JanusGraph / JanusGraph/janusgraph
The transaction listener can not be used on threaded transactions
- Dominant language
- Java
- Stars
- 5.8k
- Forks
- 1.2k
- Avg merge
- 13h 53m
- Merged PRs (30d)
- 6
Description
I'm using JanusGraph 0.4.0 with multi-threaded transactions (`graph = janusGraph.buildTransaction().start()`).
I register a transaction listener with `graph.tx().addTransactionListener(listener)` but when I commit the transaction (`graph.tx().commit()`), the listener is not executed.
With multi-threaded transactions (`StandardJanusGraphTx`), each call to `tx()` give a new instance of `Transaction`. Thus the commit/rollback must be called on the same instance on which the listener was added. In a real application, this is not convenient. In addition to `graph`, the transaction instance must be passed to components likely that can manipulate the graph and add a listener.
```java
graph = janusGraph.buildTransaction().start();
tx = graph.tx();
graph.tx().addTransactionListener(listener1);
tx.addTransactionListener(listener2);
graph.tx().commit(); // doesn't execute listener1 nor listener2
tx.commit(); // execute only listener2
```
Contributor guide
Research direction
Start by reading StandardJanusGraphTx and the Transaction APIs around addTransactionListener, commit, and rollback. Reproduce the two transaction-instance cases described in the issue, then trace how listeners are stored and invoked; done means listeners registered for the threaded transaction are invoked when the transaction is committed or rolled back through the expected graph transaction path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100