add a setting to allow cancelations to bypass any pool limit checks #543
+9
−1
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.
As described in #245 this is the first patch in a series of patches to improve the cancelation of a backend when pgbouncer is involved.
In this patch we introduce thecancel_bypass_pool_size
setting. This setting is interpreted as a boolean and should be set to either0
or1
. When set to1
a queued cancelation inside pgbouncer will always allow the creation of a new connection. Even if the creation of a new connection would normally not be allowed due to violation of pool sizes.Since pgbouncer will use new connections first for cancelations and postgres doesn't count a cancelation request towards the
max_connection
setting on the database, bypassing any pool size limits should be safe.However, since this can introduce more connections to be opened I have chosen to make the settingoff
by default. Even though I think running with this settingoff
could cause issues if your application issues cancelations under load. Overtime, when we see no negative sideeffects of this bypass we could re-evaluate if the setting should be turned on by default.Edit:
The current implementation is to allow (force) a new connection when we have cancelation requests queued. With a limit of 2 * the current pool size. As suggested on the PR, this allows for every connection that can be established to receive a cancelation while keeping an upper bound on the number of outgoing connections.