loserwang1024 opened a new issue, #3648:
URL: https://github.com/apache/fluss/issues/3648

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/fluss/issues) and 
found nothing similar.
   
   
   ### Fluss version
   
   0.9.0 (latest release)
   
   ### Please describe the bug 🐞
   
   `CoordinatorLeaderElection.close()` closes the `LeaderLatch` and immediately 
shuts down the leader callback executor
   ```java
   leaderLatch.close();
   leaderCallbackExecutor.shutdownNow();
   ```
   
   Closing the LeaderLatch triggers the notLeader() callback, which submits 
leader cleanup asynchronously to leaderCallbackExecutor.
   There is a race where shutdownNow() interrupts or cancels the cleanup task 
before it finishes. As a result, cleanupCoordinatorLeader() may not complete 
and the coordinator leader registration may remain in ZooKeeper during shutdown.
   This can cause a newly started CoordinatorServer to repeatedly fail 
registration:
   ```java
   Node for coordinator server already exists in Zookeeper.
   Retrying register after 3000 ms....
   ```
   
   It can also cause coordinator restart tests to time out while waiting for 
the old ZooKeeper node to disappear.
   
   
   ### Solution
   
   CoordinatorLeaderElection.close() should ensure that leader cleanup finishes 
before shutting down the callback executor.
   The cleanup must still execute exactly once when LeaderLatch.close() and the 
explicit shutdown path race with each other.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
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]

Reply via email to