-
Notifications
You must be signed in to change notification settings - Fork 108
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
Implement a demo application showing client-side HA with reconnections #568
Merged
Conversation
This file contains 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
DimCitus
changed the title
Feature/demo app
Implement a demo application showing client-side HA with reconnections
Jan 7, 2021
Now with an histogram of connection times distribution:
|
DimCitus
force-pushed
the
feature/open-hba-for-lan
branch
from
January 15, 2021 15:31
fc0faca
to
4f97641
Compare
DimCitus
force-pushed
the
feature/demo-app
branch
from
February 11, 2021 17:01
416388c
to
8e3e0d3
Compare
JelteF
approved these changes
Feb 12, 2021
With this option pg_autoctl edits the pg_hba.conf for Postgres to grant connection privileges on the detected LAN for the --dbname database and for the --username user. The LAN detection is done the same way as with the monitor.
This avoids some retry attemps from the other nodes at first startup.
Rather than adding an hostname that we know faulty in the HBA file, we add one of the IP addresses of the hostname instead. We might want to revisit this (add all IP addresses maybe? or find the one we want to add by connecting, like we do for the monitor?), but it allows the docker-compose demo to just work with a minimum of trouble.
The goal is to show what happens client-side (in the application) at failover time. Handling disconnections properly and reconnecting to the same database connection string to reach the new primary.
The demo application runs concurrent clients that each connect to a Postgres database multi-host connection string, and INSERT some statistics about the time taken to connect, and how many connection attempts where made.
Let's better focus on the story we want to share through this demo app.
DimCitus
force-pushed
the
feature/demo-app
branch
from
February 12, 2021 15:54
8e3e0d3
to
ee1cc66
Compare
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.
Introduces a demo application to pg_auto_failover. The demo application loops over a simple INSERT query that records the time taken to open a connection, and the number of retries that was necessary in the process of doing so.
The intend is to be able to run such application from within the docker-compose environment in order to show the proper behaviour of retrying connections when the connection is lost, all without having to edit the connection string upon failover.
Here is a sample output from running the demo manually in a
make cluster
environment: