Skip to content

How do you set a timeout for pool.Acquire in pgxpool, so that if the pool is full we can fail fast? #2185

Answered by jackc
vamshiaruru asked this question in Q&A
Discussion options

You must be logged in to vote

If you're directly calling Acquire on the pool then the regular context argument will do what you want. If Acquire is being called implicitly by another function like Query, then there is no built-in / intended way to have a separate context passed to Acquire. Off the top of my head, I'm not sure if using a Tracer as you describe would work.

This might actually relate to #2163 and #2171. It just occurred to me that a possible improvement to all of these would be to allow passing a context as a value in another context. e.g. You pass a context to Query, but if that context has a Value with the key of AcquireContext, then that context is used for the Acquire instead of the context passed to…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jwreschnig-utiq
Comment options

@vamshiaruru
Comment options

@vamshiaruru
Comment options

Answer selected by vamshiaruru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants