From 3d6aa5f93ba2971c43514a5d70ec5398607c4747 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 17 Apr 2011 18:17:58 +0000 Subject: [PATCH] try at a multiprocess torrus-srvderive to hopefully catch/keep up, RT#10574 --- FS/bin/freeside-torrus-srvderive | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/FS/bin/freeside-torrus-srvderive b/FS/bin/freeside-torrus-srvderive index 7a42f51f0..e5a05d078 100644 --- a/FS/bin/freeside-torrus-srvderive +++ b/FS/bin/freeside-torrus-srvderive @@ -64,11 +64,13 @@ my $orderlimit = " our $kids = 0; -MAIN: while (1) { +#MAIN: while (1) { +while (1) { my $found = 0; - SERVICEID: foreach my $torrus_srvderive ( qsearch('torrus_srvderive', {}) ) { + #SERVICEID: foreach my $torrus_srvderive ( qsearch('torrus_srvderive', {}) ) { + foreach my $torrus_srvderive ( qsearch('torrus_srvderive', {}) ) { &reap_kids; if ( $kids >= $max_kids ) { @@ -95,7 +97,7 @@ MAIN: while (1) { my $serviceid = $torrus_srvderive->serviceid; my @serviceids = $torrus_srvderive->component_serviceids; - next unless @serviceids; #don't try to search for empty virtual ports + exit unless @serviceids; #don't try to search for empty virtual ports my @in = (); for my $dir ('_IN', '_OUT') { @@ -118,7 +120,7 @@ MAIN: while (1) { die $error if $error; } else { warn "no initial last_srv_date for $serviceid; skipping\n" if $DEBUG; - next; + exit; } } @@ -149,12 +151,14 @@ MAIN: while (1) { alarm(0); if ( $@ && $@ eq "_timeout\n" ) { - warn "search timed out; reconnecting and restarting\n"; + #warn "search timed out; reconnecting and restarting\n"; + warn "search timed out\n"; dbh->clone()->do("KILL QUERY ". dbh->{"mysql_thread_id"}) if driver_name eq 'mysql'; dbh->rollback; #or die dbh->errstr; - adminsuidsetup($user); - next SERVICEID; #MAIN; + #adminsuidsetup($user); + #next SERVICEID; #MAIN; + exit; } elsif ( $@ ) { die $@; } @@ -200,11 +204,13 @@ MAIN: while (1) { #stupid mysql deadlocks all the time on insert, so we need to recover unless ( $isth->execute(@param) ) { - warn "Error inserting data for $serviceid$dir (restarting): ". - $isth->errstr; + #warn "Error inserting data for $serviceid$dir (restarting): ". + # $isth->errstr; + warn "Error inserting data for $serviceid$dir: ". $isth->errstr; dbh->rollback; #or die dbh->errstr; - sleep 5; - next SERVICEID; #MAIN; + #sleep 5; + #next SERVICEID; #MAIN; + exit; } } -- 2.11.0