Bug #58591 [network-mysqld.c:937]: error on a connection (fd: -1 event: 0). closing client
Submitted: 30 Nov 2010 15:32 Modified: 3 Dec 2010 2:59
Reporter: david nick Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Proxy: Scripts Severity:S3 (Non-critical)
Version:0.8.1 OS:Linux (Centos5)
Assigned to: CPU Architecture:Any
Tags: mysql-proxy rw-splitting

[30 Nov 2010 15:32] david nick
Description:
I use the official mysql-proxy Linux ver. .3.glibc2 (x86, 64-bit), Compressed TAR Archive:
mysql-proxy 0.8.1
  chassis: mysql-proxy 0.8.1
  glib2: 2.16.6
  libevent: 1.4.13-stable
  LUA: Lua 5.1.4
    package.path: /usr/local/mysql-proxy/lib/mysql-proxy/lua/?.lua;
    package.cpath: /usr/local/mysql-proxy/lib/mysql-proxy/lua/?.so;
-- modules
  admin: 0.8.1
  proxy: 0.8.1

Percona-server: Ver 14.14 Distrib 5.1.51

start the server by:

/usr/local/mysql-proxy/bin/mysql-proxy --daemon \
--admin-username=root \
--admin-password=root \
--admin-address=:4401 \
--proxy-address=:3307 \
--proxy-backend-addresses=192.168.0.2:3306 \
--proxy-read-only-backend-addresses=:3306 \
--log-level=debug \
--log-file=/var/log/mysql-proxy.log \
--keepalive \
--admin-lua-script=/usr/local/mysql-proxy/share/admin-sql.lua \
--proxy-lua-script=/usr/local/mysql-proxy/share/rw-splitting.lua

when i use php to connect the proxy it works like this:

2010-11-30 23:27:05: (debug) unix-daemon.c:121: we are the child: 9411
2010-11-30 23:27:05: (message) mysql-proxy 0.8.1 started
2010-11-30 23:27:05: (debug) max open file-descriptors = 51200
2010-11-30 23:27:05: (message) proxy listening on port :3307
2010-11-30 23:27:05: (message) added read/write backend: 121.9.209.118:3306
2010-11-30 23:27:05: (message) added read-only backend: :3306
2010-11-30 23:27:05: (message) unix-daemon.c:136: [angel] we try to keep PID=9411 alive
2010-11-30 23:27:05: (debug) unix-daemon.c:157: waiting for 9411
2010-11-30 23:27:07: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:07: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:09: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:09: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:10: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:10: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:11: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:11: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:12: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:12: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:14: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:14: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:15: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:15: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:16: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:16: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:17: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:17: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:18: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:18: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:19: (debug) [network-mysqld.c:937]: error on a connection (fd: -1 event: 0). closing client connection.
2010-11-30 23:27:28: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:28: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:28: (debug) [network-mysqld.c:937]: error on a connection (fd: -1 event: 0). closing client connection.
2010-11-30 23:27:30: (debug) abs wait-for-event::done            usec=       0
2010-11-30 23:27:30: (debug) abs lua-exec::done                  usec=       0
2010-11-30 23:27:30: (debug) [network-mysqld.c:937]: error on a connection (fd: -1 event: 0). closing client connection.

How to repeat:
this is my php script:

<?php
/* 
* Created on 2009-12-8 
* 
* To change the template for this generated file go to 
* Window - Preferences - PHPeclipse - PHP - Code Templates 
*/

$dsn = 'mysql:dbname=test;host=localhost;port=3307';
$user = 'root';
$password = 'root';

try {

$dbh = new PDO($dsn, $user, $password);

$sql = "SELECT * ".
" FROM site.site limit 2";

$sth = $dbh->prepare($sql);
$sth->execute();

$result = $sth->fetchAll(PDO::FETCH_ASSOC);
print_r($result);

} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}

?>

just type in shell:

$php test.php

