Skip to content

Fixing edge-case when ReadPartitionSession could stop reading - #706

Open
Myllyenko wants to merge 1 commit into
ydb-platform:masterfrom
Myllyenko:fix/read-partition-lost-wakeup
Open

Fixing edge-case when ReadPartitionSession could stop reading#706
Myllyenko wants to merge 1 commit into
ydb-platform:masterfrom
Myllyenko:fix/read-partition-lost-wakeup

Conversation

@Myllyenko

Copy link
Copy Markdown

ReadPartitionSession.sendDataToReadersIfNeeded takes the isReadingNow flag, peeks the queue and, when nothing is deliverable, releases the flag again. The existing re-check only covered the case of a batch that was already queued and became ready in the meantime; when the queue looked empty at peek() time the method returned without looking again.

That leaves a lost wakeup. While the flag is held, the gRPC thread can offer an already decoded (RAW) batch in addBatches and call sendDataToReadersIfNeeded, whose compareAndSet fails and is silently dropped. The batch is then never delivered, its read future never completes, the allOf in ReadSession.onReadResponse never fires and the session stops sending ReadRequests - the reader stalls forever.

Re-read the head of the queue after releasing the flag instead of re-testing the batch captured before it, and turn the retry into a loop so a burst of these hand-offs cannot nest recursively.

sendDataToReadersIfNeeded takes the isReadingNow flag, peeks the queue
and, when nothing is deliverable, releases the flag again. The existing
re-check only covered the case of a batch that was already queued and
became ready in the meantime; when the queue looked empty at peek() time
the method returned without looking again.

That leaves a lost wakeup. While the flag is held, the grpc thread can
offer an already decoded (RAW) batch in addBatches and call
sendDataToReadersIfNeeded, whose compareAndSet fails and is silently
dropped. The batch is then never delivered, its read future never
completes, the allOf in ReadSession.onReadResponse never fires and the
session stops sending ReadRequests - the reader stalls forever.

Re-read the head of the queue after releasing the flag instead of
re-testing the batch captured before it, and turn the retry into a loop
so a burst of these hand-offs cannot nest recursively.
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.44%. Comparing base (d876581) to head (b97b823).
⚠️ Report is 44 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #706      +/-   ##
============================================
+ Coverage     71.91%   72.44%   +0.53%     
- Complexity     3474     3522      +48     
============================================
  Files           390      391       +1     
  Lines         16220    16340     +120     
  Branches       1698     1701       +3     
============================================
+ Hits          11664    11837     +173     
+ Misses         3904     3865      -39     
+ Partials        652      638      -14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant