joewitt opened a new pull request, #11995: URL: https://github.com/apache/nifi/pull/11995
# Summary [NIFI-16664](https://issues.apache.org/jira/browse/NIFI-16664) `OffloadIT.testOffload` timed out after 10 minutes on both Ubuntu jobs of system-tests run [46850229270](https://github.com/apache/nifi/actions/runs/46850229270) (Java 21 and 25). The coordinator stayed in `OFFLOADING` because the node never reported `OFFLOADED`. The node logged `Attempted to finish node offload for localhost:5672 but node is not in the offloading state, it is currently DISCONNECTED.` Sequence found in the logs of both jobs, where the disconnected node (node-2) was also the Cluster Coordinator: 1. A user disconnects node-2. node-2 creates a `DISCONNECTED` status with update id 9 and notifies node-1. 2. A heartbeat that node-2 sent before disconnecting reaches its own heartbeat monitor 56 to 60 ms later. The monitor logs `Ignoring received heartbeat from disconnected node` and calls `requestNodeDisconnect` again. 3. That call replaces the status with a newer one (id 10). The state is unchanged, so `updateNodeStatus` does not notify other nodes, and node-1 still has id 9. 4. node-2 gives up the Cluster Coordinator role and node-1 takes it over. A user requests the offload, and node-1 creates the `OFFLOADING` status. `NodeConnectionStatus.updateIdGenerator` only raised the counter to the last received id (9), so the new status also gets id 9. 5. node-2 ignores the status because `updateNodeStatus` rejects a status with a lower update id than the current one (9 < 10), and it logs this at debug level only. node-2 never leaves `DISCONNECTED`, so it cannot report `OFFLOADED`. Changes: - `NodeClusterCoordinator.requestNodeDisconnect` leaves the existing status unchanged when the node is already `DISCONNECTED` with the same disconnection code and reason. The disconnect message is still sent. - `NodeConnectionStatus.updateIdGenerator` now makes the next update identifier greater than the received identifier, not equal to it. This also removes duplicate identifiers between nodes in other cases. Limits of the analysis: the logs contain no debug output showing node-2 receiving and dropping the `OFFLOADING` status, so step 5 is derived from the code and from the unit test below, which reproduces the stuck state. This has not been reproduced end to end. It requires the disconnected node to be the Cluster Coordinator and the late heartbeat to arrive in a window of roughly 140 ms. In local runs of `OffloadIT` node-1 was the coordinator in every run, which fits the failure not appearing there. # Tracking Please complete the following tracking steps prior to pull request creation. ### Issue Tracking - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created ### Pull Request Tracking - [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000` - [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000` - [x] Pull request contains [commits signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) with a registered key indicating `Verified` status ### Pull Request Formatting - [x] Pull Request based on current revision of the `main` branch - [x] 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 `./mvnw clean install -P contrib-check` - [ ] JDK 21 - [ ] JDK 25 Ran `./mvnw -P contrib-check verify` on the two changed modules only, `nifi-framework-cluster-protocol` and `nifi-framework-cluster`, with JDK 21 and JDK 25. Both builds succeeded with 234 tests, 0 failures. ### Verification performed - [x] Four new tests in `TestNodeClusterCoordinator`. Without the changes to `NodeClusterCoordinator` and `NodeConnectionStatus`, three of them fail: - `testRepeatedDisconnectRequestKeepsUpdateIdentifierOfDisconnectedNode` - `testLocallyCreatedStatusIsNewerThanReceivedStatus` - `testOffloadRequestAfterRepeatedDisconnectRequestIsAppliedByDisconnectedNode`, which ends with the node still `DISCONNECTED`, as in the failed runs - `testDisconnectRequestWithDifferentCodeReplacesDisconnectedStatus` passes with and without the changes and covers that a different disconnect code still replaces the status ### 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 Not applicable: no dependencies are added or changed. ### Documentation - [ ] Documentation formatting appears as expected in rendered files Not applicable: no documentation is changed. -- 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]
