You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NIFI-15885: Addressed issues that cause Offload to get stuck: when a … (#11184)
* NIFI-15885: Addressed issues that cause Offload to get stuck: when a processor extends AbstractSessionFactoryProcessor and stores a reference to a created ProcessSession but not its factory, garbage collection could cause framework to be unable to rollback sessions. When a processor is terminated, ensure we rollback retained sessions even if all threads are completed. Fixed related bug that caused background thread never to complete when waiting for processor thread count to reach 1 and terminate set it to 0.
* NIFI-15885: Fix to unit test
* NIFI-15885: Allow StandardProcessSession.migrate to unwrap delegating Session wrappers so FactoryRetainingProcessSession (used to keep an ActiveProcessSessionFactory reachable for offload/terminate) is recognized as a StandardProcessSession target. Adds a framework-internal DelegatingProcessSession contract implemented by the wrapper, and an IT covering the migrate-to-wrapper path that reproduces the MergeRecord CI failure.
Copy file name to clipboardExpand all lines: nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1905,6 +1905,14 @@ public void run() {
1905
1905
}
1906
1906
}
1907
1907
}
1908
+
} elseif (lifecycleState.isTerminated()) {
1909
+
// Termination was requested while the stop sequence was waiting for active threads to drain.
1910
+
// LifecycleState.terminate() reset the active thread count to zero, so the count==1
1911
+
// condition above will never be reached and rescheduling would loop forever. Complete the
1912
+
// stop action and exit. completeStopAction() is idempotent if procNode.terminate() already
1913
+
// invoked it.
1914
+
LOG.debug("Stop sequence for {} aborted because LifecycleState was terminated", this);
1915
+
completeStopAction();
1908
1916
} else {
1909
1917
// Not all of the active threads have finished. Try again in 100 milliseconds.
Copy file name to clipboardExpand all lines: nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/StandardProcessSession.java
+14-2Lines changed: 14 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1501,11 +1501,23 @@ public void migrate(final ProcessSession newOwner, final Collection<FlowFile> fl
1501
1501
thrownewIllegalArgumentException("Must supply at least one FlowFile to migrate");
1502
1502
}
1503
1503
1504
-
if (!(newOwnerinstanceofStandardProcessSession)) {
1504
+
// Look through any framework-internal Session wrappers (such as the one used to keep an
1505
+
// ActiveProcessSessionFactory reachable for the offload/terminate path) so the underlying
1506
+
// StandardProcessSession can be located.
1507
+
ProcessSessionresolvedOwner = newOwner;
1508
+
while (resolvedOwnerinstanceofDelegatingProcessSessiondelegating) {
1509
+
resolvedOwner = delegating.getDelegate();
1510
+
}
1511
+
1512
+
if (!(resolvedOwnerinstanceofStandardProcessSessionstandardOwner)) {
1505
1513
thrownewIllegalArgumentException("Cannot migrate from a StandardProcessSession to a " + newOwner.getClass());
Copy file name to clipboardExpand all lines: nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/WeakHashMapProcessSessionFactory.java
0 commit comments