Add support of dedicated backends #10506
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
We are now going to provide connection pooling by default:
https://neondb.slack.com/archives/C04DGM6SMTM/p1737726792110159
The problem is that connections pooler in transactions or statement mode doesn't preserve session semantic.
It means that Postgres applications using
will not work.
Summary of changes
We can still provide connection pooling by default, but enforce dedicated backends at Postgres level. In pgbouncer we are using transaction pooler mode. It means that pgbouncer will not reschedule backend to some other session until ned of transaction. End of transaction is determined by pgbouncer by backend status in
ReadyForQuery
message ('T' - transaction, 'I' - idle). We can add some checks to Postgres (I already done in in my pooler and it affects only very few places in Postgres core) which detects if connection need to preserve session semantic.In this case we will always return 'T' status in
ReadyForQuery
message, preventing pgbouncer from reusing our backend.See neondatabase/postgres#571