Skip to content

fix: bug: topic reader close method freezes indefinitely - #920

Merged
vgvoleg merged 3 commits into
ydb-platform:mainfrom
Roshan931:prilog/fix-error-topic-reader-close-flush-true-waits-10-10-2026-abecf8
Nov 5, 2026
Merged

vgvoleg merged 3 commits into
ydb-platform:mainfrom
Roshan931:prilog/fix-error-topic-reader-close-flush-true-waits-10-10-2026-abecf8

Conversation

@Roshan931

Copy link
Copy Markdown
Contributor

Fixes #679

Root cause

Topic reader close(flush=True) waits forever for commit acks on an already-broken stream

Changes

  • ReaderStream.flush() now stops waiting for commit acks as soon as the stream's first error is set, instead of awaiting ack futures that can never be resolved; close(flush=True) then proceeds to tear down the stream and fail pending waiters with PublicTopicReaderPartitionExpiredError. Added two regression tests.

Signed-off-by: Robert Markovski <5818108+Roshan931@users.noreply.github.com>
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.67%. Comparing base (fb9bd3f) to head (6694ca7).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #920      +/-   ##
==========================================
- Coverage   82.68%   82.67%   -0.02%     
==========================================
  Files          99       99              
  Lines       12950    12954       +4     
  Branches     1266     1266              
==========================================
+ Hits        10708    10710       +2     
- Misses       1790     1791       +1     
- Partials      452      453       +1     
Flag Coverage Δ
integration 80.39% <100.00%> (-0.01%) ⬇️
unit 49.27% <66.66%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ydb/_topic_reader/topic_reader_asyncio.py 86.65% <100.00%> (-0.24%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the asynchronous topic-reader close-hang fix and its supporting regression coverage.

No open issues 🎉

What changed in this PR

This pull request fixes an indefinite hang when closing an asynchronous topic reader with pending commit acknowledgements on a broken stream.

Changes:

  • Stop waiting for commit acknowledgements after the stream’s first error.
  • Add regression coverage for broken-stream flushing and close behavior.
  • Document the fix in the changelog.

This pull request requires changes.

File Summary Review notes
ydb/​_topic_reader/​topic_reader_asyncio.py Stops pending flush operations when the stream encounters its first error. —
ydb/​_topic_reader/​topic_reader_asyncio_test.py Adds regression coverage for broken-stream flush and close behavior. The regression test does not verify that an in-flight flush is released by a later stream error. Start flush() as a task, yield until it is waiting, then call _set_first_error() and await the task.
CHANGELOG.md Documents the topic reader close hang fix. —

Review effort: Lite

@vgvoleg
vgvoleg merged commit 2f73810 into ydb-platform:main Nov 5, 2026
34 checks passed
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.

bug: topic reader close method freezes indefinitely

3 participants