PolarDB supports transaction splitting. This feature ensures data consistency in a session and allows PolarDB to send read requests to read-only nodes to reduce the loads on the primary node.

Background

If you use a PolarDB cluster endpoint in read/write mode, the proxy forwards read and write requests to the primary node and read-only nodes. To ensure data consistency of transactions in a session, the proxy sends all requests in transactions of the session to the primary node. For example, database client drivers, such as the Java Database Connectivity (JDBC), encapsulate requests in a transaction. In this case, all requests from applications are sent to the primary node. This results in heavy loads on the primary node. However, no request is sent to read-only nodes, as shown in the following figure.

Without transaction splitting

To fix this issue, PolarDB supports the transaction splitting feature. This feature ensures data consistency in a session and allows PolarDB to send read requests to read-only nodes to reduce the loads on the primary node.

Features

The proxy sends read requests that are received before the first write request in a transaction to read-only nodes. This reduces the loads on the primary node. The uncommitted data in transactions cannot be queried from read-only nodes. Therefore, to ensure data consistency in transactions, all read and write requests that are received after the first write request are still forwarded to the primary node. To enable basic transaction splitting, see Manage a cluster endpoint. Basic transaction splitting

Benefits

This feature allows you to reduce the read loads on the primary node without the need to modify the code or configurations of your applications. This improves the stability of the primary node.

Considerations

  • Only transactions that use the Read Committed isolation level can be split.
  • If you enable basic transaction splitting and the consistency level is not set to eventual consistency, the proxy sends the read requests that are received before the first write request in a transaction to read-only nodes only after read-only nodes synchronize all data from the primary node. Otherwise, the proxy still sends read requests to the primary node. For more information about consistency levels, see Consistency levels.