Kelvin
Kelvin

Reputation: 11

phpMyAdmin replication error: ./libraries/dbi/DBIMysqli.class.php#298

Just set up binary log replication between a mysql 5.7 master running in ubuntu 16.04 and a MariaDB 10.0.28 slave running on my Asustor NAS AS204-TE.

After a few attempts replication is working without issue however my only worry are two error messages phpmyadmin shows when I click into the 'Replication' view from the main page...

Error 1:

Warning in ./libraries/dbi/DBIMysqli.class.php#298
 mysqli_fetch_array(): Malformed server packet. Field length pointing 0 bytes after end of packet

Backtrace

./libraries/dbi/DBIMysqli.class.php#298: mysqli_fetch_array(
object,
integer 1,
)
./libraries/DatabaseInterface.class.php#2760: PMA_DBI_Mysqli->fetchAssoc(object)
./libraries/DatabaseInterface.class.php#2069: PMA_DatabaseInterface->fetchAssoc(object)
./libraries/replication_gui.lib.php#612: PMA_DatabaseInterface->fetchResult(
string 'SHOW SLAVE HOSTS',
NULL,
NULL,
)
./libraries/replication_gui.lib.php#56: PMA_getHtmlForReplicationSlavesTable(boolean true)
./server_replication.php#56: PMA_getHtmlForMasterReplication()

Error 2:

Warning in ./libraries/dbi/DBIMysqli.class.php#298
 mysqli_fetch_array(): Error while reading a row

Backtrace

./libraries/dbi/DBIMysqli.class.php#298: mysqli_fetch_array(
object,
integer 1,
)
./libraries/DatabaseInterface.class.php#2760: PMA_DBI_Mysqli->fetchAssoc(object)
./libraries/DatabaseInterface.class.php#2069: PMA_DatabaseInterface->fetchAssoc(object)
./libraries/replication_gui.lib.php#612: PMA_DatabaseInterface->fetchResult(
string 'SHOW SLAVE HOSTS',
NULL,
NULL,
)
./libraries/replication_gui.lib.php#56: PMA_getHtmlForReplicationSlavesTable(boolean true)
./server_replication.php#56: PMA_getHtmlForMasterReplication()

So following a little logic the error message seems to revolve around listing the slaves connecting to the master. So I click 'Ignore All' on the error and click the 'Show connected slaves' link which shows me nothing other than a tip to ensure "--report-host=xxx" is set on the slave. I've confirmed the mysql (MariaDB) instance is starting on the slave with the needed parameter and going into mysql via the commandline on the master and issuing a SHOW SLAVE HOSTS; gives me the following output...

mysql> show slave hosts;
+-----------+----------+------+-----------+------------+
| Server_id | Host     | Port | Master_id | Slave_UUID |
+-----------+----------+------+-----------+------------+
|         2 | blacknas | 3306 |         1 |            |
+-----------+----------+------+-----------+------------+
1 row in set (0.00 sec)

I'm not clear on what my next steps should be to further debug this so would appreciate any pointers?

Upvotes: 0

Views: 3956

Answers (1)

Kelvin
Kelvin

Reputation: 11

Okay so answering this myself as I get the impression the bug submission with PHP will take an age.

This is not a fault with phpMyAdmin but instead the error is being generated by the mysqli extension in PHP and can be reproduced using the below code (credit for the code snippet goes to nijel who picked up my issue on github)...

<?php
error_reporting(E_ALL);

$link = mysqli_connect("localhost", "my_user", "my_password");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "SHOW SLAVE HOSTS";
$result = mysqli_query($link, $query);

/* get associative array */
while (($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) !== null) {
    print_r($row);
}

/* free result set */
mysqli_free_result($result);

/* close connection */
mysqli_close($link);
?>

I believe the reason the the mysqli extension is complaining is because the command being issued should return 4 values but in my use case it only returns 3. This is because the MariaDB slave does not implement the server_uuid feature whereas its MySQL counterpart does. As a result the returned values from slave to guest are incomplete which is somewhat aligned to what the error messages are saying. The bug I've filed with PHP will hopefully clarify if the mysqli extension should tolerate these nuances better. As my replication use case is documented by the developers I would have thought it should but.

Anyways to somewhat prove my theory I created a test container, deployed the ubuntu lamp packages and phpmyadmin and recreated the scenario but using mysql for both master and slave. As server_uuid is implemented the 'SHOW SLAVE HOSTS;' command returns all 4 values and both the test script above as well as phpMyAdmin no longer whinge.

Replication is certainly working so this is more an annoyance which I'll live with.

Upvotes: 1

Related Questions