PECL/mysqlnd_ms is now transaction aware,
sometimes. A new experimental configuration option
trx_stickiness=master
disables load balancing if
autocommit
mode is turned off via API. This makes
the mysqlnd
library plugin transaction safe. Unfortunately it requires PHP
5.3.99 and, it can be fooled by using SQL to control
autocommit
. It requires some discipline to use.
Past and today: SQL hints for transactions
By default the PHP replication and load balancing plugin (mysqlnd_ms) is not transaction safe, because it is not transaction aware. The plugin does not know when a transaction starts and when it ends. Thus, it may decide to load balance statements and switch connections in the middle of a transaction. So far, SQL hints have been the only way to prevent …
[Read more]