0.5.3 Upsert and RemoveRelation Issues


sammy.jia@...
 

Hello, 

I am using Java and JanusGraph 0.5.3, but I am having issues with a specific snippet of code. The code upserts a vertex and then adds a Cardinality.single property to the upserted vertex, even if the vertex already has the correct property value. The code snippet is provided at the bottom of this message.

The code works fine for inserted vertices, but it generates an IllegalArgumentException for updated vertices. The exception is being generated by StandardJanusGraphTx.java's removeRelation method. After some debugging, I discovered that the exact same property step is being called twice for updated vertices. The first property method call uses removeRelation to delete the old property from the updated vertex. The second property method call then uses removeRelation to delete the exact same old property as the first method call (they share the same ID). Strangely, the old property still thinks it is in the 'loaded' state. Midway through removeRelation, the server realizes that that the property has already been deleted, updates the property's lifecycle to 'removed' at roughly StandardJanusGraphTx.java:595, and throws an exception at StandardJanusGraphTx.java:602.

P.S. In this specific case, I was replacing a property with the exact same value. Eg. the updated vertex already has a property called "prop3" with the value "value3", but I am calling property("prop3", "value3") anyways without checking the vertex's state.

I have three main questions:
1. Why is the property step being called twice?
2. Does JanusGraph allow you to update a Cardinality.single property twice? 
3. Why does removeRelation generate a generic IllegalArgumentException when we delete something that has already been deleted? Shouldn't it just output a log and exit the method?

---

GraphTraversal<Vertex, Vertex> graphTraversal = null;

for (….) {

    if (graphTraversal == null) {

        graphTraversal = graphTraversalSource.V().has("prop1", "value1").fold()

            .coalesce(__.unfold(),

                 __.addV("label")

                .property("prop1", "value1")

                .property("prop2", "value2"));

 

    } else {

        graphTraversal.V().hasLabel("label").has("prop1", "value1").fold()

            .coalesce(__.unfold(),

                __.addV("label")

                .property("prop1", "value1")

                .property("prop2", "value2"));

    }

    graphTraversal.property("prop3", "value3");  // this is somehow being called twice

}

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.