Skip to content

feat: report query session closure reasons - #873

Open
KirillKurdyukov wants to merge 1 commit into
mainfrom
YDBAPPTEAM-1649
Open

feat: report query session closure reasons#873
KirillKurdyukov wants to merge 1 commit into
mainfrom
YDBAPPTEAM-1649

Conversation

@KirillKurdyukov

Copy link
Copy Markdown
Contributor

No description provided.

@KirillKurdyukov
KirillKurdyukov force-pushed the YDBAPPTEAM-1649 branch 2 times, most recently from 4990d65 to 9fb70cc Compare August 11, 2026 13:19
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.30435% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.41%. Comparing base (c1cdcba) to head (75db727).

Files with missing lines Patch % Lines
ydb/aio/query/session.py 41.66% 6 Missing and 1 partial ⚠️
ydb/query/session.py 97.95% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #873      +/-   ##
==========================================
+ Coverage   82.33%   82.41%   +0.07%     
==========================================
  Files          99       99              
  Lines       12750    12810      +60     
  Branches     1242     1254      +12     
==========================================
+ Hits        10498    10557      +59     
+ Misses       1798     1797       -1     
- Partials      454      456       +2     
Flag Coverage Δ
integration 80.29% <91.30%> (+0.05%) ⬆️
unit 48.32% <20.65%> (-0.08%) ⬇️

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

Files with missing lines Coverage Δ
ydb/aio/query/base.py 100.00% <100.00%> (+3.12%) ⬆️
ydb/aio/query/pool.py 94.66% <100.00%> (+0.03%) ⬆️
ydb/observability/metrics.py 97.56% <100.00%> (+0.03%) ⬆️
ydb/opentelemetry/metrics_plugin.py 95.55% <ø> (ø)
ydb/query/base.py 95.23% <100.00%> (+0.18%) ⬆️
ydb/query/pool.py 92.50% <100.00%> (+0.04%) ⬆️
ydb/query/session.py 92.51% <97.95%> (+0.67%) ⬆️
ydb/aio/query/session.py 83.90% <41.66%> (-4.85%) ⬇️

... and 2 files with indirect coverage changes

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

@robot-vibe-db robot-vibe-db Bot 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.

AI Review Summary

Verdict: ✅ No critical issues found

Critical issues

No critical issues found.

Other findings

  • Major | Medium: _on_execute_stream_error now closes sessions on Unavailable and SessionExpired, changing prior non-terminal behavior — ydb/query/session.py:222-237
  • Minor | Medium: count_open() lacks the lock that count_closed() uses, creating asymmetric thread-safety on the shared _counted flag — ydb/observability/metrics.py:459
  • Minor | Low: Normal attach-stream termination now closes the session (reason="attach_closed"), whereas before it only logged and left the session open — ydb/query/session.py:439
  • Nit | Medium: pool.stop() calls _session_metrics.count_closed() directly instead of going through _close_session(), briefly decoupling the metric state from the session state — ydb/query/pool.py:329

This review was generated automatically. Critical issues require attention; other findings are advisory.
If this comment was useful, please give it a 👍 — it helps us improve the review bot.

Comment thread ydb/query/session.py
self._lock = threading.Lock()

def count_open(self) -> None:
if self._counted:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: Minor
Confidence: Medium

count_open() reads and writes _counted without acquiring self._lock, while count_closed() does hold the lock. This creates asymmetric thread-safety on the shared flag.

In the current call ordering this is safe — count_open() runs inside _attach() before the background thread that could call count_closed() is started. However, if the calling pattern ever changes (e.g., a reconnect path that re-opens a session while the old status loop is still draining), the unprotected write in count_open() could race with count_closed().

Consider acquiring self._lock in count_open() as well, for consistency and future-proofing.

Comment thread ydb/query/session.py
Comment thread ydb/query/pool.py
@robot-vibe-db

robot-vibe-db Bot commented Aug 12, 2026

Copy link
Copy Markdown

Full analysis log

Analysis performed by claude, claude-opus-4-6.

@KirillKurdyukov
KirillKurdyukov force-pushed the YDBAPPTEAM-1649 branch 2 times, most recently from 420e16b to 75db727 Compare August 24, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant