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 86.97248% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.63%. Comparing base (53b1b16) to head (ca9a3b0).

Files with missing lines Patch % Lines
ydb/_topic_writer/topic_writer_asyncio.py 83.73% 24 Missing and 17 partials ⚠️
ydb/_topic_reader/topic_reader_asyncio.py 85.18% 4 Missing and 4 partials ⚠️
ydb/aio/query/session.py 41.66% 6 Missing and 1 partial ⚠️
ydb/_topic_writer/topic_writer.py 89.65% 3 Missing and 3 partials ⚠️
ydb/_topic_writer/topic_writer_sync.py 86.48% 3 Missing and 2 partials ⚠️
ydb/observability/tracing.py 90.62% 1 Missing and 2 partials ⚠️
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.63%   +0.29%     
==========================================
  Files          99      100       +1     
  Lines       12749    13180     +431     
  Branches     1242     1336      +94     
==========================================
+ Hits        10497    10891     +394     
- Misses       1797     1807      +10     
- Partials      455      482      +27     
Flag Coverage Δ
integration 79.08% <55.04%> (-1.13%) ⬇️
unit 49.90% <71.74%> (+1.52%) ⬆️

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

Files with missing lines Coverage Δ
ydb/_topic_common/metadata.py 100.00% <100.00%> (ø)
ydb/_topic_reader/datatypes.py 95.59% <100.00%> (+0.05%) ⬆️
ydb/_topic_reader/topic_reader_sync.py 79.74% <100.00%> (+7.59%) ⬆️
ydb/aio/query/base.py 100.00% <100.00%> (+3.12%) ⬆️
ydb/aio/query/pool.py 94.66% <100.00%> (+0.03%) ⬆️
ydb/observability/__init__.py 100.00% <ø> (ø)
ydb/observability/metrics.py 97.56% <100.00%> (+0.03%) ⬆️
ydb/opentelemetry/metrics_plugin.py 95.55% <ø> (ø)
ydb/opentelemetry/plugin.py 100.00% <100.00%> (ø)
ydb/opentelemetry/tracing.py 100.00% <ø> (ø)
... and 9 more

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

@KirillKurdyukov
KirillKurdyukov force-pushed the YDBAPPTEAM-1649 branch 2 times, most recently from c39447e to e32aad2 Compare August 12, 2026 12:28

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

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