docs/en/administration/management/graceful_exit.md
From v3.3 onwards, StarRocks supports Graceful Exit.
Graceful Exit is a mechanism designed to support non-disruptive upgrades and restarts of StarRocks FE, BE, and CN nodes. Its primary objective is to minimize the impact on running queries and data ingestion tasks during maintenance operations such as node restart, rolling upgrade, or cluster scaling.
Graceful Exit ensures that:
Graceful Exit mechanisms differ between FE and BE/CN nodes, as described below.
FE Graceful Exit is initiated via:
stop_fe.sh -g
This sends a SIGUSR1 signal, while the default exit (without the -g option) sends SIGTERM signal.
Upon receiving the signal:
/api/health endpoint.Follower FE
Leader FE
Read request handling is identical to the of Followers.
Write request handling requires:
If a query runs for too long, FE forcibly exits after 60 seconds (configurable via the --timeout option).
BE Graceful Exit is initiated via:
stop_be.sh -g
CN Graceful Exit is initiated via:
stop_cn.sh -g
This sends a SIGTERM signal, while the default exit (without the -g option) sends SIGKILL signal.
After receiving the signal:
INTERNAL_ERROR.The behavior that BE/CN waits for existing fragments to finish is controlled by the BE/CN configuration loop_count_wait_fragments_finish (Default: 2). The actual wait duration equals loop_count_wait_fragments_finish × 10 seconds (that is, 20 seconds by default). If fragments remain after timeout, BE/CN proceeds with normal shutdown (closing threads, network, and other processes).
From v3.4 onwards, FE no longer marks BE/CN as DEAD based on heartbeat failures. It correctly recognizes the BE/CN “exiting” state, allowing significantly longer graceful-exit windows for fragments to be completed.
stop_fe.sh -g --timeout--timeout 120.loop_count_wait_fragments_finishgraceful_exit_wait_for_frontend_heartbeatstop_be.sh -g --timeout, stop_cn.sh -g --timeoutloop_count_wait_fragments_finish * 10 to prevent termination before the BE/CN wait duration is reached.--timeout 30.Graceful Exit is enabled by default from v3.4 onwards. To disable it temporarily, set the BE/CN configuration loop_count_wait_fragments_finish to 0.
| Query Type | Expected Behavior |
|---|---|
| Short (less than 20 seconds) | BE/CN waits long enough, so queries complete normally. |
| Medium (20 to 60 seconds) | Queries completed within BE/CN wait window are returned with success; else queries are cancelled and require manual retry. |
| Long (more than 60 seconds) | Queries are likely terminated by FE/BE/CN due to timeout and requires manual retry. |
Graceful Exit ensures:
| Version | Behavior |
|---|---|
| v3.3 | BE Graceful Exit flawed: FE may prematurely mark BE/CN as DEAD, causing queries to get cancelled. The effective wait is limited (15 seconds by default). |
| v3.4+ | Fully supports extended wait duration; FE correctly identifies BE/CN “exiting” state. Recommended for production. |
kill -9, risking partial data persistence (recoverable via snapshot).StarRocks version:
Configuration:
loop_count_wait_fragments_finish is set to a positive integer.graceful_exit_wait_for_frontend_heartbeat to true allow FE to detect BE's "EXITING" state../bin/stop_fe.sh -g --timeout 60
Parameters:
--timeout: The maximum time to wait before the FE node is force-killed.Behavior:
SIGUSR1 signal first.SIGKILL.You can check the FE health via the following API:
http://<fe_host>:8030/api/health
LB removes the node after receiving consecutive non-200 responses.
For v3.3:
./be/bin/stop_be.sh -g
./be/bin/stop_cn.sh -g
For v3.4+:
./bin/stop_be.sh -g --timeout 600
./bin/stop_cn.sh -g --timeout 600
BE/CN exits immediately if no fragments remain.
Run on FE:
SHOW BACKENDS;
StatusCode:
SHUTDOWN: BE/CN Graceful Exit in progress.DISCONNECTED: BE/CN Node has fully exited.A.A is shown as DISCONNECTED from the FE side.A.Check FE logs fe.log, BE logs be.log, or CN logs cn.log to make sure whether there were tasks during the exit.
If tasks fail to complete within the Graceful Exit period, BE/CN will trigger forced termination (SIGKILL). Verify whether this is caused by excessively long task duration or improper configurations (for example, an overly small --timeout value).
If the node status is not SHUTDOWN, verify whether loop_count_wait_fragments_finish is set to a positive integer, or if BE/CN reported a heartbeat before exiting (if not, set graceful_exit_wait_for_frontend_heartbeat to true).