ruby dbi connection to Mariadb break after beeing idle for 10 minutes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
ruby dbi connection to Mariadb break after beeing idle for 10 minutes
I use:
* debian squeeze
* mariadb 5.3.7-mariadb11
* libdbd-
* libdbi-ruby1.8 0.4.3-2
* libmysql-ruby1.8 2.8.2-1
* libruby1.8 1.8.7.302-2squeeze1
* libmysqlclient16 5.3.7-mariadb11
ruby dbi connection to Mariadb break after beeing idle for 10 minutes and doing
a query again. Code to reproduce:
#!/usr/bin/env ruby
require 'dbi'
require 'date'
DBNAME='test'
DBSOCKET=
DBUSER='test'
DBPASS='test'
# for testing purpose just create a test db:
# create database test;
# and grant select:
# grant select on test.* to 'test'@'localhost' identified by 'test';
wait_min=[9,10,11]
db = DBI.connect(
wait_min.each do | n |
i = n*60
puts DateTime.now()
puts "do query: SELECT 1;"
query=
query.execute
query.fetch_array
query.finish
puts "sleep for #{n} min."
sleep(i)
end
puts "Disconnect:"
db.disconnect
Waiting for 9 minutes and doing a 'SELECT 1;' works, waiting for 10 minutes lead to the error:
/usr/lib/
from /usr/lib/
from /usr/lib/
from test_db2.rb:25
from test_db2.rb:20:in `each'
from test_db2.rb:20
An excerpt of an strace log running these program:
connect(3, {sa_family=AF_FILE, path="/
setsockopt(3, SOL_SOCKET, SO_RCVTIMEO, "\2003\
setsockopt(3, SOL_SOCKET, SO_SNDTIMEO, "\2003\
brk(0xde7000) = 0xde7000
setsockopt(3, SOL_IP, IP_TOS, [8], 4) = -1 EOPNOTSUPP (Operation not supported)
setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
read(3, "c\0\0\
stat("/
open("/
read(4, "<?xml version='1.0' encoding=\"ut"..., 18261) = 18261
close(4) = 0
write(3, "U\0\0\
read(3, "\7\0\0\
stat("/
fstat(1, {st_mode=
mmap(NULL, 4096, PROT_READ|
write(1, "2012-08-
write(1, "do query: SELECT 1;\n", 20) = 20
poll([{fd=3, events=
write(3, "\n\0\0\0\3SELECT 1;", 14) = 14
read(3, "\1\0\0\
write(1, "sleep for 9 min.\n", 17) = 17
select(0, NULL, NULL, NULL, {540, 0}) = 0 (Timeout)
stat("/
write(1, "2012-08-
write(1, "do query: SELECT 1;\n", 20) = 20
poll([{fd=3, events=
write(3, "\n\0\0\0\3SELECT 1;", 14) = 14
read(3, "\1\0\0\
write(1, "sleep for 10 min.\n", 18) = 18
select(0, NULL, NULL, NULL, {600, 0}) = 0 (Timeout)
stat("/
brk(0xe0a000) = 0xe0a000
brk(0xe05000) = 0xe05000
write(1, "2012-08-
write(1, "do query: SELECT 1;\n", 20) = 20
poll([{fd=3, events=
read(3, "", 8192) = 0
shutdown(3, 2 /* send and receive */) = 0
close(3) = 0
rt_sigprocmask(
rt_sigprocmask(
write(2, "/usr/lib/
write(2, ": ", 2) = 2
write(2, "MySQL server has gone away", 26) = 26
write(2, " (", 2) = 2
write(2, "DBI::DatabaseE
write(2, ")\n", 2) = 2
write(2, "\tfrom /usr/lib/
write(2, "\tfrom /usr/lib/
write(2, "\tfrom test_db2.rb:25\n", 21) = 21
write(2, "\tfrom test_db2.rb:20:in `each'\n", 31) = 31
write(2, "\tfrom test_db2.rb:20\n", 21) = 21
rt_sigaction(
exit_group(1) = ?
I have tested this Program with mysqld 5.1.63 and it works as expected. The difference between mysqld 5.1.63 and
mariadb 5.3.7-mariadb11
but not by mysqld 5.1.63. (look at line 19,27,37 of the strace log).
The only workaround I can imagin is to do keep alive querys on idle connections.
Changed in maria: | |
status: | New → Incomplete |
Hi,
I ran your script on MariaDB 5.3.7 (my local installation from a binary tarball), and I didn't hit the issue, both 10 and 11 min work as expected.
What you observe looks like you have wait_timeout=600 configured somewhere for your MariaDB instance (but not for MySQL).
Could you please connect to your servers, both of them, and check the value of wait_timeout?
Only, if you do it with an interactive client, you need to check the GLOBAL value, e.g.
SELECT @@global. wait_timeout;
(It is important because the session timeout would be initialized differently).
Thanks.