简体   繁体   中英

Titan Cassandra - Ghost Vertices and Inconsistent Read Behavior Until Restart

Deleting vertices from Titan leads to inconsistent read behavior. I'm testing this on a single machine running Cassandra, here's my conf.properties:

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

The following method deletes the appropriate vertex:

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();
}

When the following method gets called it returns two different sets of results:

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;
}

One result will be as expected - it will not contain the deleted profile. However, when I run it enough times - it sometimes will contain one extra profile - the one which was deleted.

Attempting to delete the same vertex again shows that no vertex exists with that 'uuid', the iterator's hasNext() returns false.

After the program is restarted, however, it never returns the deleted vertex. How can I fix this inconsistent behavior?

The problem is that on some threads, transactions had been opened for the graph already. Reading from the graph opens up a transaction, even if nothing is changed. These transactions need to be closed in order to ensure that the behavior is consistent.

根据http://s3.thinkaurelius.com/docs/titan/0.9.0-M2/tx.html#tx-config,您应该设置checkInternalVertexExistence

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM