[fix](cloud) Exclude abandoned schema change shadow tablets from compaction score - #67401
Open
Yukang-Lian wants to merge 1 commit into
Open
[fix](cloud) Exclude abandoned schema change shadow tablets from compaction score#67401Yukang-Lian wants to merge 1 commit into
Yukang-Lian wants to merge 1 commit into
Conversation
…action score A heavyweight schema change leaves NOT_READY shadow tablets in the BE tablet cache. When the job is cancelled (or removed), those tablets can never be converted or compacted, but they linger in the cache until the recycler permanently deletes their meta, because meta-service keeps returning their tablet meta before that. Meanwhile the compaction scheduler records the max compaction score before filtering, so such an abandoned tablet keeps feeding tablet_cumulative_max_compaction_score with a large constant value, while /api/compaction_score only enumerates TABLET_RUNNING tablets and never shows it. The metric then reports a false backlog for days until the BE restarts. Fix: - MS reports whether a tablet still has an active schema change job via the existing get_rowset RPC (one extra point read of the tablet job KV, only when BE sets need_alter_job_info for its NOT_READY tablets). The job KV is written on job start and cleared synchronously on commit/abort, so it is an authoritative and timely liveness signal, independent of delayed recycling. - BE refreshes CloudTablet::has_active_alter_job on each rowset sync. A NOT_READY tablet without an active alter job (a zombie tablet) is excluded from the max compaction score stats, from compaction candidates, and from /api/compaction_score, so the metric and the HTTP endpoint now describe the same set of tablets: RUNNING plus in-progress schema change new tablets. - /api/compaction_score entries now carry tablet_state and not_scheduled_reason (evaluated only for the returned top-n entries), and /api/compaction/show reports the full schedulability breakdown including is_zombie, so a high score that nobody compacts explains itself.
Yukang-Lian
requested review from
gavinchou,
liaoxin01 and
luwei16
as code owners
September 1, 2026 13:43
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
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.
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
In cloud mode, a heavyweight schema change leaves NOT_READY shadow tablets in the BE tablet cache. When the job is cancelled (or removed), those tablets can never be converted or compacted, but they linger in the cache until the recycler permanently deletes their meta, because meta-service keeps returning their tablet meta before that.
Meanwhile the compaction scheduler records the max compaction score before filtering, so such an abandoned tablet keeps feeding
tablet_cumulative_max_compaction_scorewith a large constant value, while/api/compaction_scoreonly enumerates TABLET_RUNNING tablets and never shows it. The metric then reports a false backlog (observed: a flat 551 across many BEs for days in production) until the BE restarts, and the metric and the HTTP endpoint contradict each other, which makes the alarm impossible to diagnose.Fix:
get_rowsetRPC: one extra point read of the tablet job KV, only when BE sets the newneed_alter_job_inforequest field for its NOT_READY tablets. The job KV is written on job start and cleared synchronously on commit/abort, so it is an authoritative and timely liveness signal, independent of delayed recycling.CloudTablet::has_active_alter_jobon each rowset sync. A NOT_READY tablet without an active alter job (a zombie tablet) is excluded from the max compaction score stats, from compaction candidates, and from/api/compaction_score, so the metric and the HTTP endpoint now describe the same set of tablets: RUNNING plus in-progress schema change new tablets. In-progress new tablets stay visible in both (they do get compacted viaenable_new_tablet_do_compaction)./api/compaction_scoreentries now carrytablet_stateandnot_scheduled_reason(evaluated only for the returned top-n entries, so the cost is bounded bytop_n), and/api/compaction/showreports the full schedulability breakdown includingis_zombie, so a high score that nobody compacts explains itself. The scheduler log line also reportsnum_zombie.Rolling upgrade is safe in both directions: an old MS simply leaves the response field unset and BE keeps today's behavior (the tablet is treated as alter-in-progress).
Manual test on a single-node cloud cluster (schema change conversion blocked via debug point, 60 double-written load txns, then CANCEL ALTER, recycler not running):
NOTREADY, consistent for the first time.num_zombie=2, and/api/compaction/showreportsis zombie tablet: true / not scheduled reason: zombie. Before this fix the gauge stayed pinned until BE restart.Release note
None
Check List (For Author)
Test
Behavior changed:
/api/compaction_score;/api/compaction_scorenow also lists in-progress schema change new tablets with atablet_statefield and anot_scheduled_reasonfield.Does this need documentation?
Check List (For Reviewer who merge this PR)