transactionsgremlintinkerpopjanusgraphgremlinpython

How to rollback gremlin transaction using gremlinpython?


I'm new to gremlin, I'm trying to use python library gremlinpython to connect to Janus Graph and need to know if it is possible to rollback transaction.

I've found that single traversal is equivalent to single transaction (tinkerPop docs), traversal is created after connecting to gremlin server: g = traversal().withRemote(...) and all operations with g are executed in a single transaction.

But I can't find what will happen if error occurs in any of operations. Is it possible to rollback all operations made with g? gremlin server allows to do smth like g.tx().rollback() or g.tx().commit() - to rollback or approve transaction, but is it possible to do this using gremlinpython?


Solution

  • If an error occurs then Gremlin Server will automatically rollback the transaction for you. If it is successful it will automatically commit for you. The semantics of "rollback" or "commit" are graph database dependent (i.e. some graphs may commit partial transactions even in the face of rollback) and in the case of JanusGraph will be further dependent upon the underlying storage engine (e.g. Cassandra, Hbase, etc).