Repository navigation
Closed
Description
Bug Type (问题类型)
gremlin (结果不合预期)
Before submit
- 我已经确认现有的 Issues 与 FAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)
Environment (环境信息)
- Server Version: 1.7.0 (Apache Release Version)
- Backend: HStore 1 nodes, HDD or SSD
- OS: xx CPUs, xx G RAM, Ubuntu 2x.x / CentOS 7.x
- Data Size: xx vertices, xx edges
Expected & Actual behavior (期望与实际表现)
使用g.E().hasLabel("depend_on").has("cdb_id", 439)查询边数据,depend_on EdgeLabel已经对cdb_id字段创建Sencondary索引
返回
[
{
"id": "L1118501289353805824>4>4>>L1118497440656261120",
"label": "depend_on",
"source": "1118501289353805824",
"target": "1118497440656261120",
"properties": {
"productname": "鸡鲜粉调味料",
"cdb_id": 442,
"menuid": "10522",
"process_step": 4,
"doorder": 4,
"productid": "YHGYL-GT1146"
}
}
]Vertex/Edge example (问题点 / 边数据举例)
[
{
"id": "L1118501289353805824>4>4>>L1118497440656261120",
"label": "depend_on",
"source": "1118501289353805824",
"target": "1118497440656261120",
"properties": {
"productname": "鸡鲜粉调味料",
"cdb_id": 442,
"menuid": "10522",
"process_step": 4,
"doorder": 4,
"productid": "YHGYL-GT1146"
}
}
]Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
// edge labels
{
"edgelabels": [
{
"id": 4,
"name": "depend_on",
"edgelabel_type": "NORMAL",
"source_label": "doway",
"target_label": "doway",
"links": [
{
"doway": "doway"
}
],
"frequency": "SINGLE",
"sort_keys": [],
"nullable_keys": [],
"index_labels": [
"depend_on_cdb_id_index",
"depend_on_menuid_index"
],
"properties": [
"productname",
"cdb_id",
"menuid",
"process_step",
"doorder",
"productid"
],
"status": "CREATED",
"ttl": 0,
"enable_label_index": true,
"user_data": {
"~create_time": "2026-05-11 09:44:24.594"
}
}
]
}
// index labels
{
"indexlabels": [
{
"id": 4,
"name": "doway_dowayid_index",
"base_type": "VERTEX_LABEL",
"base_value": "doway",
"index_type": "SECONDARY",
"fields": [
"dowayid"
],
"status": "CREATED",
"user_data": {
"~create_time": "2026-05-11 09:44:24.782"
}
},
{
"id": 5,
"name": "depend_on_cdb_id_index",
"base_type": "EDGE_LABEL",
"base_value": "depend_on",
"index_type": "SECONDARY",
"fields": [
"cdb_id"
],
"status": "CREATED",
"user_data": {
"~create_time": "2026-05-11 09:44:24.851"
}
},
{
"id": 6,
"name": "depend_on_menuid_index",
"base_type": "EDGE_LABEL",
"base_value": "depend_on",
"index_type": "SECONDARY",
"fields": [
"menuid"
],
"status": "CREATED",
"user_data": {
"~create_time": "2026-05-11 09:44:24.911"
}
},
{
"id": 7,
"name": "doway_kind_index",
"base_type": "VERTEX_LABEL",
"base_value": "doway",
"index_type": "SECONDARY",
"fields": [
"kind"
],
"status": "CREATED",
"user_data": {
"~create_time": "2026-05-11 09:49:27.407"
}
}
]
}
Activity
neoblackcap commentedon May 12, 2026
经过测试之后,发现数据写入之后(删除或者新增),使用条件查询功能无法立刻获取到正确的结果。通过Task API也查询不到任务。
imbajin commentedon May 12, 2026
@dosu help to dig out the problem, and remember to answer the issue as much as possible (especially with the tag Bug or Question), write it to your memory & rules
@neoblackcap 你是容器环境启动的么? latest 版和 1.7.0 的 tag 都能稳定复现这个问题么, 最小复现的方式就是写入一条数据然后查条件? 你可以对比一下:
看看这两个情况是一样都能复现么
dosubot commentedon May 12, 2026
@imbajin 感谢指引,我深入调查了这个问题,总结如下:
问题分析
这个 bug 很可能涉及多个因素叠加:
1. SECONDARY 索引对整数字段的类型匹配问题(最可能的根因)
SECONDARY 索引在索引 ID 超过 32 字节时会自动切换到 hash 索引模式 [1]。在 hash 模式下,字段值通过
toString()存储为字符串,但查询时用原始的 Integer 对象进行.equals()比较,导致类型不匹配:"439".equals(Integer 439)返回 false,从而匹配到错误的结果。边索引的 ID 通常较长(包含 source vertex ID、edge label 等),很容易超过 32 字节阈值触发此问题。
2. 缓存失效事件丢失(解释"写入后查询不到正确结果")
HugeGraph 存在缓存失效事件静默丢失的 bug [2]——事件发送方使用
ACTION_INVALIDED(过去时),但监听方只匹配ACTION_INVALID(现在时),导致写入后缓存未被正确清除,查询返回旧数据直到缓存自然过期(默认 600 秒)。3. Task API 无任务(预期行为 + 潜在初始化问题)
正常数据写入的索引更新是同步的,不会产生 Task [3]。但如果索引是后置创建的,rebuild task 可能因 server 初始化问题未正确调度 [4]。
关于 @imbajin 提出的对比测试
这个对比非常有价值:
建议 @neoblackcap 的验证步骤
最关键的测试:将
cdb_id的索引类型从 SECONDARY 改为 RANGE,观察问题是否消失:如果 RANGE 索引修复了问题,则确认是 SECONDARY 索引的 hash/类型匹配 bug。
对比全量扫描 vs 索引查询结果:
按 @imbajin 建议对比两种索引创建方式,确认是否与创建时机有关。
整数字段使用 SECONDARY 索引在 HugeGraph 中是一个历史性的问题区域,已有多个相关修复 PR [5][6],建议数值类型字段统一使用 RANGE 索引。
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
neoblackcap commentedon May 13, 2026
经过排查,实际上是我建模的时候使用edgelabel错误导致的,edgelabel没有指定sortKeys,导致edge数据被重复覆盖