gpt4 book ai didi

java - Titan Cassandra - 幽灵顶点和重新启动之前不一致的读取行为

转载 作者:行者123 更新时间:2023-12-01 11:11:23 25 4
gpt4 key购买 nike

从 Titan 中删除顶点会导致读取行为不一致。我正在运行 Cassandra 的单台机器上对此进行测试,这是我的 conf.properties:

storage.backend=cassandra
storage.hostname=localhost
storage.cassandra.keyspace=test

以下方法删除适当的顶点:

public void deleteProfile(String uuid, String puuid) {
for(Person person : this.graph.getVertices("uuid", uuid, Person.class)) {
if (person != null) {
for (Profile profile : this.graph.getVertices("uuid", puuid, Profile.class)) {
person.removeProfile(profile);
graph.removeVertex(profile.asVertex());
}
}
}
this.graph.getBaseGraph().commit();
}

当调用以下方法时,它会返回两组不同的结果:

public Iterable<ProfileImpl> getProfiles(String uuid) {
List<ProfileImpl> profiles = new ArrayList<>();
for(Person person : this.graph.getVertices("uuid", uuid, Person.class)) {
if (person != null) {
for (Profile profile : person.getProfiles()) {
profiles.add(profile.toImpl());
}
}
}
return profiles;
}

一个结果将符合预期 - 它不会包含已删除的配置文件。然而,当我运行它足够多次时 - 它有时会包含一个额外的配置文件 - 被删除的配置文件。

尝试再次删除相同的顶点表明不存在具有该“uuid”的顶点,迭代器的 hasNext() 返回 false。

但是,程序重新启动后,它永远不会返回已删除的顶点。如何解决这种不一致的行为?

最佳答案

问题在于,在某些线程上,已经为图打开了事务。即使没有任何更改,从图表中读取也会打开一个事务。这些事务需要关闭以确保行为一致。

关于java - Titan Cassandra - 幽灵顶点和重新启动之前不一致的读取行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32321447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com