Skip to content

Draft PR (no merge!!!): check CI after remove line with canceling stream context#2120

Draft
asmyasnikov wants to merge 1 commit into
masterfrom
draft-test-no-cancel-context
Draft

Draft PR (no merge!!!): check CI after remove line with canceling stream context#2120
asmyasnikov wants to merge 1 commit into
masterfrom
draft-test-no-cancel-context

Conversation

@asmyasnikov

Copy link
Copy Markdown
Member

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Other information

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

summary

Inferred base version: v3.135.10
Suggested version: v3.135.11

@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: ❌ 1 critical issue(s) found

Critical issues

  • Critical | High: Removing s.streamCancel() causes context and memory leak in CancelsGuardinternal/conn/grpc_client_stream.go:128

Other findings

  • Minor | High: streamCancel field becomes dead code (assigned but never called) — internal/conn/grpc_client_stream.go:24

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.

stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/conn.(*grpcClientStream).finish"), err,
)
s.streamCancel()
}

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

Removing s.streamCancel() introduces a context and memory leak. streamCancel is the wrapped cancel function returned by CancelsGuard.WithCancel (conn.go:485). It does two things:

  1. Cancels the stream's derived context.
  2. Removes the cancel function entry from the CancelsGuard.cancels map (see cancels_quard.go:27-32).

Without this call, each finished stream leaves a stale entry in childStreams.cancels. These entries accumulate over the connection's lifetime and are only cleaned up when the connection is closed (conn.go:548). For long-lived connections handling many streams, this is a memory leak proportional to the total number of streams ever opened.

Additionally, the stream's context remains uncanceled after the stream finishes, which can keep context-dependent resources (e.g., goroutines selecting on ctx.Done()) alive longer than intended.

Suggested fix: keep the s.streamCancel() call in finish().

@asmyasnikov asmyasnikov marked this pull request as draft May 5, 2026 15:53
@codecov-commenter

codecov-commenter commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.20%. Comparing base (9955e4c) to head (590a08a).

❗ There is a different number of reports uploaded between BASE (9955e4c) and HEAD (590a08a). Click for more details.

HEAD has 503 uploads less than BASE
Flag BASE (9955e4c) HEAD (590a08a)
unit 77 0
go-1.21.x 72 3
ubuntu 100 6
windows 25 0
go-1.26.x 79 3
macOS 26 0
ydb-latest 21 2
integration 65 6
ydb-edge 21 2
ydb-24.4 23 2
experiment 9 0
ydb-nightly 9 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2120       +/-   ##
===========================================
- Coverage   75.16%   57.20%   -17.97%     
===========================================
  Files         427      408       -19     
  Lines       36974    35101     -1873     
===========================================
- Hits        27792    20078     -7714     
- Misses       7993    13632     +5639     
- Partials     1189     1391      +202     
Flag Coverage Δ
experiment ?
go-1.21.x 56.94% <ø> (-15.73%) ⬇️
go-1.26.x 57.12% <ø> (-18.00%) ⬇️
integration 57.20% <ø> (-0.18%) ⬇️
macOS ?
ubuntu 57.20% <ø> (-17.97%) ⬇️
unit ?
windows ?
ydb-24.4 56.53% <ø> (-0.42%) ⬇️
ydb-edge 56.98% <ø> (-0.19%) ⬇️
ydb-latest 56.69% <ø> (-0.37%) ⬇️
ydb-nightly ?

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@github-actions github-actions Bot removed the SLO label May 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

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.

3 participants