feat: report query session closure reasons - #873
Conversation
4990d65 to
9fb70cc
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
e32aad2 to
69e256f
Compare
There was a problem hiding this comment.
AI Review Summary
Verdict: ✅ No critical issues found
Critical issues
No critical issues found.
Other findings
- Major | Medium:
_on_execute_stream_errornow closes sessions onUnavailableandSessionExpired, changing prior non-terminal behavior —ydb/query/session.py:222-237 - Minor | Medium:
count_open()lacks the lock thatcount_closed()uses, creating asymmetric thread-safety on the shared_countedflag —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.
| self._lock = threading.Lock() | ||
|
|
||
| def count_open(self) -> None: | ||
| if self._counted: |
There was a problem hiding this comment.
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.
|
Analysis performed by claude, claude-opus-4-6. |
ca9a3b0 to
69e256f
Compare
420e16b to
75db727
Compare
No description provided.