In OceanBase AI Database, the Leader handles read and write requests in transactions. Therefore, the distribution of Leaders across partitions determines how traffic is distributed across nodes.
Introduction to traffic
In an application architecture, a database system is responsible for data storage and query processing. The read and write requests from applications are referred to as database traffic. Database traffic can be categorized into write traffic, strong-consistency read traffic, and weak-consistency read traffic. Write traffic and strong-consistency read traffic are served by Leader replicas of OceanBase AI Database, while weak-consistency read traffic is served by both Leader and Follower replicas. ODP provides routing capabilities for database traffic. It implements a simple SQL parser module that extracts the database name, table name, and hints from SQL statements. Based on the business SQL, routing rules, and the status of OBServer nodes, ODP selects the most appropriate OBServer node to forward the request.
Introduction to Primary Zone
Traffic distribution is described using Primary Zones. A Primary Zone specifies the preferred location for Leader replicas. Since Leader replicas handle strong-consistency read and write traffic for the business, the Primary Zone essentially determines the traffic distribution in OceanBase AI Database. For example, if a table t1 has primary_zone="zone1", RootService will try to schedule the Leader of table t1 to zone1.
Note
Replicas describe data, whereas a Primary Zone describes the container that holds the data. The data under this container inherits the Leader preference location described by the container's Primary Zone attribute. The current version of OceanBase AI Database supports only tenant-level Primary Zones.
The Primary Zone is essentially a list of Zones, where each Zone has a priority. The priorities are configured as follows:
When the Primary Zone list contains multiple Zones, they are separated by semicolons (;) to indicate a priority from high to low. Zones separated by commas (,) have the same priority, indicating that traffic is distributed across multiple Zones, and these Zones provide services simultaneously.
For example: 'hz1;hz2' indicates hz1 has a higher priority than hz2.
OceanBase AI Database currently supports only tenant-level Primary Zones. If you do not specify primary_zone when you create a tenant, the default value is RANDOM, which indicates that all Zones have the same priority.
You can view the Primary Zone attribute of a tenant in the PRIMARY_ZONE field of the oceanbase.DBA_OB_TENANTS view in the sys tenant. Here is an example:
obclient> SELECT * FROM oceanbase.DBA_OB_TENANTS limit 10\G
The query result is as follows:
*************************** 1. row ***************************
TENANT_ID: 1
TENANT_NAME: sys
TENANT_TYPE: SYS
CREATE_TIME: 2026-08-06 16:15:04.016965
MODIFY_TIME: 2026-08-06 16:15:04.016965
PRIMARY_ZONE: RANDOM
LOCALITY: FULL{1}@zone1, FULL{1}@zone2
PREVIOUS_LOCALITY: NULL
COMPATIBILITY_MODE: MYSQL
STATUS: NORMAL
IN_RECYCLEBIN: NO
LOCKED: NO
TENANT_ROLE: PRIMARY
SWITCHOVER_STATUS: NORMAL
SWITCHOVER_EPOCH: 0
SYNC_SCN: NULL
REPLAYABLE_SCN: NULL
READABLE_SCN: NULL
RECOVERY_UNTIL_SCN: NULL
LOG_MODE: NOARCHIVELOG
ARBITRATION_SERVICE_STATUS: DISABLED
UNIT_NUM: 1
ZONE_UNIT_NUM_LIST: zone1:1,zone2:1
COMPATIBLE: 4.6.2.0
MAX_LS_ID: 1001
RESTORE_DATA_MODE: NORMAL
FLASHBACK_LOG_SCN: NULL
COMMENT: system tenant
PROTECTION_MODE: NULL
PROTECTION_LEVEL: NULL
*************************** 2. row ***************************
TENANT_ID: 1001
TENANT_NAME: META$1002
TENANT_TYPE: META
CREATE_TIME: 2026-08-06 17:44:25.713748
MODIFY_TIME: 2026-08-06 17:45:37.488885
PRIMARY_ZONE: RANDOM
LOCALITY: FULL{1}@zone1, FULL{1}@zone2
PREVIOUS_LOCALITY: NULL
COMPATIBILITY_MODE: MYSQL
STATUS: NORMAL
IN_RECYCLEBIN: NO
LOCKED: NO
TENANT_ROLE: PRIMARY
SWITCHOVER_STATUS: NORMAL
SWITCHOVER_EPOCH: 0
SYNC_SCN: NULL
REPLAYABLE_SCN: NULL
READABLE_SCN: NULL
RECOVERY_UNTIL_SCN: NULL
LOG_MODE: NOARCHIVELOG
ARBITRATION_SERVICE_STATUS: DISABLED
UNIT_NUM: 1
ZONE_UNIT_NUM_LIST: zone1:1,zone2:1
COMPATIBLE: 4.6.2.0
MAX_LS_ID: 1002
RESTORE_DATA_MODE: NORMAL
FLASHBACK_LOG_SCN: NULL
COMMENT:
PROTECTION_MODE: NULL
PROTECTION_LEVEL: NULL
*************************** 3. row ***************************
TENANT_ID: 1002
TENANT_NAME: mysql123
TENANT_TYPE: USER
CREATE_TIME: 2026-08-06 17:44:25.721861
MODIFY_TIME: 2026-08-06 17:45:38.824939
PRIMARY_ZONE: RANDOM
LOCALITY: FULL{1}@zone1, FULL{1}@zone2
PREVIOUS_LOCALITY: NULL
COMPATIBILITY_MODE: MYSQL
STATUS: NORMAL
IN_RECYCLEBIN: NO
LOCKED: NO
TENANT_ROLE: PRIMARY
SWITCHOVER_STATUS: NORMAL
SWITCHOVER_EPOCH: 0
SYNC_SCN: 1786009750425008000
REPLAYABLE_SCN: 1786009750425008000
READABLE_SCN: 1786009750425008000
RECOVERY_UNTIL_SCN: 4611686018427387903
LOG_MODE: NOARCHIVELOG
ARBITRATION_SERVICE_STATUS: DISABLED
UNIT_NUM: 1
ZONE_UNIT_NUM_LIST: zone1:1,zone2:1
COMPATIBLE: 4.6.2.0
MAX_LS_ID: 1003
RESTORE_DATA_MODE: NORMAL
FLASHBACK_LOG_SCN: NULL
COMMENT:
PROTECTION_MODE: MAXIMUM PERFORMANCE
PROTECTION_LEVEL: MAXIMUM PERFORMANCE
3 rows in set
In the current version, you can also configure the Leader of a log stream to be distributed across secondary Primary Zones. That is, when the first-priority Zone fails, the Leader of the log stream is evenly distributed across the Zones with the next priority level in the PRIMARY_ZONE attribute.
Notice
If the number of Zones in the second-priority PRIMARY_ZONE is different from that in the first-priority PRIMARY_ZONE, the Leader of the log stream may not be evenly distributed across the Zones in the second-priority PRIMARY_ZONE.
Region attribute
In OceanBase AI Database, each Zone has a Region attribute (the REGION field in the DBA_OB_ZONES view), which indicates the region where the Zone is located. Each Zone can be configured with only one Region, but a Region can contain multiple Zones. The setting of the Primary Zone implicitly includes the preferred Region of the Leader. Specifically, when you set the Primary Zone, it has two layers of semantics:
The specified Primary Zone indicates the Region of the Zone preferred by the Leader.
The Region where the specified Primary Zone is located is the preferred Region of the Leader.
Specifically, the Leader is preferentially scheduled to the Zone with the highest priority. If the replica in the Zone with the highest priority cannot become the Leader, another Zone in the same Region is preferentially selected as the Leader location, so that business access to OceanBase AI Database does not cross cities whenever possible.