Skip to content

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

Open
kprokopenko wants to merge 2 commits into
masterfrom
refactor/pool-inline-close-and-must-delete
Open

refactor(pool): inline item close and must-delete session logic#2232
kprokopenko wants to merge 2 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.143.0
Suggested version: v3.143.1

@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 75.32%. Comparing base (9efa606) to head (8ef3bc3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2232      +/-   ##
==========================================
- Coverage   75.40%   75.32%   -0.09%     
==========================================
  Files         445      445              
  Lines       45996    45981      -15     
==========================================
- Hits        34684    34635      -49     
- Misses       9352     9385      +33     
- Partials     1960     1961       +1     
Flag Coverage Δ
experiment 75.23% <100.00%> (-0.04%) ⬇️
go-1.21.x 72.20% <100.00%> (-0.09%) ⬇️
go-1.26.x 75.32% <100.00%> (-0.04%) ⬇️
integration 56.89% <100.00%> (-0.10%) ⬇️
macOS 45.21% <100.00%> (+<0.01%) ⬆️
ubuntu 75.32% <100.00%> (-0.09%) ⬇️
unit 45.21% <100.00%> (-0.01%) ⬇️
windows 45.20% <100.00%> (-0.01%) ⬇️
ydb-24.4 56.49% <100.00%> (-0.02%) ⬇️
ydb-edge 56.69% <100.00%> (-0.11%) ⬇️
ydb-latest 56.61% <100.00%> (-0.09%) ⬇️
ydb-nightly 75.23% <100.00%> (-0.04%) ⬇️

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.

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

2 participants