The PHP
replication and load balancing plugin has a configuration setting to run all transactions on
the master. But how to detect the start of a transaction? I got a
hint to look at a flag in the client-server protocol which tells
us, if we are in a transaction. I was not aware of the flag and,
I loved the idea when I heard it. The plugin wouldn’t have to
worry about how the client starts a transaction. A PHP client can
start a transaction by turning off autocommit via API (e.g.
mysqli_autocommit()
) or executing SQL
(BEGIN
, START TRANSACTION
, SET
AUTOCOMMIT=0
). It is time consuming to catch them all, if
possible at all.
Server status flag from the protocol
I hacked mysqlnd to print …
[Read more]