You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "markap14 (via GitHub)" <gi...@apache.org> on 2024/06/10 20:57:18 UTC

[PR] NIFI-13340: Fixed a bug in which an Output Port can leave a Process G… [nifi]

markap14 opened a new pull request, #8951:
URL: https://github.com/apache/nifi/pull/8951

   …roup's DataValve open for output, but then the last FlowFile is terminated instead of going to an Output Port, ultimately resulting in the DataValve remaining open indefinitely. Now, this will be detected and the valve will be closed.
   
   <!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
   <!-- contributor license agreements.  See the NOTICE file distributed with -->
   <!-- this work for additional information regarding copyright ownership. -->
   <!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
   <!-- (the "License"); you may not use this file except in compliance with -->
   <!-- the License.  You may obtain a copy of the License at -->
   <!--     http://www.apache.org/licenses/LICENSE-2.0 -->
   <!-- Unless required by applicable law or agreed to in writing, software -->
   <!-- distributed under the License is distributed on an "AS IS" BASIS, -->
   <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
   <!-- See the License for the specific language governing permissions and -->
   <!-- limitations under the License. -->
   
   # Summary
   
   [NIFI-00000](https://issues.apache.org/jira/browse/NIFI-00000)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [ ] Build completed using `mvn clean install -P contrib-check`
     - [ ] JDK 21
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
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: issues-unsubscribe@nifi.apache.org

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


Re: [PR] NIFI-13340: Fixed a bug in which an Output Port can leave a Process G… [nifi]

Posted by "jrsteinebrey (via GitHub)" <gi...@apache.org>.
jrsteinebrey commented on code in PR #8951:
URL: https://github.com/apache/nifi/pull/8951#discussion_r1635325711


##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardDataValve.java:
##########
@@ -67,30 +70,46 @@ public synchronized boolean tryOpenFlowIntoGroup(final ProcessGroup destinationG
             return true;
         }
 
-        final String reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+        final FlowInForbiddenReason reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+
+        // If we are forbidding data to flow into the group due to the fact that data is currently allowed to flow out of the group,
+        // and the valve was left open due to data being queued, let's verify that there is actually data queued up to flow out at the moment.
+        // If there is not, remove the group from those that are currently allowing data to flow out. This can happen in the following situation:
+        // - A FlowFile comes into the group
+        // - The FlowFile is split into two FlowFiles
+        // - One of the FlowFiles is routed to the Output Port, while the other is routed elsewhere
+        // - The Output Port is triggered. It opens the valve to allow data to flow out of the group.
+        // - The Output Port goes to close flow out of the group. However, the group is not empty, so the valve is not closed.
+        // - The other FlowFile is never routed to an output port. Instead, it is auto-terminated by some processor.
+        // Now, the valve has been left open.
+        // In this case, though, when the Output Port failed to close the valve, this.leftOpenDueToDataQueued was set to true. If that is the case,
+        // we can go ahead and close the valve now, if there's no more data queued.
+        if (reasonForNotAllowing == FlowInForbiddenReason.OPEN_FOR_OUTPUT && leftOpenDueToDataQueued && !destinationGroup.isDataQueued()) {
+            groupsWithDataFlowingOut.remove(destinationGroup.getIdentifier());
+        }
+
         if (reasonForNotAllowing != null) {
             // Since there is a reason not to allow it, return false. The reason has already been logged at a DEBUG level.
             return false;
         }
 
-
         logger.debug("Opening valve to allow data to flow into {}", destinationGroup);
         groupsWithDataFlowingIn.add(destinationGroup.getIdentifier());

Review Comment:
   This is the part of the code which my first comment above is referring.



-- 
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: issues-unsubscribe@nifi.apache.org

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


Re: [PR] NIFI-13340: Fixed a bug in which an Output Port can leave a Process G… [nifi]

Posted by "jrsteinebrey (via GitHub)" <gi...@apache.org>.
jrsteinebrey commented on code in PR #8951:
URL: https://github.com/apache/nifi/pull/8951#discussion_r1635304636


##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardDataValve.java:
##########
@@ -67,30 +70,46 @@ public synchronized boolean tryOpenFlowIntoGroup(final ProcessGroup destinationG
             return true;
         }
 
-        final String reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+        final FlowInForbiddenReason reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+
+        // If we are forbidding data to flow into the group due to the fact that data is currently allowed to flow out of the group,
+        // and the valve was left open due to data being queued, let's verify that there is actually data queued up to flow out at the moment.
+        // If there is not, remove the group from those that are currently allowing data to flow out. This can happen in the following situation:
+        // - A FlowFile comes into the group
+        // - The FlowFile is split into two FlowFiles
+        // - One of the FlowFiles is routed to the Output Port, while the other is routed elsewhere
+        // - The Output Port is triggered. It opens the valve to allow data to flow out of the group.
+        // - The Output Port goes to close flow out of the group. However, the group is not empty, so the valve is not closed.
+        // - The other FlowFile is never routed to an output port. Instead, it is auto-terminated by some processor.
+        // Now, the valve has been left open.
+        // In this case, though, when the Output Port failed to close the valve, this.leftOpenDueToDataQueued was set to true. If that is the case,
+        // we can go ahead and close the valve now, if there's no more data queued.
+        if (reasonForNotAllowing == FlowInForbiddenReason.OPEN_FOR_OUTPUT && leftOpenDueToDataQueued && !destinationGroup.isDataQueued()) {
+            groupsWithDataFlowingOut.remove(destinationGroup.getIdentifier());

Review Comment:
   Does reasonForNotAllowing need to be set equal to null here so that the we can execute past 
   if (reasonForNotAllowing != null) { which causes an early return exit.
   If not set to null then code will not execute:
   groupsWithDataFlowingIn.add(destinationGroup.getIdentifier());
   which seems to be the main goal of this fixing method.
   



-- 
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: issues-unsubscribe@nifi.apache.org

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


Re: [PR] NIFI-13340: Fixed a bug in which an Output Port can leave a Process G… [nifi]

Posted by "jrsteinebrey (via GitHub)" <gi...@apache.org>.
jrsteinebrey commented on code in PR #8951:
URL: https://github.com/apache/nifi/pull/8951#discussion_r1636418649


##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardDataValve.java:
##########
@@ -67,30 +70,46 @@ public synchronized boolean tryOpenFlowIntoGroup(final ProcessGroup destinationG
             return true;
         }
 
-        final String reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+        final FlowInForbiddenReason reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+
+        // If we are forbidding data to flow into the group due to the fact that data is currently allowed to flow out of the group,
+        // and the valve was left open due to data being queued, let's verify that there is actually data queued up to flow out at the moment.
+        // If there is not, remove the group from those that are currently allowing data to flow out. This can happen in the following situation:
+        // - A FlowFile comes into the group
+        // - The FlowFile is split into two FlowFiles
+        // - One of the FlowFiles is routed to the Output Port, while the other is routed elsewhere
+        // - The Output Port is triggered. It opens the valve to allow data to flow out of the group.
+        // - The Output Port goes to close flow out of the group. However, the group is not empty, so the valve is not closed.
+        // - The other FlowFile is never routed to an output port. Instead, it is auto-terminated by some processor.
+        // Now, the valve has been left open.
+        // In this case, though, when the Output Port failed to close the valve, this.leftOpenDueToDataQueued was set to true. If that is the case,
+        // we can go ahead and close the valve now, if there's no more data queued.
+        if (reasonForNotAllowing == FlowInForbiddenReason.OPEN_FOR_OUTPUT && leftOpenDueToDataQueued && !destinationGroup.isDataQueued()) {
+            groupsWithDataFlowingOut.remove(destinationGroup.getIdentifier());

Review Comment:
   I withdraw my above comment because I now realized that the code will work correctly as is because this tryOpenFlowIntoGroup will get called again in the future and then on the second call, it will open the flow.



-- 
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: issues-unsubscribe@nifi.apache.org

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


Re: [PR] NIFI-13340: Fixed a bug in which an Output Port can leave a Process G… [nifi]

Posted by "jrsteinebrey (via GitHub)" <gi...@apache.org>.
jrsteinebrey commented on code in PR #8951:
URL: https://github.com/apache/nifi/pull/8951#discussion_r1635304636


##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardDataValve.java:
##########
@@ -67,30 +70,46 @@ public synchronized boolean tryOpenFlowIntoGroup(final ProcessGroup destinationG
             return true;
         }
 
-        final String reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+        final FlowInForbiddenReason reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+
+        // If we are forbidding data to flow into the group due to the fact that data is currently allowed to flow out of the group,
+        // and the valve was left open due to data being queued, let's verify that there is actually data queued up to flow out at the moment.
+        // If there is not, remove the group from those that are currently allowing data to flow out. This can happen in the following situation:
+        // - A FlowFile comes into the group
+        // - The FlowFile is split into two FlowFiles
+        // - One of the FlowFiles is routed to the Output Port, while the other is routed elsewhere
+        // - The Output Port is triggered. It opens the valve to allow data to flow out of the group.
+        // - The Output Port goes to close flow out of the group. However, the group is not empty, so the valve is not closed.
+        // - The other FlowFile is never routed to an output port. Instead, it is auto-terminated by some processor.
+        // Now, the valve has been left open.
+        // In this case, though, when the Output Port failed to close the valve, this.leftOpenDueToDataQueued was set to true. If that is the case,
+        // we can go ahead and close the valve now, if there's no more data queued.
+        if (reasonForNotAllowing == FlowInForbiddenReason.OPEN_FOR_OUTPUT && leftOpenDueToDataQueued && !destinationGroup.isDataQueued()) {
+            groupsWithDataFlowingOut.remove(destinationGroup.getIdentifier());

Review Comment:
   
   
   
   Does reasonForNotAllowing need to be set equal to null here so that the we can execute past 
   if (reasonForNotAllowing != null) { which causes an early return exit.
   If not set to null then code will not execute:
   groupsWithDataFlowingIn.add(destinationGroup.getIdentifier());
   which seems to be the main goal of this method.
   



-- 
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: issues-unsubscribe@nifi.apache.org

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


Re: [PR] NIFI-13340: Fixed a bug in which an Output Port can leave a Process G… [nifi]

Posted by "jrsteinebrey (via GitHub)" <gi...@apache.org>.
jrsteinebrey commented on code in PR #8951:
URL: https://github.com/apache/nifi/pull/8951#discussion_r1635325711


##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardDataValve.java:
##########
@@ -67,30 +70,46 @@ public synchronized boolean tryOpenFlowIntoGroup(final ProcessGroup destinationG
             return true;
         }
 
-        final String reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+        final FlowInForbiddenReason reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+
+        // If we are forbidding data to flow into the group due to the fact that data is currently allowed to flow out of the group,
+        // and the valve was left open due to data being queued, let's verify that there is actually data queued up to flow out at the moment.
+        // If there is not, remove the group from those that are currently allowing data to flow out. This can happen in the following situation:
+        // - A FlowFile comes into the group
+        // - The FlowFile is split into two FlowFiles
+        // - One of the FlowFiles is routed to the Output Port, while the other is routed elsewhere
+        // - The Output Port is triggered. It opens the valve to allow data to flow out of the group.
+        // - The Output Port goes to close flow out of the group. However, the group is not empty, so the valve is not closed.
+        // - The other FlowFile is never routed to an output port. Instead, it is auto-terminated by some processor.
+        // Now, the valve has been left open.
+        // In this case, though, when the Output Port failed to close the valve, this.leftOpenDueToDataQueued was set to true. If that is the case,
+        // we can go ahead and close the valve now, if there's no more data queued.
+        if (reasonForNotAllowing == FlowInForbiddenReason.OPEN_FOR_OUTPUT && leftOpenDueToDataQueued && !destinationGroup.isDataQueued()) {
+            groupsWithDataFlowingOut.remove(destinationGroup.getIdentifier());
+        }
+
         if (reasonForNotAllowing != null) {
             // Since there is a reason not to allow it, return false. The reason has already been logged at a DEBUG level.
             return false;
         }
 
-
         logger.debug("Opening valve to allow data to flow into {}", destinationGroup);
         groupsWithDataFlowingIn.add(destinationGroup.getIdentifier());

Review Comment:
   This is the part of the code which my first comment above is referring.



-- 
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: issues-unsubscribe@nifi.apache.org

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


Re: [PR] NIFI-13340: Fixed a bug in which an Output Port can leave a Process G… [nifi]

Posted by "jrsteinebrey (via GitHub)" <gi...@apache.org>.
jrsteinebrey commented on code in PR #8951:
URL: https://github.com/apache/nifi/pull/8951#discussion_r1636418649


##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardDataValve.java:
##########
@@ -67,30 +70,46 @@ public synchronized boolean tryOpenFlowIntoGroup(final ProcessGroup destinationG
             return true;
         }
 
-        final String reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+        final FlowInForbiddenReason reasonForNotAllowing = getReasonFlowIntoGroupNotAllowed(destinationGroup);
+
+        // If we are forbidding data to flow into the group due to the fact that data is currently allowed to flow out of the group,
+        // and the valve was left open due to data being queued, let's verify that there is actually data queued up to flow out at the moment.
+        // If there is not, remove the group from those that are currently allowing data to flow out. This can happen in the following situation:
+        // - A FlowFile comes into the group
+        // - The FlowFile is split into two FlowFiles
+        // - One of the FlowFiles is routed to the Output Port, while the other is routed elsewhere
+        // - The Output Port is triggered. It opens the valve to allow data to flow out of the group.
+        // - The Output Port goes to close flow out of the group. However, the group is not empty, so the valve is not closed.
+        // - The other FlowFile is never routed to an output port. Instead, it is auto-terminated by some processor.
+        // Now, the valve has been left open.
+        // In this case, though, when the Output Port failed to close the valve, this.leftOpenDueToDataQueued was set to true. If that is the case,
+        // we can go ahead and close the valve now, if there's no more data queued.
+        if (reasonForNotAllowing == FlowInForbiddenReason.OPEN_FOR_OUTPUT && leftOpenDueToDataQueued && !destinationGroup.isDataQueued()) {
+            groupsWithDataFlowingOut.remove(destinationGroup.getIdentifier());

Review Comment:
   I withdraw my above comment because I now that the code will work correctly as is because this tryOpenFlowIntoGroup will get called again in the future and then on the second call, it will open the flow.



-- 
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: issues-unsubscribe@nifi.apache.org

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


Re: [PR] NIFI-13340: Fixed a bug in which an Output Port can leave a Process G… [nifi]

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory closed pull request #8951: NIFI-13340: Fixed a bug in which an Output Port can leave a Process G…
URL: https://github.com/apache/nifi/pull/8951


-- 
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: issues-unsubscribe@nifi.apache.org

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