Skip to content
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

Allow failover for replicas #857

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

magec
Copy link
Collaborator

@magec magec commented Nov 11, 2024

Now that #847 is merged, when a pool is set to default_role = replica (or manually set to replica), and no replicas are available, the primary won't be touched at all. Instead, replicas will be automatically set back to available and will be checked for health again.

If you have a single replica and it is actually down, you may find convenient to send queries to the primary until you fix the replica (if the primary can handle the load). To allow this behavior, a new configuration parameter is added to the configuration that will make the primary available to receive queries if every replica in the pool is banned.

### replica_to_primary_failover_enabled
` ` `
path: pools.<pool_name>.replica_to_primary_failover_enabled
default: "false"
` ` ` 

If set to true, when the specified role is `replica` (either by setting `default_role` or manually)
and all replicas are banned, queries will be sent to the primary (until a replica is back online).

Note that when this is enabled, the replicas won't be automatically unbanned (default behavior).

@magec magec force-pushed the replica-with-failover branch 3 times, most recently from f24a572 to 16a2cec Compare November 12, 2024 16:43
@magec magec force-pushed the replica-with-failover branch from 16a2cec to c527db5 Compare November 25, 2024 08:38
@dantio
Copy link

dantio commented Feb 6, 2025

@magec
Hey!
Did I understand correctly that with this PR, it will be possible to switch over between the primary and replica, like in the request here: GitHub Issue #228?

WIth default_role: primary and replica_to_primary_failover_enabled: true and pg_auto_failover: When a failover happens, pgcat should send traffic to the "replica." After the "primary" recovers, pgcat will use the primary again. That would be awesome!

@magec
Copy link
Collaborator Author

magec commented Feb 6, 2025

What this allow is using the primary when all replicas are down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants