From 5f993f0b60eafa12d9e941997cfea319c608777d Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 3 Mar 2016 13:09:50 +0200 Subject: [PATCH] Updated documentation about multi-statements The readwritesplit documentation now explains the multi-statement behavior in more detail and provides information about situations where the default multi-statement behavior can be disabled. --- Documentation/About/Limitations.md | 2 ++ Documentation/Routers/ReadWriteSplit.md | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Documentation/About/Limitations.md b/Documentation/About/Limitations.md index be418ed87..a40bc0d2d 100644 --- a/Documentation/About/Limitations.md +++ b/Documentation/About/Limitations.md @@ -32,6 +32,8 @@ In master-slave replication cluster also read-only queries are routed to master * statement includes a stored procedure, or an UDF call +### Multi-statement limitations + If the client enables and executes multi-statements, they will be routed to the master. All future queries will also be routed to the master to guarantee a consistent session state after the multi-statement query. This behavior can diff --git a/Documentation/Routers/ReadWriteSplit.md b/Documentation/Routers/ReadWriteSplit.md index 8fca0a006..e99454d9e 100644 --- a/Documentation/Routers/ReadWriteSplit.md +++ b/Documentation/Routers/ReadWriteSplit.md @@ -173,6 +173,19 @@ In Master-Slave replication cluster also read-only queries are routed to master * statement includes a stored procedure, or an UDF call +* if there are multiple statements inside one query e.g. `INSERT INTO ... ; SELECT LAST_INSERT_ID();` + +### Limitations in multi-statement handling + +When a multi-statemet query is executed through the readwritesplit router, it will always +be routed to the master. With the default configuration, all queries after a +multi-statement query will be routed to the master to prevent possible reads of +false data. You can override this behavior with the `strict_multi_stmt=false` +router option. In this mode, the multi-statement queries will still be routed +to the master but individual statements are routed normally. If you use +multi-statements and you know they don't modify the session state in any +relevant way, you can disable this option for better performance. + ### Limitations in client session handling Some of the queries that client sends are routed to all backends instead of sending them just to one of server. These queries include `USE ` and `SET autocommit=0` among many others. Readwritesplit sends a copy of these queries to each backend server and forwards the master's reply to the client. Below is a list of MySQL commands which are classified as session commands :