← Back to Pull requests

fix: sys.segments is_published is 1 for unused segments that a Historical still serves #20936

Closed
unknown closed this pull request without merging on Nov 20, 2026 05:25 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 05:01 UTC
Author

Description

Follow-up to #20930, see https://github.com/apache/druid/pull/20930#discussion_r4622840115.

With druid.centralizedDatasourceSchema.enabled set on the Coordinator, sys.segments reports is_published = 1 and is_active = 1 for 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 shows is_published = 0 and is_active = 0.

Root cause

With centralized schema, the Coordinator's segments endpoint appends every segment in CoordinatorSegmentMetadataCache that is not among the used segments. That cache holds every served segment, so the appended set is:

  • realtime segments, and

  • segments that are no longer used but that a Historical still serves.
  • The response only has a realtime flag, which is set for the first kind. The Broker computed is_published as !realtime, so it could not tell the second kind from a published segment.

    Fix

  • SegmentStatusInCluster gets a published field.

  • MetadataResource sets it to true for used segments and false for the appended ones.

  • SystemSchema uses it for is_published. MetadataSegmentView carries 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 SystemSchema as #20930. I will rebase whichever is merged second.

    Release note

    sys.segments.is_published and is_active are now 0 for a segment that is no longer used but is still served by a Historical, when druid.centralizedDatasourceSchema.enabled is set. The Coordinator API /druid/coordinator/v1/metadata/segments?includeOvershadowedStatus returns a new published field 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 checks published on 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
    SegmentStatusInCluster
    MetadataResource
    * SystemSchema

    This PR has:

  • been self-reviewed.

  • added documentation for new or modified features or behaviors.

  • a release note entry in the PR description.

  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.

  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • 🤖 Generated with Claude Code

    Diff: 366 lines (+274 / -92) across 4 files Reviewer: gianm Review duration: 1463m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.5% · Safe to merge
    18.5%
    Repository