DBD-mysql icon indicating copy to clipboard operation
DBD-mysql copied to clipboard

Signal cathcing inside execute method will raise the "Lost connection to MySQL..." [rt.cpan.org #85691]

Open mbeijen opened this issue 8 years ago • 0 comments
trafficstars

Migrated from rt.cpan.org#85691 (status was 'open')

Requestors:

From [email protected] on 2013-05-29 11:00:47:

Hello,

I noticed the strong problem
I have stable fork of MySQL server - Percona server, version 5.5.30
I have installed libraries from Percona too of course (i think these libraries work same as original MySQL libraries because Percona is fork of MySQL with improvements in sql engines)
And i have a fresh version DBI & DBD::mysql at this moment (2013-05-29)

If i use in program often the "execute" method in my program and if my program to be terminated by signal TERM (i catch this signal by $SIG{TERM}) and if signal occurs inside "execute" method - i got strong error "DBD::mysql::st execute failed: Lost connection to MySQL server during query at ..."

I know about deferred signals in Perl. I used other catching method as well - through using POSIX::sigaction ( https://metacpan.org/module/RJBS/perl-5.18.0/pod/perlipc.pod#Deferred-Signals-Safe-Signals ) but this doesn't help. Again and again if my program catch signal inside execute i got "Lost connection...". Please notice i don't use any I/O functions inside signal handler. I have there only one variable assigning.

Normally i want to make a following: i have local $SIG{TERM} = sub { $term = 1 } inside perl block where often to be run an "execute" method and i want only to finish my transaction which does more execute runs. But now i cannot make it. Only one way works - if before an each "execute" call in program i will use local $SIG{TERM} = 'IGNORE'. But this bad way - sometimes i cannot stop program - i should send to program more times the signal TERM for termination because often i have an ignoring TERM situation. And i cannot use everywhere in program ignoring signal before each "execute" statement. So i cannot have a normal daemons programs using DBD::mysql & signal termination.

I think this problem will occur if i will catch any signal if this problem is related with EINTR errno in read & write system calls. But i use many other I/O operations (memcached & beanstalkd daemons) in my daemon programs and i see only with mysql's executes.

From [email protected] on 2013-05-29 11:05:23:

And i forgot to tell a following:

After this error ($sth->execute) if i see a $sth->{Active} properties this property is true. So some programs use after-reconnect by this property cannot define lost connect.

From [email protected] on 2013-05-29 11:07:28:

Sorry, i saw $sth->{Database}{Active} attribute.

From [email protected] on 2013-07-06 05:10:56:

On 2013-05-29 07:00:47, PERLOVER wrote:
> Hello,
> 
> I noticed the strong problem
> I have stable fork of MySQL server - Percona server, version 5.5.30

This sounds like http://bugs.mysql.com/bug.php?id=65956, which is a bug in the underlying libmysqlclient library (just stumbled over this mysql).

You should be able to work around this by installing a signal handler with the SA_RESTART flag.

Note that your signal handler will not be executed until the sql statement has finished execution if you use safe signal handling (and that you might risk data corruption if you use unsafe signal handling).

mbeijen avatar Nov 15 '17 07:11 mbeijen