Skip to main content
Version: V1.4.1

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.

  1. Stop application writes and verify that SYNC_SCN and READABLE_SCN on the standby have caught up with the original primary.

  2. Run the precheck on the original primary:

    ALTER SYSTEM SWITCHOVER TO STANDBY VERIFY;

    VERIFY checks the conditions only. It does not block writes or change role state.

  3. 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 the PRIMARY/STANDBY/PREPARING state:

    SELECT ROLE, PENDING_ROLE, SWITCHOVER_STATUS
    FROM oceanbase.__all_virtual_server_stat;
  4. 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_STAT to verify that ROLE=PRIMARY on seekdb_B, and then redirect application connections to the new primary.

  5. Update log_restore_source on 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 persisted STANDBY role.

  6. Verify that the restarted original primary reports ROLE=STANDBY and SWITCHOVER_STATUS=NORMAL, and that its synchronization SCNs continue to advance.

warning

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:

  1. Use V$OB_SERVER_STAT to verify the new primary role.
  2. Redirect application connections to the new primary.
  3. Do not start or remove isolation from the old primary, because doing so can create a split-brain condition.
  4. Reconfigure log_restore_source on 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.