Repository navigation
Conversation
5b2283c to
64191c5
Compare
8569c10 to
014a5ac
Compare
|
Scope note for reviewers: per-bucket detail for historical rebalances This PR keeps But It is easier to enable this API: Keeping it out of this PR keeps the review surface small and leaves one design point open for discussion:
The follow-up also changes one contract: |
014a5ac to
8757b6a
Compare
affo
left a comment
There was a problem hiding this comment.
Thanks, this is a well-structured change — the bottom-up layering is clean, the failover restore paths and the final-status-before-history ordering are handled carefully, and the test coverage matches the claims in the description. I went through it layer by layer and found no blocking issues.
One design suggestion (splitting the SQL procedure instead of overloading it) and a handful of smaller points inline. The procedure split is the only one I'd push on before merge, since it also removes the two-RPC staleness window flagged in the description.
|
addressed: procedure split applied (sys.list_rebalances added, staleness window gone) and all inline comments addressed in the linked commit |
affo
left a comment
There was a problem hiding this comment.
Thanks for addressing! Now looks good to me!
3bb4ad6 to
0a14c88
Compare
0a14c88 to
2aca48b
Compare
c453793 to
1403167
Compare
1403167 to
9236017
Compare
| } | ||
|
|
||
| message ListRebalancesResponse { | ||
| repeated PbRebalanceInfo rebalance_infos = 1; |
There was a problem hiding this comment.
I have a few related questions about the API and history storage design:
-
Could we extend the existing RPC? For example, add an optional
include_historyfield toListRebalanceProgressRequestand arepeated PbRebalanceInfofield to its response, while retaining the existing fields and the current single-rebalance behavior when the flag is absent. A separate Admin method and SQL procedure could still use the same RPC underneath. This seems worth considering before introducing another RPC. We would also need to define the interaction withrebalance_idand handle older servers explicitly, so an unsupported history request cannot silently return an incomplete result. -
What should
PbRebalanceInforepresent? Should it be a summary, or also contain table/bucket details throughrepeated PbRebalanceProgressForTable(which includes the plan)? I would avoid returning every historical plan by default. If this is intended to summarize outcomes, could we include an optional, conciseerror_messageorfailure_reason? A status such asFAILEDalone does not explain what went wrong. The reason would need to be captured and persisted when the failure occurs to remain useful after coordinator failover. Full plan details could remain available through the by-ID query, depending on the retention decision below. -
Can we align the history storage with [server] Store rebalance tasks in remote storage #5133? That PR moves rebalance tasks into remote storage to address large serialized plans exceeding ZooKeeper's znode size limit. Here, each
/cluster/rebalance_history/<rebalanceId>still stores a completeRebalanceTask. Keeping only 10 entries bounds the count, but does not bound an individual entry's size; even the summary listing currently reads and decodes those complete tasks. Do we need to retain the full plan for historical rebalances, or would summary metadata and diagnostic information be sufficient? If historical plan lookup is required, could history retain metadata plus a remote reference, aligned with [server] Store rebalance tasks in remote storage #5133, with cleanup preserving files referenced by retained history? If we choose summary-only retention instead, we should explicitly adjust the historical detail-query contract. -
Could we name the new SQL procedure
sys.list_all_rebalances()? Its multi-row summary schema and use case differ substantially fromsys.list_rebalance([id]), which returns one rebalance's detailed progress and plan. The more explicit name would make that distinction clearer than the singular/plural difference alone. The documentation should clarify that "all" means the current rebalance plus retained history, rather than an unbounded audit history.
There was a problem hiding this comment.
Thanks @wuchong, I am going to follow-up on your suggestions and findings and address them soon🤞
|
Btw, is it really necessary to display the results of the last 10 rebalances? Based on our operational experience, showing only the most recent result should be sufficient. What do you think @swuferhong ? |
Rebalance tasks now carry started/completed timestamps (RebalanceTask JSON serde v2, backward compatible with v1 znodes). On completion or cancellation the coordinator writes the final task to a bounded ZooKeeper history at /cluster/rebalance_history/<rebalanceId>, keeping the last 10 entries. The trim orders entries by creation and does not decode them, so an undecodable entry ages out like any other. A failed trim is logged and retried on the next write. The history entry and the current task are written as two separate requests, history first, so each request carries the plan once. Both writes, and the write that starts a rebalance, fail if the coordinator epoch changed, so a coordinator that lost leadership cannot overwrite them. On startup the coordinator copies a finished task that only the current znode holds (written before the history existed) into the history. Cancel marks every unfinished bucket CANCELED, including the in-flight one, which the coordinator stops tracking. Cancel without a current rebalance no longer touches the znode: it is a no-op without an id and throws NoRebalanceInProgressException with one. The new Admin#listRebalances() API returns a summary (id, status, timestamps) of the current rebalance plus the retained history, newest first. listRebalanceProgress(id) also serves historical ids with full per-bucket detail and throws NoRebalanceInProgressException for an id that is neither current nor retained. RebalanceProgress exposes startedAtMs and completedAtMs (-1 when unset). In Flink, sys.list_rebalance gains started_at/completed_at columns and the new sys.list_rebalances procedure lists all known rebalances. Closes apache#3965.
Regenerate the vendored proto, add the ListRebalances API key and request, and expose Admin#list_rebalances returning RebalanceInfo (id, status, timestamps). RebalanceProgress now carries started_at_ms and completed_at_ms from the regenerated response.
9236017 to
8af0a09
Compare
I haven’t encountered this requirement either. I’d recommend using the existing List Rebalance Process API to implement this rather than introducing a new API. |
Admin#listRebalances() is renamed to Admin#listAllRebalances() and no longer has its own RPC. It sends ListRebalanceProgressRequest with the new include_history field, and the response carries the summaries in rebalance_infos. The LIST_REBALANCES API key is removed and LIST_REBALANCE_PROGRESS moves to version 1. An older server would ignore include_history and return only the current rebalance, so the client rejects the request with UnsupportedVersionException when the server negotiated version 0. The coordinator rejects include_history combined with rebalance_id. A rebalance summary carries an optional failure_reason: why the first failed bucket was given up on. The coordinator stores it with the final task, so it is available after a coordinator failover. A history entry at /cluster/rebalance_history/<rebalanceId> now stores the summary (id, status, timestamps, failure reason) instead of the complete task, so its size does not grow with the plan. The per-bucket plan and statuses are kept for the most recent rebalance only, in the current task znode. listRebalanceProgress(id) throws NoRebalanceInProgressException for any other id. In Flink, the summary procedure is renamed to sys.list_all_rebalances and gains a failure_reason column.
Regenerate the vendored proto and remove the ListRebalances API key and request. Admin#list_rebalances is renamed to Admin#list_all_rebalances. It sends ListRebalanceProgressRequest with include_history and fails with UnsupportedVersion when the server negotiated version 0. RebalanceInfo carries the optional failure_reason.
b7975cd to
f2872bf
Compare
|
Hello @wuchong, @swuferhong Thanks for your detailed and on point reviews, your suggestions made the design simpler. I pushed two follow-up commits. Single RPCI removed
|
Summary
Rebalance operations were observable only while in flight:
listRebalanceProgress(id)served the current rebalance, and nothing recorded when one started or finished. This PR
adds the history and the timestamps, then surfaces them through the SQL procedure.
Storage and the new listing API
RebalanceTaskcarriesstartedAtMs/completedAtMs(JSON serde v2; v1 znodes readback as
-1, meaning unset).history at
/cluster/rebalance_history/<rebalanceId>(last 10 kept). A failed historywrite is logged and never fails the transition;
corrupt entries are skipped, not(review update) corrupt entries are skipped on read and deleted at the nextfatal
retention trim.
Admin#listRebalances()(ApiKeys.LIST_REBALANCES) returns aRebalanceInfosummary - id, status, timestamps - for the current rebalance plus the retained history,
newest first. Per-bucket detail stays on
listRebalanceProgress(id).listRebalanceProgress(id)now also serves a historical rebalanceid from the ZooKeeper history, with full per-bucket detail and the task's final status.
An id that is neither current nor retained still throws
NoRebalanceInProgressException, with a message pointing atlistRebalances().Timestamps on the existing progress RPC
RebalanceProgressgainsstartedAtMs()/completedAtMs(), transported by two newoptional fields on
ListRebalanceProgressResponse(-1maps to absent).RebalanceProgressJsonSerializeremits both when set.SQL surface
sys.list_rebalancegainsstarted_at/completed_atTIMESTAMP_LTZ(3)columns.Called without a rebalance id it now returns one row per known rebalance (current plusretained history, newest first) instead of only the current one. Historical rows carry
null progress and plan detail.
sys.list_rebalancekeeps its original single-row semantics; a newsys.list_rebalancesprocedure lists summaries (id, status,started_at,completed_at) of all known rebalances in a single RPC, mirroring the Admin APIone-to-one.
engine-flink/procedures.md,maintenance/operations/rebalance.md.Closes #3965.
Notes for reviewers
Where the ZooKeeper read happens.
listRebalancesneeds both in-memory state andZooKeeper history.
CoordinatorEventProcessor#processListRebalancessnapshots the currentrebalance on the coordinator event thread, where it mutates, then reads the history on the
ioExecutorso the event loop never blocks on ZooKeeper.RebalanceManager#listRebalances(RebalanceInfo)takes that snapshot as a parameter andtouches nothing else, which is what makes it safe off the event thread.
The no-id procedure path issues two RPCs -listRebalanceProgress(null)for thecurrent entry's detail plus
listRebalances()for the summaries, stitched client-side -so a rebalance finishing between them can render one transiently stale row, corrected on
the next call. The alternative is carrying progress and plan detail for the current entry
inside
ListRebalancesResponse; that was left out to keep the new response summary-only.Happy to switch to the single-snapshot shape if you prefer it.
(resolved in review) The procedure split removed the two-RPC stitch entirely:
sys.list_rebalancesis backed by the singlelistRebalances()RPC, so the transientlystale row can no longer occur.
Three commits. The first adds the storage groundwork and the listing API, the second
the timestamp exposure and the SQL surface, the third addresses review comments (procedure
split, historical-id drill-down, corrupt-entry cleanup). Each compiles and passes its
tests on its own, so the PR is fine to rebase-merge or squash.
Test Plan
RebalanceTaskJsonSerdeTest(serde v2 round-trip, v1 document reads back as-1),ZooKeeperClientTest(history retention, idempotent re-register, corrupt-entryskipdeletion during the trim, sibling-znode isolation),RebalanceManagerTest(timestamp stamping, failover restore with and without timestamps, no re-completion of
an already-final restored task, newest-first ordering, empty history, historical-id
drill-down and unknown-id error),
CoordinatorEventProcessorTest(the responsecallback completes when the rebalance manager is closed),
ClientRpcMessageUtilsTest(
-1<-> absent mapping),RebalanceProgressJsonSerializerTest.RebalanceITCase(end-to-endlistRebalancesand progress timestamps on alive cluster),
FlussAuthorizationITCase#testListRebalances(DESCRIBEonResource.cluster(), deny and allow),FlinkProcedureITCase(both procedures,timestamp columns pinned to
Instantwith ordering).🤖 AI-assisted changes - reviewed by human developer