Skip to content

Fix async session pool slot leak on keep-alive failure - #934

Merged
vgvoleg merged 5 commits into
ydb-platform:mainfrom
eblackbu:fix-aio-session-pool-keep-alive-leak
Nov 2, 2026
Merged

vgvoleg merged 5 commits into
ydb-platform:mainfrom
eblackbu:fix-aio-session-pool-keep-alive-leak

Conversation

@eblackbu

@eblackbu eblackbu commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

When KeepAlive fails for an idle session, SessionPool._send_keep_alive() exits before its cleanup handler, leaving the pool slot occupied. Move the KeepAlive await inside the existing cleanup block so the session is destroyed and its slot is released.

Three pytest regression cases cover BadSession, ConnectionLost, and CancelledError. They verify session deletion, released pool capacity, and acquisition of a replacement session

Validation:

  • All three regression cases fail without the fix and pass with it.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.69%. Comparing base (6fb4593) to head (d9665d5).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #934      +/-   ##
==========================================
+ Coverage   82.64%   82.69%   +0.04%     
==========================================
  Files          99       99              
  Lines       12950    12950              
  Branches     1266     1266              
==========================================
+ Hits        10703    10709       +6     
+ Misses       1796     1789       -7     
- Partials      451      452       +1     
Flag Coverage Δ
integration 80.38% <100.00%> (+0.01%) ⬆️
unit 49.25% <0.00%> (ø)

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

Files with missing lines Coverage Δ
ydb/aio/table.py 81.86% <100.00%> (+1.33%) ⬆️

... and 1 file 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.

🟢 Approval recommended

No active review issues remain, and the change includes targeted regression coverage for failed or cancelled keep-alive operations and pool-slot reuse.

No open issues 🎉

What changed in this PR

Fixes an async SessionPool slot leak when an idle session’s keep-alive operation fails or is cancelled. Failed sessions are now cleaned up so their pool capacity can be reused.

Changes:

  • Move the keep-alive operation into the existing cleanup path.
  • Add regression coverage for BadSession, ConnectionLost, and CancelledError.
  • Document the fix in the changelog.
File Description
ydb/​aio/​table.py Cleans up sessions after failed or cancelled keep-alive operations and releases pool capacity.
tests/​aio/​test_session_pool.py Adds regression tests verifying session deletion, slot release, and replacement-session acquisition.
CHANGELOG.md Documents the async session-pool capacity leak fix.

Review effort: Lite

@eblackbu
eblackbu marked this pull request as ready for review November 2, 2026 09:34
@vgvoleg
vgvoleg merged commit 9a92165 into ydb-platform:main Nov 2, 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.

3 participants