fix: sys.segments is_published is 1 for unused segments that a Historical still serves #20936
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 366 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.353
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #20936"
general
weight: 0.35
gianm
Description
Follow-up to #20930, see https://github.com/apache/druid/pull/20930#discussion_r4622840115.
With
druid.centralizedDatasourceSchema.enabledset on the Coordinator,sys.segmentsreportsis_published = 1andis_active = 1for a segment that is not published: one that is no longer used but that a Historical has not dropped yet. Without centralized schema the same segment correctly showsis_published = 0andis_active = 0.Root cause
With centralized schema, the Coordinator's segments endpoint appends every segment in
CoordinatorSegmentMetadataCachethat is not among the used segments. That cache holds every served segment, so the appended set is:The response only has a
realtimeflag, which is set for the first kind. The Broker computedis_publishedas!realtime, so it could not tell the second kind from a published segment.Fix
SegmentStatusInClustergets apublishedfield.MetadataResourcesets it totruefor used segments andfalsefor the appended ones.SystemSchemauses it foris_published.MetadataSegmentViewcarries it through its cache.When the field is absent, as in a response from a Coordinator on an older version, it defaults to
!realtime. So a new Broker with an old Coordinator behaves as it did before.This touches the same few lines of
SystemSchemaas #20930. I will rebase whichever is merged second.Release note
sys.segments.is_publishedandis_activeare now 0 for a segment that is no longer used but is still served by a Historical, whendruid.centralizedDatasourceSchema.enabledis set. The Coordinator API/druid/coordinator/v1/metadata/segments?includeOvershadowedStatusreturns a newpublishedfield for each segment.Testing
SystemSchemaTest.testSegmentsTableWithUnpublishedSegmentsFromCoordinator: the three kinds of segments the Coordinator can return.MetadataResourceTest.testGetAllSegmentsIncludingRealtime: now includes a segment that is served by a Historical and not used, and checkspublishedon every returned segment.SegmentStatusInClusterTest: round trip of the new field, and the default when it is absent.I have not run this on a cluster with centralized schema enabled.
##### Key changed/added classes in this PR
SegmentStatusInClusterMetadataResource*
SystemSchemaThis PR has:
🤖 Generated with Claude Code