Transaction routing by ODP
OceanBase Database Proxy (ODP) supports two routing modes. In one mode, ODP routes statements in the same transaction to the same OBServer node for execution. In the other mode, ODP routes statements in a transaction to different OBServer nodes and synchronizes the status of the transaction on these nodes to implement distributed execution of the transaction. This topic describes how ODP implements distributed execution of a transaction. The OB 2.0 protocol is used to synchronize the transaction status.
Select nodes for transaction routing
Two types of nodes are available for transaction routing: coordinator and participant. The coordinator node is the node that starts the transaction. It executes non-DML statements that affect the transaction status, such as BEGIN,START TRANSACTION, COMMIT, and ROLLBACK. The participant nodes execute DML statements that do not affect the transaction status. ODP comprises a simple SQL parser that parses whether an SQL statement is a DML statement. For a DML statement, ODP routes the statement to proper nodes based on table routing or logical data center (LDC)-based routing. The routed-to nodes are participant nodes of the transaction. The coordinator node executes the first statement in the transaction.
Configure transaction routing
By default, transaction routing is enabled. You can execute the following statements to query whether transaction routing is enabled and configure transaction routing.
Log on to the sys tenant as the root user.
Check and modify the configuration of the OB 2.0 protocol to ensure that the protocol is enabled.
obclient> SHOW PROXYCONFIG LIKE enable_ob_protocol_v2; obclient> ALTER PROXYCONFIG SET enable_ob_protocol_v2=True;Execute the following statement to configure transaction routing for ODP:
obclient> SHOW PROXYCONFIG LIKE enable_transaction_internal_routing; obclient> ALTER PROXYCONFIG SET enable_transaction_internal_routing=True;