Features and Limitations
Implementation Principle
The text describes the architecture of a Read-Write separation middleware, composed of multiple high-performance proxy nodes and Surfercloud's distributed load balancing product, ULB. Clients can customize the distribution of read requests, and the proxy nodes distribute these requests based on the client's configuration. The middleware's approach to handling business requests is straightforward and is based on three basic principles.
For a more detailed explanation and full description of these principles, you would need to refer to the relevant technical documentation or source material.
- Identifying 'Select' SQL statements from business requests, as only these are considered for Read-Write separation.
- Directing 'Select' SQL within a transaction to the primary node, while those outside a transaction are distributed to either the primary or secondary nodes based on the read request distribution strategy.
- Broadcasting certain statements, like 'Use database' or 'Set Session' variables, to ensure data consistency across nodes. If broadcasting fails, the client connection is interrupted.
And adjustments for certain special cases:
- SQL statements involving locks, such as "Select For Update" or "Select Lock," are directed to the primary node.
- "Set" statements are categorized into three types: Session, Global, and User. Statements setting Session and User variables are broadcasted, while due to data consistency concerns, "Set Global" statements are only sent to the primary node. Consequently, Select statements containing global variables are also directed to the primary node.
Features and Limitations
1.MySQL Protocol Limitations
- Lack of support for SSL encryption.
- Temporary absence of support for compressed protocols.
- Current unavailability of XA transactions.
2.SQL Limitations
-
Support for 'savepoint' statements (directed to the primary node) but not 'rollback to savepoint'.
-
No support for XA transaction commands.
-
'Lock Tables/Unlock Tables' statements are sent to the primary node, without affecting the proxy layer or secondary nodes.
-
Stored procedures and subsequent 'Select' statements are routed to the primary node.
call udb\_test('000001',@pp,@qq); select @pp,@qq; select \* from t1;
-
Commands like 'show processlists', 'Show master/slave status', 'kill query', 'COM_PROCESS_INFO', and 'COM_STATISTICS' are currently only forwarded to the primary node, with more system management commands under development.
-
Protocols 'COM_TABLE_DUMP' and 'COM_CHANGE_USER' are not supported.
-
Following the execution of Multi-Statement SQL commands, all subsequent requests in the current connection are routed to the primary node, requiring reconnection to restore Read-Write separation.
Special Note on Set Statements
-
Set Session' and 'Set User' variable statements are broadcasted to both primary and secondary nodes. If broadcasting fails, the proxy disconnects from the client to avoid data inconsistency. 'Set global' variable statements are only sent to the primary node, as are subsequent 'Select' statements containing global variables.
-
A single 'Set' statement cannot simultaneously include global and session/user variables.
-
The system does not support 'set sql_mode' values that are expressions.
-
The syntax for setting multiple variables in one 'Set' statement is not supported.
-
The system currently does not support MySQL 8.0's 'caching_sha2_password' encryption algorithm. If a client uses this algorithm, the proxy coordinates to use 'mysql_native_password' instead.
Scenarios Where Read-Write Separation is Not Recommended
-
All business SQL statements are transactional (all SQL statements are included within a transaction). Since transactions can only be routed to the master node, in this scenario, UDB Read-Write separation cannot effectively separate read requests.
-
The business extensively uses stored procedures. Since stored procedures can only be routed to the master node, in this scenario, UDB Read-Write separation cannot effectively separate read requests.