Repository navigation
Conversation
Record when a rebalance started and when it reached a final status, and
return both from listRebalanceProgress.
- RebalanceTask carries startedAtMs/completedAtMs (JSON serde v3). A task
written by an older coordinator reads back as -1 (unset).
- RebalanceManager sets the start time when it generates the task and the
completion time when it persists the final status. The cancellation
task keeps the start time. Recovery restores both.
- ListRebalanceProgressResponse gets optional started_at_ms and
completed_at_ms fields. No API version bump: an older server omits them
and the client maps that to -1.
- RebalanceProgress gains startedAtMs()/completedAtMs(), and
RebalanceProgressJsonSerializer writes them when set.
- sys.list_rebalance gets started_at/completed_at TIMESTAMP_LTZ(3) columns.
- The Rust client exposes both on RebalanceProgress.
- RebalanceProgress#formatAsPercentage uses Locale.ROOT, so the output
does not depend on the machine locale ("100%", not "100 %").
Keep a summary of the last 10 finished rebalances in ZooKeeper and list them, together with the current rebalance, through Admin#listAllRebalances. Builds on the rebalance start and completion timestamps. - A finished rebalance is added to /cluster/rebalance_history/<id> as a summary (id, status, timestamps, failure reason), without the plan. The oldest entries beyond 10 are trimmed, ordered by ZooKeeper creation order. A no-op rebalance stays out of the history. On startup, a final task written before the history existed is added to it. - ListRebalanceProgressRequest gets include_history, and the response a repeated PbRebalanceInfo. LIST_REBALANCE_PROGRESS goes to version 1, and the client rejects include_history against a version 0 server. include_history cannot be combined with rebalance_id. - The coordinator snapshots the current rebalance on the event thread and reads the history on the IO executor. - RebalanceInfo (public) is the summary type. A FAILED rebalance carries the reason its first bucket was given up on. - RebalanceTask keeps each bucket's own final status, so a recovered canceled or failed rebalance no longer reports every bucket with the overall status. - Rebalance znode writes check the coordinator epoch. - New sys.list_all_rebalances procedure.
Mirror Admin#listAllRebalances in the Rust client. RebalanceInfo is the summary type, and ListRebalanceProgress v1 sends include_history. The request fails with UnsupportedVersion against a server that only supports version 0.
morazow
marked this pull request as ready for review
December 1, 2026 13:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: close #3965
Depends on #3985. The first commit on this branch is #3985 (rebalance start and
completion timestamps). Please review only the last two commits:
listRebalanceProgresscovers only the most recent rebalance. Once the next rebalancestarts, the previous one is gone, so "what happened in the last few rebalances?" can only
be answered from server logs. This PR keeps a bounded summary of finished rebalances and
lists it.
This is the history half of the earlier version of #3985, split out after review. It
keeps the design agreed in that review: a single
ListRebalanceProgressRPC withinclude_history, and history entries that store only a summary.Brief change log
History storage
start and completion time, failure reason) to
/cluster/rebalance_history/<rebalanceId>.The entry does not contain the plan, so its size does not grow with the rebalance.
order ZooKeeper created them, so coordinator clock differences after a failover cannot
reorder or wrongly trim entries.
cluster cannot push real rebalances out.
added to the history. Otherwise the next rebalance would overwrite it.
when listing. The trim does not read entries, so it keeps such an entry until it falls out
of the 10 most recent.
Listing API
ListRebalanceProgressRequestgetsinclude_history. With it, the response carries arepeated
PbRebalanceInfo: the current rebalance first, then the history, newest first.include_historycannot be combined withrebalance_id; the coordinator rejects thatwith
InvalidRequestException.LIST_REBALANCE_PROGRESSgoes to version 1. An older server ignoresinclude_historyand answers with the current rebalance only, which the client could not tell apart from
an empty history. So the client fails with
UnsupportedVersionExceptionwhen the serveronly supports version 0.
changes, and reads the history from ZooKeeper on the IO executor, so the event loop never
blocks on ZooKeeper.
RebalanceInfo(@PublicEvolving) andAdmin#listAllRebalances().sys.list_all_rebalancesprocedure:rebalance_id,rebalance_status,started_at,completed_at,failure_reason.FlussAdmin::list_all_rebalances.Related changes
RebalanceTaskstores each bucket's own final status when it differs from the overallstatus. Before, a coordinator that recovered a finished CANCELED or FAILED rebalance
reported every bucket with the overall status, including buckets that had completed.
failure_reason).leadership cannot overwrite the current task or the history.
FutureUtils#completeFromCallablealso completes the future when the callable throws anError. Without this, anErrorthrown on the IO executor would leave the client waitinguntil the RPC times out.
listRebalanceProgress(id)now throwsNoRebalanceInProgressExceptionwhen the id isnot the most recent rebalance, including when no rebalance has run. Before, an id with no
rebalance present returned an empty result. The message points to
listAllRebalances().list, it skips such entries and logs a warning.
Tests
ZooKeeperClientTest: retention trim, creation-order listing under coordinator clockskew, idempotent re-register, corrupt entries skipped and aged out, sibling znode
isolation, epoch-fenced writes.
RebalanceManagerTest: history written on completion and cancel (not on a cancellationrequest or a no-op rebalance), current-first then newest-first listing, stale snapshot
vs. history, startup backfill, per-bucket status and failure reason on recovery,
older and unknown id errors, ZooKeeper read failure.
RebalanceTaskJsonSerdeTest,RebalanceInfoJsonSerdeTest: per-bucket status, failurereason, unknown status codes (a bucket falls back to the task status; a history entry
fails to decode).
CoordinatorRebalanceTest: the response callback completes when the rebalance manager isclosed.
ServerConnectionTest:include_historyagainst a version 0 server.ClientRpcMessageUtilsTest: summary conversion, absent fields, unknown status.FutureUtilsTest:completeFromCallablewith anError.RebalanceITCase:listAllRebalanceson a live cluster, andinclude_historywithrebalance_idrejected.FlussAuthorizationITCase#testListAllRebalances:DESCRIBEon the cluster resource.FlinkProcedureITCase:sys.list_all_rebalances.RebalanceInfo::from_pb, version check forinclude_history.API and Format
RebalanceInfoclass andAdmin#listAllRebalances().listRebalanceProgress(id)now throws for an id when no rebalance has run (see above).LIST_REBALANCE_PROGRESSversion 1 withinclude_historyandrebalance_infos.Version 0 requests behave as before.
/cluster/rebalance_history. The rebalance task znode gainsoptional
bucket_statusandfailure_reasonfields within format version 3; oldercoordinators ignore them.
Documentation
website/docs/engine-flink/procedures.md(list_all_rebalances, updatedlist_rebalance)and
website/docs/maintenance/operations/rebalance.md.🤖 Generated with Claude Code