Bug #38238 "Connect failed: Lost connection to MySQL server during query" in rw-splitting
Submitted: 19 Jul 2008 3:48 Modified: 18 Oct 2008 21:22
Reporter: Liew Soo Hung Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Proxy: Scripts Severity:S1 (Critical)
Version:0.6.1 OS:Other (CentOS 5)
Assigned to: CPU Architecture:Any
Tags: Connect failed, mysql proxy

[19 Jul 2008 3:48] Liew Soo Hung
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.
[18 Sep 2008 21:22] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior in my environment. Could you please provide MySQL Proxy output?
[18 Oct 2008 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".