[ 
https://issues.apache.org/jira/browse/TINKERPOP-2719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17509774#comment-17509774
 ] 

ASF GitHub Bot commented on TINKERPOP-2719:
-------------------------------------------

FlorianHockmann commented on a change in pull request #1586:
URL: https://github.com/apache/tinkerpop/pull/1586#discussion_r830980112



##########
File path: 
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
##########
@@ -383,9 +383,14 @@ protected void handleIterator(final Context context, final 
Iterator itty, final
                         break;
                     }
 
+                    // track whether there is anything left in the iterator 
because it needs to be accessed after
+                    // the transaction could be closed - in that case a call 
to hasNext() could open a new transaction
+                    // unintentionally
+                    final boolean moreInIterator = itty.hasNext();

Review comment:
       Thanks for the detailed explanation! Our understanding of your earlier 
suggestion was wrong based on that. Our assumption was that you wanted to get 
rid of the additional call `itty.hasNext()` completely.
   
   But then it definitely sounds good to reuse `hasMore` hereinstead of adding 
`moreInIterator`. Pushed an updated commit that incorporates this change also 
for the `AbstractOpProcessor` which already used `moreInIterator` before.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


> hasNext is called on TraverserIterator after transaction is committed
> ---------------------------------------------------------------------
>
>                 Key: TINKERPOP-2719
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2719
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: server
>    Affects Versions: 3.5.2
>            Reporter: Florian G
>            Priority: Major
>
> In {{{}TraversalOpProcessor{}}}, the {{hasNext()}} [function is 
> called|https://github.com/apache/tinkerpop/blob/a52887d084053cd420580a0c0a80e745b49ee252/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java#L428]
>  on a {{TraversalIterator}} object after the transaction [is 
> committed|https://github.com/apache/tinkerpop/blob/a52887d084053cd420580a0c0a80e745b49ee252/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java#L414].
>  This causes issues if the database tries to further execute the traversal 
> upon the {{hasNext()}} call but has no access to the transaction anymore.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to