Subject: | select GET_LOCK(?, ?) block signal handling |
The attached script cannot be ended with SIGINT when $SIG{INT} is set
up. The issue appears when a "SELECT GET_LOCK(?, ?)" statement waits for
the lock from the database.
Subject: | select-getlock.pl |
use strict;
use DBI;
use DBD::mysql 4.018;
if($ENV{'BLOCK_SIGNAL'}) {
$SIG{'INT'} = sub { die "INT!" };
}
my $dbh1 = DBI->connect('DBI:mysql:database=foo', @ENV{qw/ user pw /});
my $dbh2 = DBI->connect('DBI:mysql:database=foo', @ENV{qw/ user pw /});
my $sth1 = $dbh1->prepare('SELECT GET_LOCK(?, ?)');
my $sth2 = $dbh2->prepare('SELECT GET_LOCK(?, ?)');
warn "select sth1->GET_LOCK(...)";
$sth1->execute(foo => 10);
# this last will block for ten seconds, and i cannot kill it with
# SIGINT/TERM when BLOCK_SIGNAL=1
warn "select sth2->GET_LOCK(...)";
$sth2->execute(foo => 10);