Handling configuration issuse and getting notifications about pool state at startup#104
Handling configuration issuse and getting notifications about pool state at startup#104mcesaro wants to merge 6 commits intoerleans:mainfrom
Conversation
|
Sounds cool! When would you use this new feature? Trying to fully understand the use cases. Thank you |
|
I found the need when I tried to start an application and the postgres connection setup info was dynamically provided by a central configuration server and it was wrongly configured. Same also when postgres was stopped for maintenance at my application startup time. The pool retried indefinitely and my idea was to send a message to the operator that there is a problem with the postgres service. Also, fixing the confugration didn't work outright because the pool was already initialized and the only way to use the new config is by restarting it, stopping the whole application. With this PR, when I receive a notification that at least one connection with postgres is up, the rest of the application can act accordingly. If not, just the pool is killed so I can retry later. |
|
Do you really want to notify for each connection that fails instead of the pool? But also, couldn't the process that wants to be notified instead monitor the pool process? I figured the use of backoff made this feature unnecessary since it won't just keep constantly flooding with attempts to connect -- though the backoff does need to be made configurable as it right now will not go above trying to reconnect every 10 seconds. I wonder if exposing a I'm definitely for the idea of being able to kick the pool easily when you know it will never connect successfully and have a fixed configuration. |
|
A single notification is enough, as the problem happens only at the pool creation time and we shouldn't care of a single connection down at runtime. |
This pull request add the possibility to define the max number of reconnection retries and then stop in case there are problems in the pool configuration or if the postgres database cannot be reached.
The caller process can receive notification messages when a db connection from the pool is available or if the pool has no connections to the database. See the readme file for the details.
If the connection cannot be established, the pool process is terminated, so it is possible to try again when the configuration/connectivity issues are removed.