0

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?

cscan
  • 3,684
  • 9
  • 45
  • 83

2 Answers2

1

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.

cscan
  • 3,684
  • 9
  • 45
  • 83
  • This is correct. Read more about it in Titan http://s3.thinkaurelius.com/docs/titan/0.9.0-M2/tx.html#_transaction_handling and TinkerPop http://tinkerpop.incubator.apache.org/docs/3.0.0-incubating/#transactions – Jason Plurad Sep 02 '15 at 03:34
  • Another link to read from the Titan forum https://groups.google.com/d/msg/aureliusgraphs/WMpcbqVECd8/Tvg1iRKDvhcJ – Jason Plurad Sep 02 '15 at 03:37
0

According http://s3.thinkaurelius.com/docs/titan/0.9.0-M2/tx.html#tx-config you should set checkInternalVertexExistence

sibnick
  • 3,995
  • 20
  • 20
  • I tried to do that - it still has the same inconsistent behavior. The really weird thing is that cassandra is just running on one computer - ghost edges or vertices shouldn't be a problem here. – cscan Sep 01 '15 at 23:30