Mysqlnd replication and load balancing plugin (
mysqlnd_ms
)
2627
As of PHP 5.4.0 the mysqlnd library allows the plugin
to monitor the
autocommit
mode set by calls to
the libraries
set_autocommit()
function. If setting
set_stickiness=master
and
autocommit
gets disabled by
a PHP MySQL extension invoking the
mysqlnd
library internal
function call
set_autocommit()
, the plugin is made aware of the
begin of a transaction. Then, the plugin stops load balancing and
directs all statements to the master server until
autocommit
is
enabled. Thus, no SQL hints are required.
An example of a PHP MySQL API function calling the
mysqlnd
library internal function call
set_autocommit()
is
mysqli_autocommit
.
Although setting
trx_stickiness=master
, the plugin cannot
be made aware of
autocommit
mode changes caused by SQL
statements such as
SET AUTOCOMMIT=0
or
BEGIN
.
As of PHP 5.5.0, the mysqlnd library features additional C API
calls to control transactions. The level of control matches the one
offered by SQL statements. The
mysqli
API has been modified
to use these calls. Since version 1.5.0, PECL/mysqlnd_ms can
monitor not only
mysqli_autocommit
, but also
mysqli_begin
,
mysqli_commit
and
mysqli_rollback
to detect transaction
boundaries and stop load balancing for the duration of a transaction.
Example 20.290. Using master to execute transactions
{
"myapp": {
"master": {
"master_0": {
"host": "localhost"
}
},
"slave": {
"slave_0": {
"host": "192.168.78.136",
"port": "3306"
}
},
"trx_stickiness": "master"
}
}
Since version 1.5.0 automatic and silent failover is disabled for
the duration of a transaction. If the boundaries of a transaction
have been properly detected, transaction stickiness is enabled
and a server fails, the plugin will not attempt to fail over to the next
server, if any, regardless of the failover policy configured. The user
must handle the error manually. Depending on the configuration,
the plugin may emit an error of type
E_WARNING
reading like
(mysqlnd_ms) Automatic failover is not permitted
in the middle of a transaction
. This error may then
be overwritten by follow up errors such as
(mysqlnd_ms) No
connection selected by the last filter
. Those errors
will be generated by the failing query function.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...