Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] range index 残留索引导致统计不准确 #1495

Closed
jadepeng opened this issue Jun 10, 2021 · 1 comment · Fixed by #1498
Closed

[Bug] range index 残留索引导致统计不准确 #1495

jadepeng opened this issue Jun 10, 2021 · 1 comment · Fixed by #1498
Labels
bug Something isn't working

Comments

@jadepeng
Copy link
Contributor

jadepeng commented Jun 10, 2021

How to reproduce ( 复现步骤 )

当前vertex写入相同id数据时,老索引并不会删除,会在后续查询是通过condtion条件过滤进行删除

但是range索引会存在问题,例如我们写入2000条数据

        SchemaManager schema = graph.schema();

        schema.vertexLabel("sj").properties("name", "update_time")
              .primaryKeys("name").create();

        schema.indexLabel("sj_update_time_range").onV("sj").range()
              .by("update_time").create();

        for (int i=1; i<=2000; i++) {
            graph.addVertex(T.label, "sj", "name", "sj"+i,
                            "update_time", i);
        }
        graph.tx().commit();

        List<Vertex> vertices;
        long count = graph.traversal().V().has("sj", "update_time", ConditionP.gt(0))
                                          .count().next();
        Assert.assertEquals(2000L, count);

让后更新 update_time

        for (int i=1; i<=2000; i++) {
            graph.addVertex(T.label, "sj", "name", "sj"+i,
                            "update_time", 2*i);
        }
        graph.tx().commit();

        count = graph.traversal().V().has("sj", "update_time", ConditionP.gt(0))
                                     .count().next();
        Assert.assertEquals(2000L, count);

查询结果是3500:

Exception in thread "main" java.lang.AssertionError: expected:<2000> but was:<3500>
 at org.junit.Assert.fail(Assert.java:88)
@jadepeng jadepeng added the bug Something isn't working label Jun 10, 2021
@imbajin
Copy link
Member

imbajin commented Jun 10, 2021

感谢反馈. 类似的确这种范围类的索引, 的确可能会在读的时候残留 (取决于读的条件是否覆盖)

解决方案之一是读的时候异步取对应 elementId 的属性值与索引进行对比, 删去不符合的部分

jadepeng pushed a commit to jadepeng/hugegraph that referenced this issue Jul 2, 2021
jadepeng pushed a commit to jadepeng/hugegraph that referenced this issue Jul 2, 2021
jadepeng pushed a commit to jadepeng/hugegraph that referenced this issue Jul 7, 2021
jadepeng pushed a commit to jadepeng/hugegraph that referenced this issue Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants