Skip to content

Fix repeated asyncio driver stop after discovery cancellation - #953

Merged
vgvoleg merged 2 commits into
mainfrom
fix/async-driver-repeat-stop
Dec 4, 2026
Merged

vgvoleg merged 2 commits into
mainfrom
fix/async-driver-repeat-stop

Conversation

@vgvoleg

@vgvoleg vgvoleg commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

When shutdown times out waiting for endpoint discovery, the asyncio driver cancels the discovery task. A repeated or concurrent stop() can then await the cancelled task and raise CancelledError.

Serialize shutdown at the driver boundary so concurrent callers wait for cleanup to finish. Once the driver has stopped, subsequent calls return immediately.

@codecov

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.85%. Comparing base (1d1c308) to head (1e1d2e1).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #953      +/-   ##
==========================================
+ Coverage   84.81%   84.85%   +0.04%     
==========================================
  Files         102      102              
  Lines       14262    14267       +5     
  Branches     1508     1509       +1     
==========================================
+ Hits        12096    12106      +10     
+ Misses       1723     1717       -6     
- Partials      443      444       +1     
Flag Coverage Δ
integration 80.01% <100.00%> (+0.07%) ⬆️
unit 58.72% <75.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
ydb/aio/driver.py 94.11% <100.00%> (+1.01%) ⬆️

... and 3 files with indirect coverage changes

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

🟡 Changes recommended

Two critical active issues remain: the regression test patches the production call with an incompatible signature, and concurrent stop() calls can propagate CancelledError instead of completing idempotently.

2 open issues
What changed in this PR

Makes asynchronous driver shutdown idempotent after discovery cancellation.

Changes:

  • Adds an early return for already-stopped connection pools.
  • Adds regression coverage for repeated shutdown.
  • Documents the fix in the changelog.
File Description
ydb/​aio/​pool.py Adds a guard to prevent repeated shutdown from awaiting a cancelled discovery task.
tests/​aio/​test_connection_pool.py Adds regression coverage for stopping the driver twice after discovery cancellation.
CHANGELOG.md Documents the asynchronous shutdown fix.

Review effort: Lite

Comment thread tests/aio/test_connection_pool.py Resolved
Comment thread ydb/aio/pool.py Resolved

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

The review records no active issues for the shutdown-concurrency fix and its associated regression coverage.

No open issues 🎉

2 resolved since last review

Review effort: Lite

@vgvoleg
vgvoleg merged commit a7d0fe3 into main Dec 4, 2026
35 checks passed
@vgvoleg
vgvoleg deleted the fix/async-driver-repeat-stop branch December 4, 2026 13:55
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.

2 participants