[freeside-commits] freeside/FS/bin freeside-torrus-srvderive, 1.32, 1.33
Ivan,,,
ivan at wavetail.420.am
Thu Apr 7 18:04:35 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail.420.am:/tmp/cvs-serv22057/FS/bin
Modified Files:
freeside-torrus-srvderive
Log Message:
attempt to handle mysql hanging on queries, RT#10574
Index: freeside-torrus-srvderive
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-torrus-srvderive,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -d -r1.32 -r1.33
--- freeside-torrus-srvderive 7 Apr 2011 23:46:58 -0000 1.32
+++ freeside-torrus-srvderive 8 Apr 2011 01:04:33 -0000 1.33
@@ -1,6 +1,7 @@
#!/usr/bin/perl -w
use strict;
+use Sys::SigAction qw( set_sig_handler );
use Date::Parse;
use Date::Format;
use FS::Daemon ':all'; #daemonize1 drop_root daemonize2 myexit logfile sig*
@@ -91,10 +92,32 @@
warn "searching for times to add $serviceid\n" if $DEBUG;
warn $ssql if $DEBUG > 2;
- my $sth = dbh->prepare($ssql) or die $DBI::errstr; #better recovery?
+ my $sth = dbh->prepare($ssql) or die $DBI::errstr; #better recovery here?
warn "executing search" if $DEBUG;
+
+ eval {
+ my $timeout = set_sig_handler(
+ 'ALRM', sub {
+ dbh->clone()->do("KILL QUERY ". dbh->{"mysql_thread_id"})
+ if driver_name eq 'mysql';
+ die '_timeout';
+ },
+ { mask=>['ALRM'] , safe=>1 }
+ );
+ alarm(5*60); # 15*60);
$sth->execute($serviceid, $serviceid) or die $sth->errstr;
+ alarm(0);
+ };
+ alarm(0);
+ if ( $@ =~ /^_timeout/ ) {
+ warn "search timed out; reconnecting and restarting\n";
+ adminsuidsetup($user);
+ next MAIN;
+ } elsif ( $@ ) {
+ die $@;
+ }
+
warn "search executed; checking results" if $DEBUG;
my $prev = 0;
More information about the freeside-commits
mailing list