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 bylog_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:
- Execute
ALTER SYSTEM SWITCHOVER TO STANDBYon the original primary. This operation stops accepting new writes, waits for active transactions and log appends to complete, and persists the pending role. - At this point, the original primary still reports
ROLE=PRIMARY, together withPENDING_ROLE=STANDBYandSWITCHOVER_STATUS=PREPARING. It adopts the standby role only after its process is restarted. - On a standby that has caught up, execute
ALTER SYSTEM SWITCHOVER TO PRIMARYto promote it online to the new primary. - 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 item | Description | Default | Effective mode |
|---|---|---|---|
rpc_port | The RPC port used between the primary and standby. | 2882 | At startup |
enable_rpc_service | Whether to start the RPC service. Enable it on both the primary and standby. | false | After restart |
log_restore_source | The standby's upstream endpoint in IP:RPC_PORT format. | Empty | Dynamic |
log_disk_size | The upper limit on redo log disk usage. In primary/standby mode, OBD configures this value to three times memory_budget. | 0 | Dynamic |
log_disk_utilization_threshold | The disk utilization threshold that triggers redo log recycling. | 0 | Dynamic |
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_SCNand 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.