44
Installing/Configuring
436
and every operation that changes the state of the global transaction itself (started, committed, rolled back,
errors and aborts), the addition of participants (host, optionally user and password required to connect) and
any changes to a participants state. Please note, depending on configuration and your security policies,
these recordings may be considered sensitive. It is therefore recommended to restrict access to the state
store. Unless the state store itself becomes overloaded, writing the state information may contribute
noteworthy to the runtime but should overall be only a minor factor.
It is possible that the effort it takes to implement your own routines for handling XA transactions that failed
during the second commit phase exceeds the benefits of using the XA feature of PECL/mysqlnd_ms in
the first place. Thus, the manual focussed on using the built-on garbage collection only.
Garbage collection can be triggered manually or automatically in the background. You may want to call
mysqlnd_ms_xa_gc immediately after a commit failure to attempt to solve any failed but still open global
transactions as soon as possible. You may also decide to disable the automatic background garbage
collection, implement your own rule set for invoking the built-in garbage collection and trigger it when
desired.
By default the plugin will start the garbage collection with a certain probability in the extensions internal
RSHUTDOWN method. The request shutdown is called after your script finished. Whether the garbage
collection will be triggered is determined by computing a random value between 1...1000 and comparing
it with the configuration setting probability (default: 5). If the setting is greater or equal to the random
value, the garbage collection will be triggered.
Once started, the garbage collection acts upon up to max_transactions_per_run (default: 100) global
transactions recorded. Records include successfully finished but also unfinished XA transactions. Records
for successful transactions are removed and unfinished transactions are attempted to be solved. There
are no statistics that help you finding the right balance between keeping garbage collection runs short by
limiting the number of transactions considered per run and preventing the garbage collection to fall behind,
resulting in many records.
For each failed XA transaction the garbage collection makes max_retries (default: 5) attempts to finish
it. After that PECL/mysqlnd_ms gives up. There are two possible reasons for this. Either a participating
server crashed and has not become accessible again within max_retries invocations of the garbage
collection, or there is a situation that the built-in garbage collection cannot cope with. Likely, the latter
would be considered a bug. However, you can manually force more garbage collection runs calling
mysqlnd_ms_xa_gc with the appropriate parameter set. Should even those function runs fail to solve the
situation, then the problem must be solved by an operator.
The function mysqlnd_ms_get_stats provides some statistics on how many XA transactions have been
started, committed, failed or rolled back.
7.6 Installing/Configuring
Copyright 1997-2014 the PHP Documentation Group.
7.6.1 Requirements
Copyright 1997-2014 the PHP Documentation Group.
PHP 5.3.6 or newer. Some advanced functionality requires PHP 5.4.0 or newer.
The mysqlnd_ms replication and load balancing plugin supports all PHP applications and all available
PHP MySQL extensions (mysqli, mysql, PDO_MYSQL). The PHP MySQL extension must be configured to
use mysqlnd in order to be able to use the mysqlnd_ms plugin for mysqlnd.