dawidwys commented on a change in pull request #8511: 
[FLINK-12319][Library/CEP]Change the logic of releasing node from recursive to 
non-recursive
URL: https://github.com/apache/flink/pull/8511#discussion_r295804620
 
 

 ##########
 File path: 
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/nfa/sharedbuffer/SharedBufferAccessor.java
 ##########
 @@ -235,31 +235,32 @@ public void lockNode(final NodeId node) {
         * @throws Exception Thrown if the system cannot access the state.
         */
        public void releaseNode(final NodeId node) throws Exception {
-               Lockable<SharedBufferNode> sharedBufferNode = 
sharedBuffer.getEntry(node);
-               if (sharedBufferNode != null) {
-                       if (sharedBufferNode.release()) {
-                               removeNode(node, sharedBufferNode.getElement());
-                       } else {
-                               sharedBuffer.upsertEntry(node, 
sharedBufferNode);
+               // the stack used to detect all nodes that needs to be released.
+               Stack<NodeId> nodesToExamine = new Stack<>();
+               nodesToExamine.push(node);
+
+               while (!nodesToExamine.isEmpty()) {
+                       NodeId curNode = nodesToExamine.pop();
+                       Lockable<SharedBufferNode> curBufferNode = 
sharedBuffer.getEntry(curNode);
+
+                       if (curBufferNode == null) {
+                               break;
 
 Review comment:
   What does it mean if the `currBufferNode` is null? When can it occur? 
Shouldn't we rather `continue` to clear all elements from `nodesToExamine`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to