|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-07-04 03:38 UTC] accounts at dotmanila dot com
Description:
------------
When using mysqlnd_ms after creating a new mysqli object and executing a ping, an error is returned like:
Connection to host 'primary' failed: [0] Commands out of sync; you can't run this command now
If mysqlnd_ms is disabled, this works well without errors.
mysqlnd => enabled
Version => mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $
Compression => supported
SSL => supported
Command buffer size => 4096
Read buffer size => 32768
Read timeout => 31536000
Collecting statistics => Yes
Collecting memory statistics => No
Tracing => n/a
Loaded plugins => mysqlnd,example,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password
API Extensions => mysql,mysqli,pdo_mysql
Test script:
---------------
When using mysqlnd_ms:
----------------------
-- INI file:
mysqlnd_ms.enable=1
mysqlnd_ms.force_config_usage = 1
mysqlnd_ms.config_file=mysqlnd_ms_ms.ini
-- mysqlnd_ms_ms.ini
{
"primary": {
"master": {
"master_1": {
"host": "127.0.0.1",
"port": "33001"
}
},
"slave": {
"slave_0": {
"host": "127.0.0.1",
"port": "33002"
}
}
}
}
<?php
$mysql_host = 'primary';
$mysqli = new mysqli($mysql_host, "msandbox", "msandbox", "test");
$t = $mysqli->ping();
if(!$t) {
printf("Connection to host '{$mysql_host}' failed: [%d] %s, retrying ($retries of 10) in 3 seconds\n",
$mysqli->connect_errno, $mysqli->error
);
}
?>
When using mysqlnd only:
----------------------
<?php
$mysql_host = '127.0.0.1:33001';
$mysqli = new mysqli($mysql_host, "msandbox", "msandbox", "test");
$t = $mysqli->ping();
if(!$t) {
printf("Connection to host '{$mysql_host}' failed: [%d] %s, retrying ($retries of 10) in 3 seconds\n",
$mysqli->connect_errno, $mysqli->error
);
}
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 12:00:01 2025 UTC |
I'd suspect the out of sync error means the actual connection to the server has not been established yet because mysqlnd_ms by default is lazy, to adhere more to the transparency feature of the plugin. One would have to execute something like below to actually create the connection: $mysqli->query('/*ms=master*/select 1'); $mysql->real_connect() at least should create the actual connection this as documented.