From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH 13/27] cr-ensure-disk-space: Look at referring flights
Date: Wed, 16 Sep 2015 14:35:16 +0100 [thread overview]
Message-ID: <1442410530-9665-14-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1442410530-9665-1-git-send-email-ian.jackson@eu.citrix.com>
Previously the flight to delete was simply the one with the lowest
flight number. Now we sort flights not by their own flight number,
but by the highest flight number of any referencing flight.
This means that flights whose builds are being reused are kept as long
as the reusing flights.
This almost-entirely fixes a largely-theoretical race in the way
cs-bisection-step works (where the flight's logs and build outputs
might be deleted between the setup and execution of the referring
flight).
A smaller race still exists because the stash check in
cs-bisection-step occurs before the being-created flight is visible to
other db clients. We will have to fix this by taking the flights
lock.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
cr-ensure-disk-space | 43 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 38 insertions(+), 5 deletions(-)
diff --git a/cr-ensure-disk-space b/cr-ensure-disk-space
index ced9777..0314e7a 100755
--- a/cr-ensure-disk-space
+++ b/cr-ensure-disk-space
@@ -55,7 +55,17 @@ flock LOCK, LOCK_EX or die $!;
$|=1;
my $chkq= db_prepare("SELECT * FROM flights WHERE flight=?");
+
+my $refq= db_prepare(<<END);
+ SELECT flight, val
+ FROM runvars
+ WHERE name like '%job'
+ AND val like '%.%'
+ AND flight >= ?
+END
+
our @flights;
+our %latestref;
for (;;) {
open P, "-|", onloghost "df --block-size=1M -P $logdir" or die $!;
@@ -69,23 +79,46 @@ for (;;) {
last if $space >= logcfg('MinSpaceMby');
if (!@flights) {
+ %latestref = ();
open P, "-|", onloghost "ls -1 $logdir" or die $!;
+
+ my $minflight = undef;
while (<P>) {
next unless m/^(\d+)\n$/;
- push @flights, $1;
+ $latestref{$1} = $1;
+ $minflight //= $1;
+ $minflight = $1 if $1 < $minflight;
}
$!=$?=0; close P or die "ls: $? $!";
- @flights = sort { $b <=> $a } @flights;
+
+ print DEBUG "MINFLIGHT $minflight\n";
+
+ $refq->execute($minflight);
+ while (my $rr= $refq->fetchrow_hashref) {
+ my $testflight = $rr->{flight};
+ next unless $rr->{val} =~ m/^(\d+)\./;
+ my $buildflight = $1;
+ next unless exists $latestref{$buildflight};
+ if ($testflight > $latestref{$buildflight}) {
+ print DEBUG "REF $buildflight <- $testflight\n";
+ $latestref{$buildflight} = $testflight;
+ }
+ }
+
+ @flights =
+ sort { $latestref{$b} <=> $latestref{$a} }
+ keys %latestref;
printf "(%d flights) ", scalar @flights;
die unless @flights;
}
my $flight = pop @flights;
- printf "selected %s ", $flight;
+ my $latestref = $latestref{$flight};
+ printf "selected %s (latest ref %s) ", $flight, $latestref;
- $chkq->execute($flight);
+ $chkq->execute($latestref);
my $row= $chkq->fetchrow_hashref();
$chkq->finish();
- die $flight unless defined $row;
+ die "$flight $latestref" unless defined $row;
my $age= time - $row->{started};
printf "(age %dd) ", $age / 86400;
--
1.7.10.4
next prev parent reply other threads:[~2015-09-16 13:35 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 13:35 [OSSTEST PATCH 00/27] xen.git#staging smoke tests Ian Jackson
2015-09-16 13:35 ` [OSSTEST PATCH 01/27] docs: Document OSSTEST_RESOURCE_PRIORITY values in README.planner Ian Jackson
2015-09-16 13:46 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 02/27] Executive: cs-job-create: Check that OSSTEST_FLIGHT is not set Ian Jackson
2015-09-16 13:48 ` Ian Campbell
2015-09-16 13:52 ` Ian Jackson
2015-09-16 13:35 ` [OSSTEST PATCH 03/27] mg-list-all-branches: Suppress `maintjobs' Ian Jackson
2015-09-16 13:48 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 04/27] standalone: Do not blunder on after errors Ian Jackson
2015-09-16 13:48 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 05/27] standalone: Set very long SQLite3 busy timeout in Perl Ian Jackson
2015-09-16 13:49 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 06/27] cr-daily-branch: Honour AP_FETCH_PFX Ian Jackson
2015-09-16 13:49 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 07/27] memoise: New utility Ian Jackson
2015-09-16 13:54 ` Ian Campbell
2015-09-16 13:58 ` Ian Jackson
2015-09-16 14:07 ` Ian Campbell
2015-09-16 14:38 ` Ian Jackson
2015-09-16 14:41 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 08/27] standalone-generate-dump-flight-runvars: memoise ap-fetch Ian Jackson
2015-09-16 13:56 ` Ian Campbell
2015-09-16 13:59 ` Ian Jackson
2015-09-16 13:35 ` [OSSTEST PATCH 09/27] mfi-common: Use job_create_build for build-*-prev Ian Jackson
2015-09-16 13:56 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 10/27] ap-fetch-version*: Unwrap xen-unstable lines Ian Jackson
2015-09-16 13:56 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 11/27] ap-push: Use refs/heads/ for destinations Ian Jackson
2015-09-16 13:57 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 12/27] cr-ensure-disk-space: Honour -D Ian Jackson
2015-09-16 13:59 ` Ian Campbell
2015-09-16 13:35 ` Ian Jackson [this message]
2015-09-16 14:09 ` [OSSTEST PATCH 13/27] cr-ensure-disk-space: Look at referring flights Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 14/27] cr-ensure-disk-space: Make main loop body into a subroutine Ian Jackson
2015-09-16 14:09 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 15/27] cr-ensure-disk-space: Take the flights db lock Ian Jackson
2015-09-16 14:13 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 16/27] cs-job-create: Permit creation of `synth' runvars Ian Jackson
2015-09-16 14:16 ` Ian Campbell
2015-09-16 14:41 ` Ian Jackson
2015-09-16 14:49 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 17/27] mg-show-flight-runvars: Decorate synth runvar names with ~ Ian Jackson
2015-09-16 14:19 ` Ian Campbell
2015-09-16 14:46 ` Ian Jackson
2015-09-16 13:35 ` [OSSTEST PATCH 18/27] standalone-generate-dump-flight-runvars: Show synth runvars Ian Jackson
2015-09-16 14:20 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 19/27] ts-host-alloc-Executive: Honour various hostalloc_* runvars Ian Jackson
2015-09-16 14:22 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 20/27] make-flight: Allow separate specification of pre-built Xen vs others Ian Jackson
2015-09-16 14:25 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 21/27] make-flight: Contemplate varying architecture for Debian HVM Ian Jackson
2015-09-16 14:26 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 22/27] make-flight: Run job_create_test_filter_callback on true job name Ian Jackson
2015-09-16 14:26 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 23/27] make-flight: Provide xen-unstable-smoke branch Ian Jackson
2015-09-16 14:28 ` Ian Campbell
2015-09-16 14:51 ` Ian Jackson
2015-09-16 15:09 ` Ian Campbell
2015-09-16 14:31 ` Ian Campbell
2015-09-16 14:31 ` Ian Campbell
2015-09-16 14:57 ` Ian Jackson
2015-09-16 15:10 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 24/27] make-flight: mfi-common: Honour $global_runvars Ian Jackson
2015-09-16 14:29 ` Ian Campbell
2015-09-16 14:53 ` Ian Jackson
2015-09-16 13:35 ` [OSSTEST PATCH 25/27] ap-*: Be able to fetch and push xen.git#smoked Ian Jackson
2015-09-16 14:32 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 26/27] cri-common: Support xen-unstable-smoke Ian Jackson
2015-09-16 14:33 ` Ian Campbell
2015-09-16 13:35 ` [OSSTEST PATCH 27/27] crontab: Enable xen-unstable-smoke branch every 3h at <1mod3>:51 UTC Ian Jackson
2015-09-16 14:34 ` Ian Campbell
2015-09-16 14:37 ` Ian Campbell
2015-09-16 15:29 ` [OSSTEST PATCH 00/27] xen.git#staging smoke tests Ian Campbell
2015-09-16 15:46 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442410530-9665-14-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).