Skip to content

feat: segment availability improvements - #19889

Open
jtuglu1 wants to merge 1 commit into
apache:masterfrom
jtuglu1:fix-segment-move-replica-accounting-18764
Open

jtuglu1 wants to merge 1 commit into
apache:masterfrom
jtuglu1:fix-segment-move-replica-accounting-18764

Conversation

@jtuglu1

@jtuglu1 jtuglu1 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #18764.

Description

During move of a 1x-replicated segment from historical A to historical B, the coordinator can currently race and drop a segment temporarily from the timeline.

This occurs through 2 primary ways:

  1. The SegmentLoadQueueManager.moveSegment operation calls unmarkSegmentToDrop and then dropSegment which can race with readers.
  2. The coordinator currently receives information about what segments are loaded where through an inventory view (ServerInventoryView) and historical node callbacks (HttpLoadQueuePeon). Since these historical callbacks typically always arrive first, the code sums up load data from both sources and then does a diff. While this works if the HttpLoadQueuePeon is present in the queue (to cancel out the new pending load on historical B), before this fix, the peon deletes the holder the moment the server acks. So the DROP left the queue while the inventory still showed the segment loaded.

Changes

  1. Ensure we do the mark to drop transition atomically (SegmentMoveConcurrencyTest::testMarkToDropGraduatesToQueuedDrop).
  2. Make sure we hang on to callbacks until inventory catches up.

Release note


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • 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.
  • added integration tests.
  • been tested in a test Druid cluster.

@jtuglu1
jtuglu1 force-pushed the fix-segment-move-replica-accounting-18764 branch 3 times, most recently from 9877c77 to 7d16389 Compare August 6, 2026 03:10
@jtuglu1
jtuglu1 marked this pull request as ready for review August 6, 2026 15:18
@jtuglu1
jtuglu1 force-pushed the fix-segment-move-replica-accounting-18764 branch from 7d16389 to dae9817 Compare August 6, 2026 15:53
@jtuglu1 jtuglu1 added this to the 39.0.0 milestone Aug 6, 2026
@jtuglu1
jtuglu1 force-pushed the fix-segment-move-replica-accounting-18764 branch from dae9817 to effefb7 Compare August 6, 2026 18:56
@jtuglu1
jtuglu1 force-pushed the fix-segment-move-replica-accounting-18764 branch from effefb7 to 3e1dca0 Compare August 6, 2026 21:46

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

Reviewed 14 of 14 changed files. Found one P2 move-accounting race that can trigger duplicate loads during inventory lag.


This is an automated review by Codex GPT-5.6-Luna(max)

} else {
// Retain until the inventory view catches up, so the operation is never invisible in both.
holder.markAcknowledgedByServer();
segmentsAwaitingConfirmation.put(holder.getSegment().getId(), holder);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Delay MOVE_TO callbacks until inventory confirmation

The holder is retained, but the following onRequestCompleted still dispatches its callback immediately. For a MOVE_TO, this removes the source MOVE_FROM mark and queues the source DROP before the target appears in inventory. If that DROP is also acknowledged while the source inventory still shows the segment, the next coordinator run sees DROP on the source and MOVE_TO on the target; replica accounting treats neither as a projected loaded replica, so a third eligible historical can receive an unnecessary duplicate load. Defer the move callback until target confirmation, or account for this acknowledged move pair explicitly.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

This pull request has been marked as stale due to 60 days of inactivity.
It will be closed in 4 weeks if no further activity occurs. If you think
that's incorrect or this pull request should instead be reviewed, please simply
write any comment. Even if closed, you can still revive the PR at any time or
discuss it on the dev@druid.apache.org list.
Thank you for your contributions.

@github-actions github-actions Bot added the stale label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segment Rebalance Race

2 participants