Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close connection when check query errors #683

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jfrconley
Copy link

Currently, pgbouncer will ignore errors returned by the check query. This is mostly ok for traditional Postgres, but creates issues when using pgbouncer in front of high availability pg compatible databases (ex: CockroachDB). Essentially, the pooler will hand out broken connections if the database is draining. This change simply closes SV_TESTED connections that receive errors, allowing for seamless failover. Additionally, newly logged in connections are now checked when check delay is set to zero.

Copy link
Member

@JelteF JelteF left a comment

Choose a reason for hiding this comment

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

I'm not entirely sure what issue this is fixing, could you describe the scenario a bit more clearly? I haven't used CockroachDB a lot, so I likely just need a bit more background to understand.

TBH, I'm not even sure I really understand the purpose of the server_check_query at all. From my look at the code of server_check_query, it's run after a previous query ends to check if the server is still working. I guess this is mostly to find out quickly if the connection got completely broken during the previous query, but even if it succeeds, it's still very possible that the connection breaks inbetween the server_check_query and the next query that's sent over the connection.

Also regarding this:

Additionally, newly logged in connections are now checked when check delay is set to zero.

What is this necessary for?

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.

None yet

2 participants