Skip to content

refactor(pool): inline item close and must-delete session logic#2232

Merged
kprokopenko merged 3 commits into
masterfrom
refactor/pool-inline-close-and-must-delete
Jul 16, 2026
Merged

refactor(pool): inline item close and must-delete session logic#2232
kprokopenko merged 3 commits into
masterfrom
refactor/pool-inline-close-and-must-delete

Conversation

@kprokopenko

Copy link
Copy Markdown
Collaborator

Summary

  • Remove closeItemFunc and mustDeleteItemFunc hooks from internal/pool configuration.
  • Call item.Close directly when closing pool items and use xerrors.MustDeleteTableOrQuerySession in checkItemAndError.
  • Drop duplicated WithMustDeleteItemFunc setup from table/query clients and update pool tests to use BAD_SESSION errors instead of custom predicates.

Test plan

  • go test ./internal/pool/ -count=1
  • go test ./internal/table/ -count=1
  • go test ./internal/query/ -count=1
  • golangci-lint run ./internal/pool/ ./internal/table/ ./internal/query/

Made with Cursor

Remove closeItemFunc and mustDeleteItemFunc hooks from internal pool
configuration and call item.Close and xerrors.MustDeleteTableOrQuerySession
directly, eliminating duplicated setup in table and query clients.

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

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

summary

Inferred base version: v3.144.3
Suggested version: v3.144.4

@codecov-commenter

codecov-commenter commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.88%. Comparing base (9c42b65) to head (6d5619a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2232      +/-   ##
==========================================
- Coverage   78.00%   77.88%   -0.13%     
==========================================
  Files         453      453              
  Lines       46204    46189      -15     
==========================================
- Hits        36042    35972      -70     
- Misses       8081     8127      +46     
- Partials     2081     2090       +9     
Flag Coverage Δ
experiment 77.75% <100.00%> (-0.14%) ⬇️
go-1.21.x 74.75% <100.00%> (-0.11%) ⬇️
go-1.26.x 77.84% <100.00%> (-0.15%) ⬇️
integration 55.46% <100.00%> (-0.18%) ⬇️
macOS 48.31% <100.00%> (-0.03%) ⬇️
ubuntu 77.88% <100.00%> (-0.13%) ⬇️
unit 48.32% <100.00%> (-0.06%) ⬇️
windows 48.30% <100.00%> (-0.07%) ⬇️
ydb-24.4 55.00% <100.00%> (-0.27%) ⬇️
ydb-edge 55.34% <100.00%> (-0.15%) ⬇️
ydb-latest 55.23% <100.00%> (-0.24%) ⬇️
ydb-nightly 77.75% <100.00%> (-0.14%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@robot-vibe-db

robot-vibe-db Bot commented Jul 7, 2026

Copy link
Copy Markdown

AI Review Summary

Verdict: ✅ No critical issues found

Critical issues

No critical issues found.

Other findings

  • Nit | Low: The comment block in pool_test.go:571-573 ("Count closes to detect context-cancelled failures…") was moved from the old closeItemFunc override into the onClose callback definition. In the new location the comment describes why closes are counted, which is fine, but the remark about gRPC context-cancelled behavior is less relevant to the onClose factory and slightly misleading — testItem.Close() does not actually use the context. Consider shortening to just the counting rationale. — internal/pool/pool_test.go:571

Detailed analysis:

The refactoring is behaviorally equivalent for all production callers:

  1. mustDeleteItemFunc removal: The old callers (table/client, query/client) all passed the same predicate: !s.IsAlive() || (err != nil && MustDeleteTableOrQuerySession(err)). The IsAlive() part was redundant because checkItemAndError already checks !item.IsAlive() as its first operation. The err != nil guard was redundant because checkItemAndError returns early when err == nil. So the inlined xerrors.MustDeleteTableOrQuerySession(err) call is exactly equivalent.

  2. closeItemFunc removal: The default implementation was _ = item.Close(ctx), and no caller ever overrode it. The inline _ = item.Close(closeCtx) is identical.

  3. Test updates: Tests now use xerrors.Operation(xerrors.WithStatusCode(Ydb.StatusIds_BAD_SESSION)) instead of custom error+predicate combinations. BAD_SESSION is both naturally retryable (via operationError.Type() → TypeRetryable) and detected by MustDeleteTableOrQuerySession, so the test semantics are preserved.

  4. //nolint:funlen removal: Both pool.New() and query.newWithQueryServiceClient() are now under the default funlen threshold (~56–57 lines), making the nolint directives unnecessary.

No remaining references to the removed API (WithMustDeleteItemFunc, closeItemFunc, mustDeleteItemFunc) exist in the codebase.


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.

@robot-vibe-db

robot-vibe-db Bot commented Jul 7, 2026

Copy link
Copy Markdown

Full analysis log

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

kprokopenko and others added 2 commits July 7, 2026 17:36
Drop the misleading gRPC context-cancellation remark from the onClose
factory comment; testItem.Close does not use the context.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings July 16, 2026 13:06

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.

@kprokopenko
kprokopenko merged commit 2f5b6a9 into master Jul 16, 2026
39 checks passed
@kprokopenko
kprokopenko deleted the refactor/pool-inline-close-and-must-delete branch July 16, 2026 14:04
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.

4 participants