From: Ian Jackson Subject: [OSSTEST PATCH 18/25] sg-report-host-history: Move database manipulations Date: Wed, 17 Jun 2015 17:45:14 +0100 Message-ID: <1434559521-8751-19-git-send-email-ian.jackson@eu.citrix.com> References: <1434559521-8751-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z5GTP-0004cO-8t for xen-devel@lists.xenproject.org; Wed, 17 Jun 2015 16:45:59 +0000 In-Reply-To: <1434559521-8751-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Arrange for the SET LOCAL to have the right scope. Run computeflightsrange, and reporthost, each within a db transaction, with an appropriate lock. Signed-off-by: Ian Jackson --- sg-report-host-history | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sg-report-host-history b/sg-report-host-history index f7a773d..5a3f8be 100755 --- a/sg-report-host-history +++ b/sg-report-host-history @@ -97,11 +97,6 @@ END $flightcond = "(flight > $minflight)"; } -$dbh_tests->do("SET LOCAL enable_seqscan=false"); -# Otherwise the PostgreSQL query planner likes to do a complete scan -# of the runvars table, rather than walking backwards through the -# flights until it has what we've told it is enough. - sub jobquery ($$) { my ($q, $jr) = @_; $q->execute($jr->{flight}, $jr->{job}); @@ -245,5 +240,17 @@ END rename "$html_file.new", "$html_file" or die "$html_file $!"; } -computeflightsrange(); -reporthost $_ foreach @ARGV; +db_retry($dbh_tests, [qw(flights resources)], sub { + computeflightsrange(); +}); + +$dbh_tests->do("SET LOCAL enable_seqscan=false"); +# Otherwise the PostgreSQL query planner likes to do a complete scan +# of the runvars table, rather than walking backwards through the +# flights until it has what we've told it is enough. + +foreach my $host (@ARGV) { + db_retry($dbh_tests, [qw(flights)], sub { + reporthost $host; + }); +} -- 1.7.10.4