php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67564 mysqli::ping mysqlnd_ms return Out of sync error
Submitted: 2014-07-04 03:38 UTC Modified: 2021-09-14 12:45 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: accounts at dotmanila dot com Assigned:
Status: Suspended Package: mysqlnd_ms (PECL)
PHP Version: 5.4.30 OS: CentOS 6.5
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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
  );
}
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-04 05:09 UTC] accounts at dotmanila dot com
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.
 [2021-09-14 12:45 UTC] cmb@php.net
-Status: Open +Status: Suspended -Package: MySQLi related +Package: mysqlnd_ms
 [2021-09-14 12:45 UTC] cmb@php.net
The mysqlnd_ms package is no longer maintained; I suspend this
ticket until a new maintainer steps up.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 08:01:29 2024 UTC