Skip to content

fix: suppress pool Close() errors for stale connections#3778

Merged
ndyakov merged 4 commits into
masterfrom
fix-suppress-pool-close-errors-for-stale-conns
Apr 23, 2026
Merged

fix: suppress pool Close() errors for stale connections#3778
ndyakov merged 4 commits into
masterfrom
fix-suppress-pool-close-errors-for-stale-conns

Conversation

@ofekshenawa

@ofekshenawa ofekshenawa commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3775

pool.Close() now checks isHealthyConn before propagating connection close errors, aligning its behavior with the existing error suppression in Get() where stale connections are silently discarded.
This prevents spurious errors (e.g., TLS closeNotify timeouts) from being returned when closing a pool whose connections have already been dropped by the server due to idle timeout.


Note

Medium Risk
Changes ConnPool.Close() error propagation semantics by suppressing close errors for connections deemed stale via isHealthyConn, which could mask some real shutdown-close failures if the health check misclassifies a connection.

Overview
ConnPool.Close() now evaluates each connection with isHealthyConn before closing it and only propagates the first Close() error when the connection is still considered healthy; close errors from stale/expired connections are suppressed to match Get()’s stale-connection handling.

Tests add a failCloseConn helper to simulate TLS/network close failures and verify that Close() returns no error for idle-timeout-stale conns, but still returns the close error for healthy ones.

Reviewed by Cursor Bugbot for commit 9329719. Bugbot is set up for automated code reviews on this repo. Configure here.

@jit-ci

jit-ci Bot commented Apr 15, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 238ec1f. Configure here.

Comment thread internal/pool/pool.go
ndyakov
ndyakov previously approved these changes Apr 22, 2026

@ndyakov ndyakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@ndyakov ndyakov merged commit 1a7ac74 into master Apr 23, 2026
39 checks passed
@ndyakov ndyakov deleted the fix-suppress-pool-close-errors-for-stale-conns branch April 23, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pool close errors are not suppressed when ConnMaxIdleTime expired

2 participants