xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [OSSTEST PATCH 5/9] db retry, bisect: Cache build reuse investigations
Date: Tue, 20 Dec 2016 18:37:58 +0000	[thread overview]
Message-ID: <1482259082-30767-6-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1482259082-30767-1-git-send-email-ian.jackson@eu.citrix.com>

If we previously searched for builds to reuse, trust our previous
answers.  We will only have seen data from committed transactions and
we will only have looked at jobs in completed flights, which won't
have changed.

So any previously reuseable build is still reuseable.  (Unless its
stash check failed, in which case we might want to search again if we
do a db retry.)  We don't care much about missing any
recently-finished jobs - there is a much bigger and unavoidable race
there anyway, where multiple bisections on different branches may
choose to pointlessly rebuild the same thing at the same time.

Not doing this search over and over again is important because it is a
very wide ranging search, which will often cause database transaction
serialisation errors.  Without some caching here, we may never
converge.

In principle we could do this another way: we could make a readonly
transaction which did all the searching.  But that's a more awkward
way to organise the code because our search uses a temporary table
which we then construct the flight from.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 cs-bisection-step | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/cs-bisection-step b/cs-bisection-step
index 1d1962a..819e519 100755
--- a/cs-bisection-step
+++ b/cs-bisection-step
@@ -1121,6 +1121,7 @@ END
 }
 
 our %jobs_created;
+our %builds_investigated; # $builds_investigated{$popjob} = 0, or {..row..}
 
 sub preparejob ($$$);
 sub preparejob ($$$) {
@@ -1194,7 +1195,11 @@ END
     my $usejob;
 
     if ($cache_option and $cacheok and $recipe =~ m/^build/ and !@$subjobs) {
-        my $reusejob= $dbh_tests->selectrow_hashref(<<END,{}, $popjob,$popjob);
+	my $reusejob= $builds_investigated{$popjob};
+	if (!defined $reusejob) {
+	    print STDERR "Searching for $popflight.$popjob to reuse...\n";
+	    $reusejob =
+		$dbh_tests->selectrow_hashref(<<END,{}, $popjob,$popjob);
             SELECT  *
             FROM    flights JOIN jobs j USING (flight)
             WHERE   j.job=?
@@ -1216,6 +1221,9 @@ END
             ORDER BY flights.started desc
             LIMIT 1
 END
+	    $reusejob //= 0; # defined but falseish
+	    $builds_investigated{$popjob}= $reusejob;
+	}
 
         if ($reusejob) {
 	    my $wantusejob= "$reusejob->{flight}.$reusejob->{job}";
@@ -1226,6 +1234,7 @@ END
 	    } else {
 		print STDERR "Can NOT reuse $recipe $wantusejob:".
 		    " $stashcheck: $!\n";
+		undef $builds_investigated{$popjob};
 	    }
         }
     }
-- 
2.1.4


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

  parent reply	other threads:[~2016-12-20 18:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-20 18:37 [OSSTEST PATCH 0/9] db retry: fixes and workarounds Ian Jackson
2016-12-20 18:37 ` [OSSTEST PATCH 1/9] mg-schema-test-database: Revamp sequence handling Ian Jackson
2016-12-20 18:37 ` [OSSTEST PATCH 2/9] mg-schema-test-database: Wrap some withtest psql_do in subshells Ian Jackson
2016-12-20 18:37 ` [OSSTEST PATCH 3/9] cs-bisection-step: Do not acquire the repo lock Ian Jackson
2016-12-20 18:37 ` [OSSTEST PATCH 4/9] db retry, bisection: Reset %jobs_created on db retry Ian Jackson
2016-12-20 18:37 ` Ian Jackson [this message]
2016-12-20 18:37 ` [OSSTEST PATCH 6/9] db retry: Document $@ as an implicit parameter to need_retry Ian Jackson
2016-12-20 18:38 ` [OSSTEST PATCH 7/9] db retry: Break out Osstest::Executive::JobDB::_need_retry Ian Jackson
2016-12-20 18:38 ` [OSSTEST PATCH 8/9] db retry: Use HandleError and exceptions to detect when to retry Ian Jackson
2016-12-20 18:38 ` [OSSTEST PATCH 9/9] db retry: Retry on $dbh->state eq '' 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=1482259082-30767-6-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.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).