Unique constraint exception even when handling it

42 views
Skip to first unread message

Palash Kulshrestha

unread,
Aug 16, 2016, 4:29:45 AM8/16/16
to Aurelius

What i am trying to do is getOrCreateVertex i.e. get if the vertex is present otherwise create it. but when I hit this query v=g.V().has(idKey,idVal).tryNext().orElseGet{ graph.addVertex(T.label,vertexTypeValue, __key_customer_id, __val_customer_id);graph.tx().commit();};g.V().has(idKey,idVal);


I get the following error/exception

179127052 [gremlin-server-exec-8] WARN org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor - Exception processing a script on request [RequestMessage{, requestId=be67d041-613e-11e6-89a5-4703f811502a, op='eval', processor='', args={gremlin=

v=g.V().has(idKey,idVal).tryNext().orElseGet{ graph.addVertex(T.label,vertexTypeValue, __key_customer_id, __val_customer_id);graph.tx().commit();};g.V().has(idKey,idVal);

,

bindings={__key_c ustomer_id=customer_id, __val_customer_id=71888724, vertexTypeValue=customer, hasString=__key_customer_id, __val_customer_id, idKey=customer_id, id Val=71888724},

accept=application/json, language=gremlin-groovy}}]. com.thinkaurelius.titan.core.SchemaViolationException: Adding this property for key [customer_id] and value [71888724] violates a uniqueness constraint [customer_id]


Not able to figure out why an exception even after taking it into consideration in query itself

HadoopMarc

unread,
Aug 16, 2016, 6:26:34 AM8/16/16
to Aurelius
I think orElseGet wants a return value, while commit() is void. Try and and .commit(); null ???

Marc

Op dinsdag 16 augustus 2016 10:29:45 UTC+2 schreef Palash Kulshrestha:

Palash Kulshrestha

unread,
Aug 16, 2016, 6:57:11 AM8/16/16
to Aurelius
Thanks marc . Also  the hidden problem is that its not always throwing error. In some cases out of the blue it starts throwing exception on above query.

Palash Kulshrestha

unread,
Aug 19, 2016, 2:29:30 AM8/19/16
to Aurelius
Seems like it didn't solve the problem as errors are still coming from time to time.

Excerpt from the gremlin log
683866824 [gremlin-server-exec-3] WARN  org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor  - Exception processing a script on request [RequestMessage{, requestId=eef21220-65d5-11e6-bb81-153c7e1719fb, op='eval', processor='', args={gremlin=v=g.V().has(idKey,idVal).tryNext().orElseGet{ graph.addVertex(T.label,vertexTypeValue, __key_customer_id, __val_customer_id);graph.tx().commit();null;};g.V().has(idKey,idVal);, bindings={__key_customer_id=customer_id, __val_customer_id=9732436, vertexTypeValue=customer, hasString=__key_customer_id, __val_customer_id, idKey=customer_id, idVal=9732436}, accept=application/json, language=gremlin-groovy}}].
com.thinkaurelius.titan.core.SchemaViolationException: Adding this property for key [customer_id] and value [9732436] violates a uniqueness constraint [customer_id]
Reply all
Reply to author
Forward
0 new messages