Mysqlnd replication and load balancing plugin (
mysqlnd_ms
)
2618
exactly one node for statement execution. A multi filter is typically
placed at the top of the filter chain. The
quality_of_service
filter is another example of a multi filter.
The return value of the callback set for
user_multi
must be an an
array with two elements. The first element holds a list of selected
master servers. The second element contains a list of selected
slave servers. The lists shall contain the keys of the slave and
master servers as found in the slave and master lists passed to the
callback. The below example returns random master and slave lists
extracted from the functions input.
Example 20.282. Returning random masters and slaves
<?php
function pick_server($connected, $query, $masters, $slaves, $last_used_connection, $in_transaction)
{
$picked_masters = array()
foreach ($masters as $key => $value) {
if (mt_rand(0, 2) > 1)
$picked_masters[] = $key;
}
$picked_slaves = array()
foreach ($slaves as $key => $value) {
if (mt_rand(0, 2) > 1)
$picked_slaves[] = $key;
}
return array($picked_masters, $picked_slaves);
}
?>
The plugin will issue an error of type
E_RECOVERABLE
if
the callback fails to return a server list. The error may read
(mysqlnd_ms) User multi filter callback has not
returned a list of servers to use. The callback
must return an array in %s on line %d
. In case the
server list is not empty but has invalid servers key/ids in it, an error
of type
E_RECOVERABLE
will the thrown with an error message
like
(mysqlnd_ms) User multi filter callback has
returned an invalid list of servers to use. Server
id is negative in %s on line %d
, or similar.
Whether an error is emitted in case of an empty slave or master list
depends on the configuration. If an empty master list is returned for
a write operation, it is likely that the plugin will emit a warning that
may read
(mysqlnd_ms) Couldn't find the appropriate
master connection. 0 masters to choose from.
Something is wrong in %s on line %d
. Typically a follow
up error of type
E_ERROR
will happen. In case of a read operation
and an empty slave list the behavior depends on the fail over
configuration. If fail over to master is enabled, no error should
appear. If fail over to master is deactivated the plugin will emit a
warning that may read
(mysqlnd_ms) Couldn't find the
appropriate slave connection. 0 slaves to choose
from. Something is wrong in %s on line %d
.
Filter:
node_groups
object
The
node_groups
filter lets you group cluster nodes and query
selected groups, for example, to support data partitioning. Data
partitioning can be required for manual sharding, primary copy
based clusters running multiple masters, or to avoid hot spots in
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...