fix: sys.segments is_realtime is 0 for published segments served only by realtime tasks #20930
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 421 lines diff across 5 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.362
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #20930"
general
weight: 0.35
gianm
Description
sys.segments.is_realtimeis documented as:It did not do that for published segments. A segment that was published but not handed off yet, and so was served only by its realtime task, showed
is_realtime = 0.This replaces #20926, which worked around the wrong value in a test. See https://github.com/apache/druid/pull/20926#discussion_r4619696682.
Root cause
For segments returned by the Coordinator,
SystemSchemacopiedis_realtimefromSegmentStatusInCluster.MetadataResourcesets that flag tofalsefor every published segment. The Coordinator only uses it to mark the unpublished realtime segments it adds when centralized datasource schema is enabled.Fix
The Broker already tracks which servers serve each segment.
AvailableSegmentMetadata.isRealtime()is 0 as soon as any Historical serves the segment and 1 while only realtime servers do.SystemSchemanow uses that value for a published segment that the Broker sees being served, and falls back to the Coordinator's value otherwise.is_published,is_availableandis_activeare unchanged.Flaky stream test
This also fixes the flaky row count in
KafkaIndexFaultToleranceTest.test_supervisorRecovers_afterCoordinatorRestartthat #20926 was about:The test's supervisor has a 5 second completion timeout. When the Coordinator restart takes longer than that, the supervisor kills a publishing task that is still waiting for handoff. The task's segments are published, but no server serves them until a Historical loads them, and a count that runs in that window is short. The timeline from a failed run is in #20926.
EmbeddedClusterApis.waitForAllSegmentsToBeHandedOff. It pollssys.segmentsuntil the number of segments withis_available = 1 AND is_realtime = 0reaches the number of used segments.StreamIndexTestBase.verifyRowCountcalls it in place ofwaitForAllSegmentsToBeAvailable, which sums the Broker's schema refresh count since startup and so can pass before handoff.The completion timeout in the test is unchanged.
Release note
sys.segments.is_realtimeis now 1 for a segment that has been published but is still served only by realtime tasks. Before, it was 0 for every published segment.Testing
SystemSchemaTest.testSegmentsTableIsRealtimeForPublishedSegmentscovers published segments served by a Historical only, by a Historical and a realtime server, by a realtime server only, and by no server. It fails without the fix.verifyRowCountpass locally (19 tests). The failure is rare, so this shows that the wait works, not that the flake is gone.##### Key changed/added classes in this PR
SystemSchemaEmbeddedClusterApis*
StreamIndexTestBaseThis PR has:
🤖 Generated with Claude Code