and repeat it a little faster.
it works fine at first few queries then one error after one fine ...
[30 Nov 2010 15:45] david nick
my.cnf:
[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir=/data/mysql
back_log = 50
max_connections = 500
max_connect_errors = 100
table_cache = 2048
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
query_cache_size = 64M
query_cache_limit = 2M
ft_min_word_len = 4
default_table_type = InnoDB
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M
long_query_time = 3
key_buffer_size = 32M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 36M
innodb_data_file_path = ibdata1:4G;idbdata2:4G:autoextend
innodb_file_io_threads = 5
innodb_thread_concurrency = 5
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_autoextend_increment = 20M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 80
innodb_flush_method=O_DIRECT
innodb_lock_wait_timeout = 50
auto_increment_increment=2
auto_increment_offset=1
expire_logs_days=3
innodb_write_io_threads=5
innodb_io_capacity=200
slow_query_log=/data/logs/slow.log

innodb_use_sys_malloc =1

user=mysql
old_passwords=0

# sync
server-id=1001
log-bin=mysql-bin
binlog-ignore-db=mysql
sync_binlog=1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-name-resolve
skip-grant-tables
skip-locking
[30 Nov 2010 16:11] david nick
[root@test1 ~]# php test.php 

[connect_server] 127.0.0.1:52669
  [1].connected_clients = 0
  [1].pool.cur_idle     = 5
  [1].pool.max_idle     = 8
  [1].pool.min_idle     = 4
  [1].type = 1
  [1].state = 1
  [2].connected_clients = 0
  [2].pool.cur_idle     = 0
  [2].pool.max_idle     = 8
  [2].pool.min_idle     = 4
  [2].type = 2
  [2].state = 1
  [2] idle-conns below min-idle
[read_query] 127.0.0.1:52669
  current backend   = 0
  client default db = test
  client username   = root
  query             = SELECT *  FROM site.site limit 2
  sending to backend : 0.0.0.0:3306
    is_slave         : true
    server default db: test
    server username  : root
    in_trans        : false
    in_calc_found   : false
    COM_QUERY       : true
  
[read_query] 127.0.0.1:52669
  current backend   = 0
  client default db = test
  client username   = root
  (QUIT) current backend   = 0
[disconnect_client] 127.0.0.1:52669
[root@test1 ~]# php test.php 

[connect_server] 127.0.0.1:52680
  [1].connected_clients = 0
  [1].pool.cur_idle     = 5
  [1].pool.max_idle     = 8
  [1].pool.min_idle     = 4
  [1].type = 1
  [1].state = 1
  [2].connected_clients = 0
  [2].pool.cur_idle     = 5
  [2].pool.max_idle     = 8
  [2].pool.min_idle     = 4
  [2].type = 2
  [2].state = 1
  [1] taking master as default
  using pooled connection from: 1
[disconnect_client] 127.0.0.1:52680
Connection failed: SQLSTATE[08S01] [1156] Got packets out of order  
[root@test1 ~]# php test.php 

[connect_server] 127.0.0.1:54787
  [1].connected_clients = 0
  [1].pool.cur_idle     = 0
  [1].pool.max_idle     = 8
  [1].pool.min_idle     = 4
  [1].type = 1
  [1].state = 1
  [1] idle-conns below min-idle
[read_query] 127.0.0.1:54787
  current backend   = 0
  client default db = test
  client username   = root
  query             = SELECT *  FROM site.site limit 2
  sending to backend : 0.0.0.0:3306
    is_slave         : true
    server default db: test
    server username  : root
    in_trans        : false
    in_calc_found   : false
    COM_QUERY       : true
  
[read_query] 127.0.0.1:54787
  current backend   = 0
  client default db = test
  client username   = root
  (QUIT) current backend   = 0
[disconnect_client] 127.0.0.1:54787
[root@test1 ~]# php test.php 

[connect_server] 127.0.0.1:55499
  [1].connected_clients = 0
  [1].pool.cur_idle     = 5
  [1].pool.max_idle     = 8
  [1].pool.min_idle     = 4
  [1].type = 1
  [1].state = 1
  [2].connected_clients = 0
  [2].pool.cur_idle     = 5
  [2].pool.max_idle     = 8
  [2].pool.min_idle     = 4
  [2].type = 2
  [2].state = 1
  [1] taking master as default
  using pooled connection from: 1
[disconnect_client] 127.0.0.1:55499
Connection failed: SQLSTATE[08S01] [1156] Got packets out of order  
[root@test1 ~]#
[1 Dec 2010 18:52] Sveta Smirnova
Thank you for the report.

Verified as described.
[1 Dec 2010 18:57] Sveta Smirnova
Bug #57655 was marked as duplicate of this one.
[3 Dec 2010 2:59] david nick
I reinstalled mysql5.1 compile from official src instead of Percona server, everything work fine now.

now I use mysql5.1 as a readonly slave and Percona as master server .

so may be it is not compatible with Percona.