]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
sg-report-host-history: Move database manipulations
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 17 Jun 2015 15:55:26 +0000 (16:55 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 18 Jun 2015 15:31:04 +0000 (16:31 +0100)
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 <Ian.Jackson@eu.citrix.com>
sg-report-host-history

index f7a773d920448267a55a35bdce93f7c80913871e..5a3f8be0e2f1854d155cca251bf86c3fa966d6ca 100755 (executable)
@@ -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;
+    });
+}