Oracle 5.0 Reference Manual page 2587

Table of Contents

Advertisement

Mysqlnd replication and load balancing plugin (mysqlnd_ms)
/* Please do proper ROLLBACK in your code, don't just die */
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
}
if ($res = $mysqli->query(sprintf("/*%s*/SELECT COUNT(*) AS _num FROM test", MYSQLND_MS_LAST_USED_SWITC
$row = $res->fetch_assoc();
$res->close();
if ($row['_num'] > 1000) {
if (!$mysqli->query(sprintf("/*%s*/INSERT INTO events(task) VALUES ('cleanup')", MYSQLND_MS_LAST_USE
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
}
}
} else {
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
}
if (!$mysqli->query(sprintf("/*%s*/UPDATE log SET last_update = NOW()", MYSQLND_MS_LAST_USED_SWITCH))))
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
}
if (!$mysqli->query(sprintf("/*%s*/COMMIT", MYSQLND_MS_LAST_USED_SWITCH)))) {
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
}
$mysqli->close();
?>
Starting with PHP 5.4.0, the
mode, if the mode is set by API calls instead of using SQL statements such as
autocommit
AUTOCOMMIT=0. This makes it possible for the plugin to become transaction aware. In this case, you
do not need to use SQL hints.
If using PHP 5.4.0 or newer, API calls that enable
configuration option trx_stickiness=master, the plugin can automatically disable load balancing and
connection switches for SQL transactions. In this configuration, the plugin stops load balancing if
is disabled and directs all statements to the master. This prevents connection switches
autocommit
in the middle of a transaction. Once
statements again.
API based transaction boundary detection has been improved with PHP 5.5.0 and PECL/mysqlnd_ms
1.5.0 to cover not only calls to
mysqli_rollback.
Example 20.230. Transaction aware load balancing: trx_stickiness setting
{
"myapp": {
"master": {
"master_0": {
"host": "localhost",
"socket": "\/tmp\/mysql.sock"
}
},
"slave": {
"slave_0": {
"host": "127.0.0.1",
"port": "3306"
}
},
"trx_stickiness": "master"
}
}
Example 20.231. Transaction aware
<?php
library allows the plugin to monitor the status of the
mysqlnd
autocommit
is re-enabled, the plugin starts to load balance
autocommit
mysqli_autocommit
2567
mode, and when setting the plugin
but also mysqli_begin,
SET
and
mysqli_commit

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents