Open Kobaruon opened 1 year ago
I agree, I was thinking of implementing the same thing. Another approach could be to patch Patroni to update PgCat's config when something changes in the cluster.
Generally I think config-driven routing is better than probing nodes for information because configs are changed and verified by some system who's entire job is to make sure configs are correct. Meanwhile, someone can just remove standby.signal
by accident from a replica and promote it, and we'll have a split-brain situation or a config validation failure because PgCat does not accept multiple primaries in one shard.
I think overall though, in most situations, this feature is likely to do more good than harm, so we should implement it but put it behind a config, e.g. automatic_role_discovery = true
and set it to false by default for the time being until we understand all corner cases better.
hi, mark "primary" is write-able with read , and 'replica' for read only ?
hi, mark "primary" is write-able with read , and 'replica' for read only ?
Yes, primary is a leader node with both reads and writes. Replica is for read only.
Patroni definitely does a lot of great stuff; however, would it be within scope to just replace Patroni with something like this? The primary mechanism with pgcat seems to be a bit more narrow in scope. It doesn't appear as though the primary can be dynamically changed in this system, instead such would require a manual — or at least an externally driven — reconfig.
Thoughts?
At the moment, that's true, but we can make it dynamic. Patroni does more things to the actual DBs, like reconfiguration after failover, so pgcat can't replace Patroni yet, and might be out of scope at the moment.
There is benefit to having a unified tool that handles Postgres production deployments as a whole, in the future.
Got the same issue with pg-auto-failover select pg_is_in_recovery(); => t on primary select pg_is_in_recovery(); => f on secondaries
Patroni uses confd for proxy config patching, https://github.com/zalando/patroni/tree/master/extras#confd I think pgcat can maintain a set of configs of its own
Got the same issue with pg-auto-failover select pg_is_in_recovery(); => t on primary select pg_is_in_recovery(); => f on secondaries
I'm also using pg-auto-failover, so it would be great to make it easier to mark the new primary automatically, and then at least offer some notification capability.
pg_autofailover here too
Hi @levkk Consider I have postgres running on A machine and I have B which is a replica. Now I want to do failover from A to B without downtime or data loss, is it possible to use pgCat or other tools? Thanks
can someone found any solution for that issue? I'm getting same issue.
This would be a great feature to have. We are not using Patroni but this feature would be perfect for our use case.
Is your feature request related to a problem? Please describe. When a primary node failover on PostgreSQL cluster specifically Patroni in my case, pgcat needs to be configured again to correctly route queries.
When this happens, it bans that node correctly, but it can not detect another node that becomes primary on its own. As a result of this, write queries get errors.
Describe the solution you'd like I think this behaviour can be improved by checking nodes with a query like this to see if they are primary or replica.
If this query returns
true
pgcat can mark that node replica, if it'sfalse
then it knows that's a primary node.Describe alternatives you've considered Another alternative can be creating a test table when pgcat starts, and it can run INSERT/DELETE/UPDATE on that table to see if it runs successfully.
What do you think? Is this a viable solution to this problem?