← Back to Pull requests

fix: Prevent a single unhealthy historical from stalling all segment loading and balancing. #19950

Closed
unknown closed this pull request without merging on Aug 25, 2026 16:34 UTC
View on GitHub
unknown unknown commented on Aug 10, 2026 18:01 UTC
Author

Description

HttpLoadQueuePeon fetches a historical's segment-loading capabilities
synchronously in its constructor, via GET /druid-internal/v1/segments/loadCapabilities.
On any response other than 200 or 404 (e.g. a 503 from an overloaded or
briefly-unavailable historical), the constructor threw an RE.

Peon construction happens inside LoadQueueTaskMaster.resetPeonsForNewServers(),
which is the first line of PrepareBalancerAndLoadQueues — the first duty in the
HistoricalManagementDuties group. The top-level
DruidCoordinator.DutiesRunnable.run() catch logged
"Caught exception, ignoring so that schedule keeps going." and the coordinator
kept ticking — but performed no segment management on any server.

The blast radius is cluster-wide from a single sick server: segment loading and
balancing stop, handoffs stall, and ingestion tasks back up waiting for handoff.
Because computeIfAbsent does not cache on exception, the coordinator re-attempts
the bad server every run and fails again the same way.

Observed in production as slow handoffs and ingestion tasks taking 2x+ longer,
correlated with the alert above whose stack trace pointed at
HttpLoadQueuePeon → resetPeonsForNewServers → PrepareBalancerAndLoadQueues.run.
Once the problematic historical was restarted, segment management duties
resumed normally and ingestion wasn't stalled anymore.

### Fix

Make the capabilities fetch degrade gracefully instead of throwing. On a non-OK
response or any error, alert and fall back to default SegmentLoadingCapabilities
(derived from the configured batch size) — mirroring the behavior the 404 branch
already had. The peon is still created, the server is still managed with
conservative defaults, and the rest of the duty group proceeds. Operators still
get one alert per affected server.

### Changes

- HttpLoadQueuePeon.fetchSegmentLoadingCapabilities(): the non-OK-status branch
and the catch-all now alert and return default capabilities instead of throwing.
Extracted a getDefaultLoadingCapabilities() helper shared by all three fallback
paths (404, non-OK, error).

### Tests

- HttpLoadQueuePeonTest: constructing a peon against a server that returns 503 on
loadCapabilities now succeeds and falls back to default capabilities.
- DruidCoordinatorTest#testUnhealthyHistoricalDoesNotAbortDutyGroup: end-to-end
test with a real DruidCoordinator + LoadQueueTaskMaster where one of three
historicals 503s; asserts the HistoricalManagementDuties group still completes
a run and the two healthy historicals are still managed.

<!-- Replace XXXX with the id of the issue fixed in this PR. Remove this section if there is no corresponding issue. Don't reference the issue in the title of this pull-request. -->

<!-- If you are a committer, follow the PR action item checklist for committers:
https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. -->

This PR has:

  • been self-reviewed.

  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.

  • 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.

  • been tested in a test Druid cluster.
  • Diff: 456 lines (+342 / -114) across 5 files Reviewer: abhishekrb19 Review duration: 21513m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 456 lines diff across 5 files
    0.46
    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%
    60%
    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.366
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #19950"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 45.5% (MEDIUM) · Higher = larger blast radius
    45.5%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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.0% · Safe to merge
    18.0%
    Repository