For some exceptional reasons, the quorum size (paxos_replica_num) of a log stream may not match the number of full-featured replicas in the tenant's locality. You can manually adjust the log stream's quorum size using the ALTER SYSTEM MODIFY command.
Limitations
You can modify the quorum size of log streams of all tenants in the
systenant but modify only the quorum size of log streams of the current tenant in a user tenant.For the same log stream in a tenant, multiple replica migration tasks can be performed in parallel, but other disaster recovery tasks (such as adding replicas, reducing replicas, and modifying the quorum size of the log stream) can be performed only one at a time.
You can query ongoing replica tasks from the
CDB_OB_LS_REPLICA_TASKSview in thesystenant or from theDBA_OB_LS_REPLICA_TASKSview in a user tenant.Currently, you can only manually reduce the value of
paxos_replica_num. Increasing the value manually is not supported.
Prerequisites
Before modifying the quorum size of a log stream leader, make sure that the current user has the
ALTER SYSTEMprivilege. Otherwise, theALTER SYSTEM MODIFYstatement cannot be executed.Before querying a view, make sure that the current user has the
SELECTprivilege on the following views. Otherwise, the relevant information cannot be queried.DBA_OB_TENANTSDBA_OB_LS/CDB_OB_LSDBA_OB_LS_LOCATIONS/CDB_OB_LS_LOCATIONS
Procedure
Assume that log stream 1002 of a tenant named tenant1 has two full-featured replicas but the value of paxos_replica_num is 3. In this case, you can change the value to 2 so that it is consistent with the number of full-featured replicas in the locality of the tenant.
Log in to the target tenant.
Here is an example:
obclient -h172.30.xxx.xxx -P2883 -uroot@tenant1#obdemo -pxxxx -AFor more information about how to connect to a database, see Overview of connection methods.
Query the tenant ID of the target tenant.
System tenant
obclient(root@sys)[oceanbase]> SELECT TENANT_NAME,TENANT_ID FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME='tenant1';User tenant
Execute the following statement:
obclient(root@tenant1)[oceanbase]> SELECT TENANT_NAME, TENANT_ID FROM oceanbase.DBA_OB_TENANTS;Here is an example of the query result:
+-------------+-----------+ | TENANT_NAME | TENANT_ID | +-------------+-----------+ | tenant1 | 1002 | +-------------+-----------+ 1 row in setThe query result shows that the tenant ID is
1002.For more information about the fields in the
DBA_OB_TENANTSview, see DBA_OB_TENANTS.
Query all log streams of the target tenant.
System tenant
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS WHERE TENANT_ID=1002;For more information about the fields in the
CDB_OB_LSview, see CDB_OB_LS.User tenant
Execute the following statement:
obclient(root@tenant1)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS;Here is an example of the query result:
+-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+----------------+ | LS_ID | STATUS | PRIMARY_ZONE | UNIT_GROUP_ID | LS_GROUP_ID | CREATE_SCN | DROP_SCN | SYNC_SCN | READABLE_SCN | FLAG | UNIT_LIST | +-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+----------------+ | 1 | NORMAL | z1;z2 | 0 | 0 | NULL | NULL | 1712455113896017202 | 1712455113896017202 | | | | 1001 | NORMAL | z1;z2 | 0 | 1001 | 1712125812893680165 | NULL | 1712455113896017202 | 1712455113896017202 | | 1002,1004,1006 | | 1002 | NORMAL | z1;z2 | 0 | 1002 | 1712125812908098857 | NULL | 1712455114041323052 | 1712455113540551113 | | 1001,1003,1005 | | 1003 | NORMAL | z1;z2 | 0 | 0 | 1712125828880850585 | NULL | 1712455113896017202 | 1712455113896017202 | DUPLICATE | | +-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+----------------+ 4 rows in setThe query result shows that the
tenant1tenant has log streams1,1001, and1002, as well as broadcast log stream1003.For more information about the fields in the
DBA_OB_LSview, see DBA_OB_LS.
Query the replica distribution of each log stream.
The following example queries the replica distribution and the
paxos_replica_numvalue of log stream1002.System tenant
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_LOCATIONS WHERE LS_ID=1002 AND TENANT_ID=1002;For more information about the fields in the
CDB_OB_LS_LOCATIONSview, see CDB_OB_LS_LOCATIONS.User tenant
Execute the following statement:
obclient(root@tenant1)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;Here is an example of the query result:
+----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+--------------------------------------------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ | CREATE_TIME | MODIFY_TIME | LS_ID | SVR_IP | SVR_PORT | SQL_PORT | ZONE | ROLE | MEMBER_LIST | PAXOS_REPLICA_NUMBER | REPLICA_TYPE | LEARNER_LIST | REBUILD | +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+--------------------------------------------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ | 2024-01-31 16:50:06.856652 | 2024-01-31 16:52:54.618093 | 1002 | 100.xx.xxx.012 | 5070 | 5105 | z1 | LEADER | 100.xx.xxx.012:5070:1,100.xx.xxx.003:5073:1706691171162545 | 3 | FULL | | FALSE | | 2024-01-31 16:52:51.216095 | 2024-01-31 16:52:57.135393 | 1002 | 100.xx.xxx.003 | 5073 | 5108 | z2 | FOLLOWER | NULL | NULL | FULL | | FALSE | +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+--------------------------------------------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ 2 rows in setThe query result shows that log stream
1002has two full-featured replicas but itsPAXOS_REPLICA_NUMBERvalue is3. You must change thePAXOS_REPLICA_NUMBERvalue to2.
Execute the
ALTER SYSTEM MODIFYstatement to modify thepaxos_replica_numvalue.The statement is as follows:
ALTER SYSTEM MODIFY LS [=] ls_id PAXOS_REPLICA_NUM [=] paxos_replica_num [TENANT [=] 'tenant_name'];The statement is used as follows:
ls_id: specifies the ID of the log stream to be modified.paxos_replica_num: specifies the quorum size of the log stream after the modification, which is the number of full-featured (F) replicas in the locality of the tenant.When you specify this value, take note of the following considerations:
The value of
paxos_replica_nummust be greater than or equal to the number of members in theMEMBER_LISTof the leader replica. You can query theMEMBER_LISTfrom theCDB_OB_LS_LOCATIONSview in thesystenant or from theDBA_OB_LS_LOCATIONSview in a user tenant.You can only decrease the value of
paxos_replica_num, and the decrease cannot exceed 1. In this example, you can only change the value to2.
If any one of the preceding conditions is not met, the system will return an error.
tenant_name: specifies the tenant to be operated on. You can specify another tenant in thesystenant and specify only the current tenant in a user tenant. If you do not explicitly specify the tenant, the default tenant name is the current tenant. This statement does not support usingall,all_user,all_meta, and so on, to specify all tenants, user tenants, or all Meta tenants.
Here is an example:
obclient> ALTER SYSTEM MODIFY LS = 1002 paxos_replica_num = 2;After the execution is successful, query the replica distribution of the log stream again.
System tenant
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_LOCATIONS WHERE LS_ID=1002 AND TENANT_ID=1002;User tenant
Execute the following statement:
obclient(root@tenant1)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;Here is an example of the query result:
+----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+--------------------------------------------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ | CREATE_TIME | MODIFY_TIME | LS_ID | SVR_IP | SVR_PORT | SQL_PORT | ZONE | ROLE | MEMBER_LIST | PAXOS_REPLICA_NUMBER | REPLICA_TYPE | LEARNER_LIST | REBUILD | +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+--------------------------------------------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ | 2024-01-31 16:50:06.856652 | 2024-01-31 16:52:54.618093 | 1002 | 100.xx.xxx.012 | 5070 | 5105 | z1 | LEADER | 100.xx.xxx.012:5070:1,100.xx.xxx.003:5073:1706691171162545 | 2 | FULL | | FALSE | | 2024-01-31 16:52:51.216095 | 2024-01-31 16:52:57.135393 | 1002 | 100.xx.xxx.003 | 5073 | 5108 | z2 | FOLLOWER | NULL | NULL | FULL | | FALSE | +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+--------------------------------------------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ 2 rows in setThe query result shows that the
PAXOS_REPLICA_NUMBERvalue of log stream1002is changed to2.