Skip to content

feat: supported attach hint#833

Merged
vgvoleg merged 9 commits into
mainfrom
feat-attach-stream
Jul 8, 2026
Merged

feat: supported attach hint#833
vgvoleg merged 9 commits into
mainfrom
feat-attach-stream

Conversation

@KirillKurdyukov

Copy link
Copy Markdown
Contributor

No description provided.

@codecov-commenter

codecov-commenter commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.32%. Comparing base (dc20074) to head (71b827d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #833      +/-   ##
==========================================
+ Coverage   81.30%   81.32%   +0.02%     
==========================================
  Files          94       94              
  Lines       12162    12189      +27     
  Branches     1194     1202       +8     
==========================================
+ Hits         9888     9913      +25     
- Misses       1809     1810       +1     
- Partials      465      466       +1     
Flag Coverage Δ
integration 79.15% <100.00%> (+0.06%) ⬆️
unit 47.21% <20.68%> (-0.08%) ⬇️

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

Files with missing lines Coverage Δ
ydb/aio/pool.py 75.21% <100.00%> (+0.64%) ⬆️
ydb/aio/query/session.py 88.60% <ø> (-0.15%) ⬇️
ydb/pool.py 83.88% <100.00%> (+0.49%) ⬆️
ydb/query/session.py 91.62% <100.00%> (+0.61%) ⬆️

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Pull request overview

Copilot reviewed 63 out of 87 changed files in this pull request and generated 2 comments.

Files not reviewed (13)
  • ydb/_grpc/v3/draft/protos/ydb_maintenance_pb2.py: Language not supported
  • ydb/_grpc/v3/draft/protos/ydb_replication_pb2.py: Language not supported
  • ydb/_grpc/v3/draft/protos/ydb_view_pb2.py: Language not supported
  • ydb/_grpc/v3/draft/ydb_replication_v1_pb2.py: Language not supported
  • ydb/_grpc/v3/draft/ydb_view_v1_pb2.py: Language not supported
  • ydb/_grpc/v3/protos/ydb_query_pb2.py: Language not supported
  • ydb/_grpc/v3/protos/ydb_topic_pb2.py: Language not supported
  • ydb/_grpc/v3/ydb_table_v1_pb2.py: Language not supported
  • ydb/_grpc/v4/draft/protos/ydb_maintenance_pb2.py: Language not supported
  • ydb/_grpc/v4/draft/protos/ydb_replication_pb2.py: Language not supported
  • ydb/_grpc/v4/draft/protos/ydb_view_pb2.py: Language not supported
  • ydb/_grpc/v4/draft/ydb_replication_v1_pb2.py: Language not supported
  • ydb/_grpc/v4/draft/ydb_view_v1_pb2.py: Language not supported

Comment thread ydb/pool.py Outdated
Comment thread ydb/_grpc/v6/ydb_table_v1_pb2_grpc.py
@github-actions github-actions Bot removed the SLO label Jun 11, 2026
@github-actions github-actions Bot removed the SLO label Jun 14, 2026
@github-actions

Copy link
Copy Markdown

🌋 SLO Test Results

🟢 2 workload(s) tested — All thresholds passed

Commit: dbe5fee · View run

Workload Thresholds Duration Report
sync-query 🟢 OK 10m 10s 📄 Report
sync-table 🟢 OK 10m 2s 📄 Report

Generated by ydb-slo-action

@KirillKurdyukov
KirillKurdyukov force-pushed the feat-attach-stream branch 2 times, most recently from a0a70db to 3a583b1 Compare June 29, 2026 09:22
KirillKurdyukov and others added 8 commits July 8, 2026 10:20
Co-authored-by: Cursor <cursoragent@cursor.com>
Move the missing-node-id check to the session and tighten the connection
pool contract to accept a concrete int node id.

Co-authored-by: Cursor <cursoragent@cursor.com>
Look up node connections under ConnectionsCache lock when
pessimizing after NodeShutdown hints, and strip grpcio-tools
version gates from v6 gRPC stubs so imports work with grpcio>=1.42.0.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore stubs from main and strip grpcio version gates via generate_protoc,
instead of leaving broken conflict markers or truncated files.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore auto-generated stubs and generate_protoc.py to match main.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Cover attach stream wrapper, ConnectionsCache lookup, and async pool
pessimize edge cases to satisfy codecov/patch threshold.

Co-authored-by: Cursor <cursoragent@cursor.com>

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread tests/query/test_query_session_hints.py

@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

  • Minor | Medium: Fire-and-forget asyncio task reference not saved — ydb/aio/pool.py:321
  • Minor | Low: If _pessimize_node raises, _close_session is skipped on that code path — ydb/query/session.py:172
  • Nit | High: No logging when session shutdown hints are received — ydb/query/session.py:164

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/aio/pool.py

connection = cast(Optional[Connection], self._store.get_connection_by_node_id(node_id))
if connection is not None:
asyncio.get_running_loop().create_task(self._on_disconnected(connection)())

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

The task created by create_task() is not saved to a variable. Per the Python docs: "Save a reference to the result of this function, to avoid a task disappearing mid-execution." Starting from Python 3.12, the event loop only keeps weak references to tasks, so an unsaved task may be garbage-collected before completing.

Additionally, if connection.close() inside _on_disconnected raises, the exception will go unhandled (only producing a Task exception was never retrieved warning).

Suggested fix: store the task and add a done-callback to discard it, e.g.:

task = asyncio.get_running_loop().create_task(self._on_disconnected(connection)())
task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)

Or collect tasks in a set with task.add_done_callback(self._background_tasks.discard).

Comment thread ydb/query/session.py
hint = response_pb.WhichOneof("session_hint")
if hint == "node_shutdown":
if self._node_id is not None:
self._driver._pessimize_node(self._node_id)

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: Low

If _pessimize_node raises (e.g. connection.close() fails inside the sync pool's _on_disconnected), the _close_session(invalidate=True) call on line 173 is skipped. The session is eventually invalidated through the exception propagating up to _check_session_status_loop's except handler, but the recovery path is indirect.

Suggested fix — wrap the pessimization so _close_session is always reached:

if hint == "node_shutdown":
    if self._node_id is not None:
        try:
            self._driver._pessimize_node(self._node_id)
        except Exception:
            logger.debug("Failed to pessimize node %s", self._node_id, exc_info=True)
    self._close_session(invalidate=True)

Comment thread ydb/query/session.py
self._handle_attach_session_state(response_pb)
return common_utils.ServerStatus.from_proto(response_pb)

def _handle_attach_session_state(self, response_pb) -> None:

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: Nit
Confidence: High

When a NodeShutdown or SessionShutdown hint arrives, the session is closed without any log entry indicating why. The eventual stream-error log from _check_session_status_loop ("Attach stream error: …") doesn't mention the hint was the root cause, making it harder to diagnose graceful-shutdown scenarios in production.

Suggested fix — add a debug-level log at the top of each branch:

if hint == "node_shutdown":
    logger.debug("NodeShutdown hint received, session_id: %s, node_id: %s", self._session_id, self._node_id)
    ...
elif hint == "session_shutdown":
    logger.debug("SessionShutdown hint received, session_id: %s", self._session_id)
    ...

@robot-vibe-db

robot-vibe-db Bot commented Jul 8, 2026

Copy link
Copy Markdown

Full analysis log

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

@vgvoleg
vgvoleg merged commit 3054b8f into main Jul 8, 2026
35 checks passed
@vgvoleg
vgvoleg deleted the feat-attach-stream branch July 8, 2026 09:10
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.

5 participants