Skip to content

closed pool #2165

Closed Answered by jackc
nexovec asked this question in Q&A
Nov 14, 2024 · 4 comments
Discussion options

You must be logged in to vote

Sometimes my pgx Pool closes and all the database accesses return closed pool error. Is there a way to error handle this or detect this? Couldn't find anything.

I found mentions of how the pool should never be closed unless you call .Close().

This is correct. The only way a pgxpool is closed is by calling Close(). Any errors encountered using the pool will only affect the underlying connections. I strongly suspect your application is inadvertently closing the pool.

I'm also surprised that it's not context aware, it might easily just end up blocking for a very long time.

That is correct, it does block. But it's not clear what the alternative would be. What is the state of a pool where

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by nexovec
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants