Skip to content

feat[pool]: Expose Close method to facilitate removal of broken connections#1054

Merged
ernado merged 1 commit intoClickHouse:mainfrom
danieloliveira-shopify:add-close-pool
Jul 16, 2025
Merged

feat[pool]: Expose Close method to facilitate removal of broken connections#1054
ernado merged 1 commit intoClickHouse:mainfrom
danieloliveira-shopify:add-close-pool

Conversation

@danieloliveira-shopify
Copy link
Copy Markdown
Contributor

Summary

This adds a Close method to the chpool.Client struct. This function will close the underlying connection and destroy the resource from the pool.

This will allow broken connections to not be put back into the pool if they are broken. The snipped below exemplifies the scenario.

conn, err := pool.Acquire(ctx)
if err != nil {
	return nil, err
}

if err := conn.Ping(ctx); err != nil {
	conn.Close() <<<<< This connections is broken and should not be put back into the pool using conn.Release()
	return nil, level.Error(logger).Log("msg", "failed to ping acquired connection from pool", "err", err)
}

return conn, nil

Checklist

Delete items not relevant to your PR:

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2025

CLA assistant check
All committers have signed the CLA.

@SpencerTorres
Copy link
Copy Markdown
Member

@danieloliveira-shopify Make sure to complete the CLA in the above message

@ernado ernado merged commit 067ca6f into ClickHouse:main Jul 16, 2025
18 of 19 checks passed
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.

4 participants