[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 18/25] sg-report-host-history: Move database manipulations



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@xxxxxxxxxxxxx>
---
 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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.