Description:
Hi,
I run the mysql-proxy with the following commands:
# LUA_PATH="/usr/bin/?.lua" mysql-proxy --proxy-lua-script=/usr/bin/rw-splitting.lua --proxy-address=[IP Server A]:3306 --proxy-backend-addresses=[IP Server A]:3307 --proxy-read-only-backend-addresses=[IP Server B]:3306 --proxy-read-only-backend-addresses=[IP Server C]:3306 &
Then I test it with my php script in internet browser, then after i refresh my php script in internet browser for several times, it shows the error. After the error, i refresh again, it can load the page without any error, then i refresh again, it shows the error again, then i fresh again, it can load the page without any error, ......this situation is just like looping between the "load with error" and "load without error" which after the first occurrence of the error.
1.) The error
Warning: mysqli::mysqli() [function.mysqli-mysqli]: (HY000/2013): Lost connection to MySQL server during query in C:\Inetpub\wwwroot\test.php on line 7
Connect failed: Lost connection to MySQL server during query
2.) My php script
<?php
/* let browser keep no cache */
# header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
/* connect to MySQL server and database */
$mysqli = new mysqli("[host]", "[user]", "[password]", "[database]","[port]");
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* execute query */
$query = "select * from tb1";
if ($result = $mysqli->query($query))
{
/* show result in table format */
print "<table border = '1'>";
/* fetch associative array */
while ($row = $result->fetch_assoc())
{
print "<tr><td><b>User ID</b></td><td>".$row["user_id"]."</td></tr>";
print "<tr><td><b>User Name</b></td><td>".$row["user_name"]."</td></tr>";
}
print "</table>";
/* free result set */
$result->close();
}
/* close connection */
$mysqli->close();
?>
Anyone have encounter this error before and how to fix this?
How to repeat:
1.) Start the mysql-proxy with the following commands:
# LUA_PATH="/usr/bin/?.lua" mysql-proxy --proxy-lua-script=/usr/bin/rw-splitting.lua --proxy-address=[IP]:3306 --proxy-backend-addresses=[IP]:3307 --proxy-read-only-backend-addresses=[IP]:3306 --proxy-read-only-backend-addresses=[IP]:3306 &
2.) Browse the PHP script in Internet browser.
3.) Refresh the Internet browser page for several times.