Switch roles
This topic describes a planned primary/standby switchover and standby activation after a primary failure in seekdb V1.4.0.
Planned switchover
The following procedure assumes that seekdb_A is the original primary and seekdb_B is a standby that has caught up.
-
Stop application writes and verify that
SYNC_SCNandREADABLE_SCNon the standby have caught up with the original primary. -
Run the precheck on the original primary:
ALTER SYSTEM SWITCHOVER TO STANDBY VERIFY;VERIFYchecks the conditions only. It does not block writes or change role state. -
Initiate primary demotion on the original primary:
ALTER SYSTEM SWITCHOVER TO STANDBY;After the statement succeeds, the original primary no longer accepts writes, but its active role is still
PRIMARY. Execute the following query and verify thePRIMARY/STANDBY/PREPARINGstate:SELECT ROLE, PENDING_ROLE, SWITCHOVER_STATUS
FROM oceanbase.__all_virtual_server_stat; -
On the standby, run the promotion precheck and promote it online:
ALTER SYSTEM SWITCHOVER TO PRIMARY VERIFY;
ALTER SYSTEM SWITCHOVER TO PRIMARY;After promotion, use
V$OB_SERVER_STATto verify thatROLE=PRIMARYonseekdb_B, and then redirect application connections to the new primary. -
Update
log_restore_sourceon the original primary to the RPC endpoint of the new primary. After confirming that the new primary accepts reads and writes, stop and restart the original primary. During startup, it activates the persistedSTANDBYrole. -
Verify that the restarted original primary reports
ROLE=STANDBYandSWITCHOVER_STATUS=NORMAL, and that its synchronization SCNs continue to advance.
After step 3, do not treat the original primary's remaining ROLE=PRIMARY value as a failed switchover, and do not re-enable writes on it. The process has already blocked writes. An external operations workflow must update its configuration and restart it.
Failover
Execute the following statements on the standby only after the original primary is unrecoverable or has been isolated:
ALTER SYSTEM ACTIVATE STANDBY VERIFY;
ALTER SYSTEM ACTIVATE STANDBY;
ACTIVATE STANDBY promotes the current standby online to a primary. Data that has not reached the standby cannot be recovered, so this procedure can cause data loss.
After promotion:
- Use
V$OB_SERVER_STATto verify the new primary role. - Redirect application connections to the new primary.
- Do not start or remove isolation from the old primary, because doing so can create a split-brain condition.
- Reconfigure
log_restore_sourceon other standbys or rebuild them.
About OBD commands
Until OBD orchestration for stopping the old primary, updating its upstream, and restarting it has been implemented and verified for V1.4.0, this topic does not use obd seekdb switchover as a substitute for the complete procedure. When using automation, inspect the actual active role, pending role, and switchover status at each stage.
For SQL syntax, see SWITCHOVER and ACTIVATE STANDBY.