matanper opened a new issue, #70848: URL: https://github.com/apache/doris/issues/70848
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Description A planned restart of the master FE (rolling upgrade, config change, node maintenance) always costs an unplanned master election, even though the FE has a graceful shutdown path. On SIGTERM, the shutdown hook (`fe/fe-core/src/main/java/org/apache/doris/DorisFE.java:186` on master) does the following: 1. It sets `serverReady` to false, so `/api/health` reports not ready and load balancers stop sending new connections. 2. `gracefulShutdown()` (`DorisFE.java:743`) waits up to 300 s for the queries this FE coordinates. 3. It stops the query, thrift and HTTP servers, and the JVM exits. Nothing in this path concerns the master role. During the drain, the master keeps serving metadata writes and the requests followers forward to it. When the JVM exits, the remaining electable FEs learn that the master is gone only through the replication heartbeat timeout, and then hold an election. Metadata writes and forwarded requests stall or fail for the whole failure-detection-plus-election window. The bundled BDB JE (`org.apache.doris:je:18.3.14-doris-SNAPSHOT`) already supports a controlled handover: - `ReplicatedEnvironment.transferMaster(Set<String> replicas, int timeout, TimeUnit unit)` - an overload with a `force` flag It blocks new transactions on the current master, waits until one of the named replicas has caught up, and makes that replica master. Doris does not call it anywhere (no reference in `fe/`), so even a planned restart of the master is handled like a crash. ### Solution During graceful shutdown, before the query drain, if this FE is the master: 1. Pick the electable followers that are alive (from the frontend list / `BDBHA`). 2. Call `transferMaster(followers, timeout, unit)` through the existing BDB JE environment wrapper, with a bounded timeout (for example 30-60 s, configurable). 3. On success, continue the shutdown as a follower. On `MasterTransferFailureException` or a timeout, log it and fall back to the current behaviour (shut down and let the group elect). Optionally, expose the same handover as an admin statement (something like `ALTER SYSTEM TRANSFER MASTER TO "<host>:<edit_log_port>"`), so that operators and orchestrators can move mastership before restarting a node, without sending a signal. This turns a planned master restart into one short write pause, without waiting for failure detection. Together with restarting followers first and the master last, a rolling FE restart then moves mastership exactly once and never through a timeout. ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
