hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.1k stars 115 forks source link

How can I force a node to be primary #996

Closed dblife1024 closed 1 year ago

dblife1024 commented 1 year ago

hi,I use pg_auto_failover and citus

Due to some reasons, my architecture is in an abnormal situation,

pg_autoctl show state --pgdata /data1/citusdata/citusmonitor/ Name | Node | Host:Port | TLI: LSN | Connection | Reported State | Assigned State ---------+-------+----------------------+-------------------+--------------+---------------------+-------------------- coord0a | 0/27 | 10.249.104.123:5432 | 4: B1/70193AC8 | read-only | secondary | secondary coord0b | 0/28 | 10.249.104.212:5432 | 4: B1/70193AC8 | read-write | primary | primary worker1a | 1/29 | 10.249.104.123:15432 | 6: 29D/389788C0 | read-only | secondary | secondary worker1b | 1/30 | 10.249.104.212:15432 | 6: 29D/389788C0 | read-write | primary | primary worker2a | 2/31 | 10.249.104.123:15433 | 4: 2AC/B543C30 | read-only | secondary | secondary worker2b | 2/32 | 10.249.104.212:15433 | 4: 2AC/B542080 | read-write | primary | primary worker3a | 3/33 | 10.249.104.212:15434 | 5: 229/E7139838 | read-write | primary | primary worker3b | 3/34 | 10.249.104.123:15434 | 5: 229/E713A000 | read-only | secondary | secondary worker4b | 4/48 | 10.249.106.211:15432 | 3: 211/21478E28 | read-write | single | single worker5a | 5/49 | 10.249.106.210:15433 | 1: 0/0 | none ! | wait_standby | single worker5b | 5/50 | 10.249.106.211:15433 | 1: 0/0 | none ! | wait_standby | wait_standby worker6b | 6/52 | 10.249.106.211:15434 | 1: 0/0 | none ! | wait_standby | wait_standby worker6a | 6/60 | 10.249.106.210:15434 | 1: 0/0 | none ! | wait_standby | single

Can I forcefully designate worker5a and worker6a as primary nodes without considering the risk of data loss? None of these three commands can meet this requirement. “pg_autoctl perform swithchover pg_autoctl perform promotion pg_autoctl perform failover”

dimitri commented 1 year ago

The last resort command is to force drop a node in each group, the remaining node would then be a single, and then you can re-create the missing node.