Transactions - tx.commit vs tx.close
I have a question related to transactions. I'm having issues with tx.commit() hanging locally when running through Tinkerpop (this is fine when connected to Amazon Neptune), although tx.close() does seem to work instead.
So I'm wondering whats the difference between tx.commit() and tx.close() ? Are they ok to be substituted for one another?
6 Replies
Could you please clarify what you mean by "hanging locally"? do you mean you are using Gremlin Server locally when testing in lieu of Neptune?
correct - I'm writing/testing a script to update some edges. Locally we connect to Gremlin Server this is where I am having the issue
Gremlin Server uses TinkerGraph by default. TinkerGraph does not support transactions and I assume you've not changed the default graph configuration. I'm a bit surprised it ends in hanging though and if that is the case we should probably make some improvement there. For now, if you want to mimic Neptune behavior locally, you will want to use a graph that supports transactions in Gremlin Server. Options would include configuring Neo4j, an in-memory JanusGraph, Bitsy, or the like. In the future, there are plans to make it so that TinkerGraph has a very simple transaction system cc/ @Valentyn Kahamlyk which will make it a better default local testing system. does that make sense?
I don't see a hanging behavior with the Java driver:
the error message is poor in Gremlin Console, but within the stack trace the reason is quite clear (and if you were building a Java application this is the message you would get:
Given the tag that you have on this question it appears you are using javascript. I've created: https://issues.apache.org/jira/browse/TINKERPOP-2913 to track this issue. Thank you for bringing it up.
Interesting... the transaction seems to complete when I use
tx.close()
though (as my tests for the transaction result pass) which seems to conflict with the above?There is something unique to Neptune that will commit the transaction on
tx.close()
. Note that in Java, I get the same error for trying to call that method:
Interesting that tx.close()
works in Javascript. I'm not sure what Javascript is doing that is allowing tx.close()
to work with TinkerGraph. I'll make a note on that JIRA to have that reviewed as well across programming languages.
i think i'd avoid tx.close()
if you can and prefer using a transactional graph for your local testing. it might be a bit annoying to have to setup Gremlin Server with in-memory JanusGraph or whatever you choose, but until TinkerGraph supports transactions i'd say that's the "right" way to do it. And, when TinkerGraph does support transactions you could simply swap back to it without having to change much.thanks for your help. It may be something to do with the docker image we are using for the gremlin server that this obscurity happens (that or our code!) I'll have a play around