parakhnr opened a new pull request, #2489:
URL: https://github.com/apache/helix/pull/2489
### Issues
- [X] My PR addresses the following Helix issues and references them in the
PR description:
* Fixes #2200, #2387
### Description
- [X] Here are some details about my PR, including screenshots of any UI
changes:
#### Brief overview of the integration test
In a nutshell, the integration test verifies that he metrics for the
`ClusterStatus` are emitted correctly when participants/controller_participants
are added/removed.
#### What's the failure?
Towards the end of the test, we disconnect all the controller from the super
cluster and ensure that there are 0 metrics related to the `ClusterStatus`
being emitted.
#### Analysis
Upon debugging the test failure from the logs, I found a race condition for
the last controller `controller_9(CONTROLLER_PARTICIPANT) ` in the super
cluster disconnect process which can be explained from the logs below:
```
--- Disconnect initiated for **controller_9[CONTROLLER_PARTICPANT]**
2023-05-09T17:14:02.0244076Z 5813977
[ClusterManager_Watcher_CONTROLLER_TestClusterStatusMonitorLifecycle_controller_9_CONTROLLER_PARTICIPANT_11918]
INFO org.apache.helix.manager.zk.ZKHelixManager [] - disconnect
controller_9(CONTROLLER_PARTICIPANT) from
CONTROLLER_TestClusterStatusMonitorLifecycle
--- Message to become leader sent by the **controller_9**
2023-05-09T17:14:02.2758113Z 5814083
[HelixController-pipeline-default-CONTROLLER_TestClusterStatusMonitorLifecycle-(075feaf2_DEFAULT)]
INFO org.apache.helix.controller.stages.MessageDispatchStage [] - Event
075feaf2_DEFAULT : Sending Message 1495e9e6-e04c-4e43-b565-8aa64f22039e to
controller_9 transit
TestClusterStatusMonitorLifecycle0.TestClusterStatusMonitorLifecycle0_9|[]
from:STANDBY to:LEADER, relayMessages: 0
--- **controller_9** attempts to become leader for
**TestClusterStatusMonitorLifecycle0_9** due to the StateModel transition
2023-05-09T17:14:02.4001289Z 5814212
[HelixTaskExecutor-message_handle_STATE_TRANSITION] INFO
org.apache.helix.participant.DistClusterControllerStateModel [] - controller_9
becoming leader from standby for TestClusterStatusMonitorLifecycle0_9
--- *controller_9** becomes leader for
**TestClusterStatusMonitorLifecycle0_9** due to the StateModel transition
2023-05-09T17:14:03.9794014Z 5815598
[HelixTaskExecutor-message_handle_STATE_TRANSITION] INFO
org.apache.helix.participant.AbstractHelixLeaderStandbyStateModel [] - Helix
Service Controller for cluster TestClusterStatusMonitorLifecycle0_9 on instance
controller_9 became LEADER from STANDBY
--- Rest the state model which disconnects **controller_9** from being the
controller for **TestClusterStatusMonitorLifecycle0_9**
2023-05-09T17:14:02.4037210Z 5814273
[ClusterManager_Watcher_CONTROLLER_TestClusterStatusMonitorLifecycle_controller_9_CONTROLLER_PARTICIPANT_11918]
INFO org.apache.helix.participant.HelixStateMachineEngine [] - Operating on
TestClusterStatusMonitorLifecycle0::TestClusterStatusMonitorLifecycle0_9
```
Based on the above logs, reset for `TestClusterStatusMonitorLifecycle0_9`
happens before the `controller_9` transitions to being leader for
`TestClusterStatusMonitorLifecycle0_9` which results in disconnect being not
[invoked](https://github.com/apache/helix/blob/1f5c5c82fb5bc8273f3d6e04b4cc245e77ece2c8/helix-core/src/main/java/org/apache/helix/participant/DistClusterControllerStateModel.java#L116)
as reset only works if the controller is the leader for that resource
partition. So, this leaves `controller_9` be the leader despite it's
disconnected.
#### Solution
We should wait for the cluster to stabilize before we disconnect it
especially when are taking controllers from the super cluster one after
another.
**NOTE: This is not fixing the actual race condition. Fixing the race
condition will be prioritized later since it's a larger and complex effort.**
### Tests
- [X] The following tests are written for this issue:
Ran the `TestClusterStatusMonitorLifecyle` integration test locally 10 times
in a loop successfully.
### Changes that Break Backward Compatibility (Optional)
N/A
### Documentation (Optional)
N/A
### Commits
- My commits all reference appropriate Apache Helix GitHub issues in their
subject lines. In addition, my commits follow the guidelines from "[How to
write a good git commit message](http://chris.beams.io/posts/git-commit/)":
1. Subject is separated from body by a blank line
1. Subject is limited to 50 characters (not including Jira issue reference)
1. Subject does not end with a period
1. Subject uses the imperative mood ("add", not "adding")
1. Body wraps at 72 characters
1. Body explains "what" and "why", not "how"
### Code Quality
- My diff has been formatted using helix-style.xml
(helix-style-intellij.xml if IntelliJ IDE is used)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]