From: Dylan William Hardison Date: Wed, 14 Nov 2018 20:23:27 +0000 (-0500) Subject: Bug 1505050 - make the request nagging script more robust X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fce85617244a8e32a7db15d8439867cdb4a38af6;p=thirdparty%2Fbugzilla.git Bug 1505050 - make the request nagging script more robust 1. The nags script switches to the shadow database, but $dbh is defined before that happens and is thus the primary database. This is easily fixed by using Bugzilla->dbh 2. Since we have DBIx::Connector, we can run the sql in fixup mode, so that if it gets disconnected, it will retry the code. This is perfectly safe for the the two big sql queries. --- diff --git a/extensions/RequestNagger/bin/send-request-nags.pl b/extensions/RequestNagger/bin/send-request-nags.pl index 824c0dc51..93652f100 100755 --- a/extensions/RequestNagger/bin/send-request-nags.pl +++ b/extensions/RequestNagger/bin/send-request-nags.pl @@ -43,12 +43,11 @@ if (my $filename = shift @ARGV) { exit; } -my $dbh = Bugzilla->dbh; -my $db_date = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); +my $db_date = Bugzilla->dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); my $date = format_time($db_date, '%a, %d %b %Y %T %z', 'UTC'); # delete expired defers -$dbh->do("DELETE FROM nag_defer WHERE defer_until <= CURRENT_DATE()"); +Bugzilla->dbh->do("DELETE FROM nag_defer WHERE defer_until <= CURRENT_DATE()"); Bugzilla->switch_to_shadow_db(); # send nags to requestees @@ -77,9 +76,10 @@ sub send_nags { # get requests foreach my $report (@{ $args{reports} }) { - - # collate requests - my $rows = $dbh->selectall_arrayref($args{$report . '_sql'}, { Slice => {} }); + my $rows; + Bugzilla->dbh->connector->run(fixup => sub { + $rows = $_->selectall_arrayref($args{$report . '_sql'}, { Slice => {} }); + }); foreach my $request (@$rows) { next unless _include_request($request, $report);