Skip to main content
Version: V1.4.0

Primary and standby overview

seekdb provides high availability through asynchronous log replication between a primary instance and a standby instance. The primary (PRIMARY) accepts reads and writes. The standby (STANDBY) continuously pulls and replays logs from its upstream instance and can serve read-only queries. You can promote the standby when the primary requires maintenance or becomes unavailable.

Roles and replication​

  • PRIMARY: Provides query, DML, and DDL services.
  • STANDBY: Synchronizes and replays logs from the upstream instance specified by log_restore_source, and provides read-only services.
  • Replication between the primary and standby is asynchronous. Before a planned switchover, wait for the standby to catch up with the primary. A failover can lose data that has not yet reached the standby.
  • After a role change, applications must connect to the new primary address. seekdb does not transparently move the connection endpoint.

Role changes​

In V1.4.0, a planned switchover consists of distinct stages:

  1. Execute ALTER SYSTEM SWITCHOVER TO STANDBY on the original primary. This operation stops accepting new writes, waits for active transactions and log appends to complete, and persists the pending role.
  2. At this point, the original primary still reports ROLE=PRIMARY, together with PENDING_ROLE=STANDBY and SWITCHOVER_STATUS=PREPARING. It adopts the standby role only after its process is restarted.
  3. On a standby that has caught up, execute ALTER SYSTEM SWITCHOVER TO PRIMARY to promote it online to the new primary.
  4. An external deployment tool or operations workflow must update the upstream address of the original primary, then stop and restart it after the new primary is ready.

If the primary cannot be recovered, execute ALTER SYSTEM ACTIVATE STANDBY on the standby to activate it online as the new primary. This operation cannot recover data that was not replicated to the standby.

Synchronization status​

Use V$OB_SERVER_STAT to view the active role and synchronization SCNs:

SELECT ROLE, SYNC_SCN, READABLE_SCN
FROM oceanbase.V$OB_SERVER_STAT;

When diagnosing a role change, you can query the pending role and switchover status from the internal virtual table:

SELECT ROLE, PENDING_ROLE, SWITCHOVER_STATUS,
LOG_RESTORE_SOURCE, SYNC_SCN, READABLE_SCN
FROM oceanbase.__all_virtual_server_stat;

__all_virtual_server_stat is an internal diagnostic interface and must not be used as a long-term application dependency.

Key configuration items​

Configuration itemDescriptionDefaultEffective mode
rpc_portThe RPC port used between the primary and standby.2882At startup
enable_rpc_serviceWhether to start the RPC service. Enable it on both the primary and standby.falseAfter restart
log_restore_sourceThe standby's upstream endpoint in IP:RPC_PORT format.EmptyDynamic
log_disk_sizeThe upper limit on redo log disk usage. In primary/standby mode, OBD configures this value to three times memory_budget.0Dynamic
log_disk_utilization_thresholdThe disk utilization threshold that triggers redo log recycling.0Dynamic

Limitations​

  • Only synchronization from a network upstream is supported. Restore from archived media, paused replay, and controlled replay are not supported.
  • During a switchover, ensure that the original primary no longer provides write services to prevent a split-brain condition.
  • Read-only data on the standby is bounded by READABLE_SCN and can lag behind the primary.
  • This documentation describes the standard one-primary, one-standby workflow. In a topology with multiple or cascading standbys, update the upstream relationship of each standby separately and use deployment tooling to orchestrate the topology.

For related procedures, see Create a standby instance, View instance synchronization status, and Switch roles.