You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "Cole-Greer (via GitHub)" <gi...@apache.org> on 2025/01/25 05:33:36 UTC

[PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Cole-Greer opened a new pull request, #2992:
URL: https://github.com/apache/tinkerpop/pull/2992

   This is based on a [reported issue in discord](https://discord.com/channels/838910279550238720/1260355937604997240/1332331746418491475) where users were observing a `TransactionException` due to concurrent modification in an unexpected case. The test added in this case is a simplified reproducer for the reported issue.
   
   The root cause of the issue is that a read only traversal will increment an elements [usedInTransactions](https://github.com/apache/tinkerpop/blob/077e3eb22c463545c3fc974944d4bf1d5d6a32fd/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerElementContainer.java#L65) count as the read operation must call [getWithClone()](https://github.com/apache/tinkerpop/blob/077e3eb22c463545c3fc974944d4bf1d5d6a32fd/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerElementContainer.java#L90), however in 3.7.3, the `usedInTransactions` counter is never decremented for read-only elements when the transaction is committed.
   
   In the example used in the test in this PR, vertex 1 will have an incorrect `usedInTransactions` of 1 after the read-only transaction has been committed. This causes the subsequent "delete" query not to remove the vertex from the graph as it is still "in use". This then leads to a TransactionException due to concurrent modification when the final query attempts to create a new vertex with the same ID.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on code in PR #2992:
URL: https://github.com/apache/tinkerpop/pull/2992#discussion_r1933266492


##########
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerTransaction.java:
##########
@@ -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));

Review Comment:
   Thanks for the suggestion, I've added such a test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #2992:
URL: https://github.com/apache/tinkerpop/pull/2992#issuecomment-2622297182

   Thanks, yes this was intended for 3.7. I've fixed the target branch and added a changelog entry. Will merge once actions pass.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Posted by "vkagamlyk (via GitHub)" <gi...@apache.org>.
vkagamlyk commented on PR #2992:
URL: https://github.com/apache/tinkerpop/pull/2992#issuecomment-2620751244

   Is these fix for 3.7.x or 4.x?
   
   anyway VOTE +1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Posted by "vkagamlyk (via GitHub)" <gi...@apache.org>.
vkagamlyk commented on code in PR #2992:
URL: https://github.com/apache/tinkerpop/pull/2992#discussion_r1929602092


##########
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerTransaction.java:
##########
@@ -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));

Review Comment:
   Thanks Cole for figuring this out! 
   
   I think it would be good to add a test to verify case when element is in 
   both `changedVertices` and `readElements`, that `usedInTransactions` counter will be reduced exactly 2 times



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on PR #2992:
URL: https://github.com/apache/tinkerpop/pull/2992#issuecomment-2621515408

   seems like its a fix for 3.7-dev, no? and changelog needed...otherwise VOTE +1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer merged PR #2992:
URL: https://github.com/apache/tinkerpop/pull/2992


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #2992:
URL: https://github.com/apache/tinkerpop/pull/2992#issuecomment-2620724897

   VOTE +1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Bug in TinkerTransactionGraph transaction used counts [tinkerpop]

Posted by "danielcweber (via GitHub)" <gi...@apache.org>.
danielcweber commented on PR #2992:
URL: https://github.com/apache/tinkerpop/pull/2992#issuecomment-3028646798

   I'd like to propose a 3.7.4 release containing this fix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org