Skip to content

Commit

Permalink
Fixed bug where elements which are read in a transaction end up with …
Browse files Browse the repository at this point in the history
…incorrect usedInTransaction counts which may trigger unintended TransactionExceptions
  • Loading branch information
Cole-Greer committed Jan 25, 2025
1 parent 9627b78 commit 2369ff2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void commit(final long txVersion) {
element.removed = true;
element = null;
isDeleted = true;
} else {
} else if (isModifiedInTx.get()){
element = transactionUpdatedValue.get();
element.currentVersion = txVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected void doCommit() throws TransactionException {

final Set<TinkerElementContainer> readElements = txReadElements.get();
if (readElements != null)
readElements.stream().forEach(e -> e.reset());
readElements.stream().forEach(e -> e.commit(txVersion));

txChangedVertices.remove();
txChangedEdges.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1457,4 +1457,24 @@ public void shouldHandleAddingVertexWhenOtherTxTryToDeleteSameVertex() throws In

countElementsInNewThreadTx(g, 1, 0);
}

@Test
public void shouldHandleSequenceOfCreateReadDeleteCreateSameVertex() {
final TinkerTransactionGraph graph = TinkerTransactionGraph.open();
final GraphTraversalSource g = graph.traversal();

g.addV().property(T.id, 1).next();
graph.tx().commit();
g.V().next();
graph.tx().commit();
g.V().drop().iterate();
graph.tx().commit();

assertEquals(false, graph.hasVertex(1));

g.addV().property(T.id, 1).next();
graph.tx().commit();

assertEquals(true, graph.hasVertex(1));
}
}

0 comments on commit 2369ff2

Please sign in to comment.