Repository navigation
Improve recommended systemd unit file - #983
Merged
Merged
Conversation
Replace network.target with network-online.target. Postgres already did it [1]. Issue pgbouncer#980 suggests that if you are using DNS and, for some reason, the PgBouncer starts before the network finishes the initialization, it is unable to resolve names; the solution is to restart the service if it occurs (which is a unfortunate workaround). According to man 7 systemd.special [2]: Note the distinction between this unit and network.target. This unit is an active unit (i.e. pulled in by the consumer rather than the provider of this functionality) and pulls in a service which possibly adds substantial delays to further execution. In contrast, network.target is a passive unit (i.e. pulled in by the provider of the functionality, rather than the consumer) that usually does not delay execution much. It could delay the service start up to $timeout (default is 90 seconds). Hence, PgBouncer won't accept connections until the network is ready and it is time to start the service. It seems a good tradeoff to wait until the network is ready then to fail a setup that uses DNS. (If you don't use DNS and cannot afford waiting the network to be ready and wants to accept client connections ASAP, then edit the systemd unit file and revert this change.) Fixes pgbouncer#980 [1] postgres/postgres@2d27e13b35 [2] https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
Contributor
|
Fixes #987 In #987, PgBouncer cannot bind to an ip address before networking starts. So even when PgBouncer does not use DNS, this fix is needed most of the times. |
emelsimsek
approved these changes
Nov 23, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace network.target with network-online.target. Postgres already did it [1]. Issue #980 suggests that if you are using DNS and, for some reason, the PgBouncer starts before the network finishes the initialization, it is unable to resolve names; the solution is to restart the service if it occurs (which is a unfortunate workaround).
According to man 7 systemd.special [2]:
Note the distinction between this unit and network.target. This unit is an active unit (i.e. pulled in by the consumer rather than the provider of this functionality) and pulls in a service which possibly adds substantial delays to further execution. In contrast, network.target is a passive unit (i.e. pulled in by the provider of the functionality, rather than the consumer) that usually does not delay execution much.
It could delay the service start up to $timeout (default is 90 seconds). Hence, PgBouncer won't accept connections until the network is ready and it is time to start the service. It seems a good tradeoff to wait until the network is ready then to fail a setup that uses DNS. (If you don't use DNS and cannot afford waiting the network to be ready and wants to accept client connections ASAP, then edit the systemd unit file and revert this change.)
Fixes #980
[1] postgres/postgres@2d27e13b35
[2] https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/