Skip to contentSkip to conversation

cs-bisection-step: Improve a message

PATCH New Ian Jackson 1 participant 6 messages Jun 12, 2018 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

cover Handle jobs that depend on identically-named jobs

From: Ian Jackson <[email protected]>

Ian Jackson (5):
db_retry: Honour new OSSTEST_DB_ALWAYS_ABORT variable
cs-bisection-step: Improve a message
cs-bisection-step: Refactor $subjobs calculations a bit
cs-bisection-step: Handle build job chains
cs-bisection-step: Do explicitly set runvar for suppressed recursion

 Osstest.pm        |  2 ++
 cs-bisection-step | 43 +++++++++++++++++++++++++++++++++++++------
 2 files changed, 39 insertions(+), 6 deletions(-)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

PATCH 1/5 db_retry: Honour new OSSTEST_DB_ALWAYS_ABORT variable

This is useful for debugging.

---
 Osstest.pm | 2 ++
 1 file changed, 2 insertions(+)
Osstest.pm +2 -0
index 2263786..3377ea3 100644
@@ -330,6 +330,8 @@ sub db_retry ($$$;$$) {
 		last if $db_retry_stop eq 'abort';
 		next;
 	    }
+            die 'OSSTEST_DB_ALWAYS_ABORT set'
+                if $ENV{'OSSTEST_DB_ALWAYS_ABORT'};
 	    $committing = 1;
 	    $dbh->commit();
 	};
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw

PATCH 2/5 cs-bisection-step: Improve a message

In reply to Ian Jackson
---
 cs-bisection-step | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cs-bisection-step +1 -1
index 0be8bd0..0d0e08f 100755
@@ -1208,7 +1208,7 @@ END
     if ($cache_option and $cacheok and $recipe =~ m/^build/ and !@$subjobs) {
 	my $reusejob= $builds_investigated{$popjob};
 	if (!defined $reusejob) {
-	    print STDERR "Searching for $popflight.$popjob to reuse...\n";
+	    print STDERR "Searching for $popjob (like $copyflight) to reuse...\n";
 	    $reusejob =
 		$dbh_tests->selectrow_hashref(<<END,{}, $popjob,$popjob);
             SELECT  *
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#4 lore raw

PATCH 3/5 cs-bisection-step: Refactor $subjobs calculations a bit

In reply to Ian Jackson

Parse the runvar name earlier, adding job and orgflight members to the row hashes we got from the db. This slightly unifies the call to preparejob, but more relevantly, makes the effective job and flight information available earlier. That will be useful in a moment.

No functional change.

---
 cs-bisection-step | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
cs-bisection-step +12 -6
index 0d0e08f..01ee6e5 100755
@@ -1197,6 +1197,17 @@ END
     my $subjobs= $jobq->fetchall_arrayref( {} );
     $jobq->finish();
 
+    foreach my $subjob (@$subjobs) {
+        my $jobspec= $subjob->{val};
+        if ($jobspec =~ m/^(\d+)\.(.+)$/) {
+            $subjob->{job}       = $2;
+            $subjob->{orgflight} = $1;
+        } else {
+            $subjob->{job}       = $jobspec;
+            $subjob->{orgflight} = $copyflight;
+        }
+    }
+
     # See if there's a build we can reuse
 
     my ($recipe) = $dbh_tests->selectrow_array(<<END,{}, $copyflight,$popjob);
@@ -1277,12 +1288,7 @@ END
 END
     foreach my $subjob (@$subjobs) {
         my $target;
-        my $jobspec= $subjob->{val};
-        if ($jobspec =~ m/^(\d+)\.(.+)$/) {
-            $target= preparejob($2, $1, 1);
-        } else {
-            $target= preparejob($jobspec, $copyflight, 1);
-        }
+        $target= preparejob($subjob->{job}, $subjob->{orgflight}, 1);
         $jobsetq->execute($target, $popflight, $popjob, $subjob->{name});
     }
     $jobsetq->finish();
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

PATCH 4/5 cs-bisection-step: Handle build job chains

In reply to Ian Jackson

cs-bisection-step assumes that every job it will need to create has a unique name. Indeed, in general, it is probably not reasonable to expect it to work if that is not the case.

build-amd64-freebsd needs a previous build-amd64-freebsd.

Currently cs-bisection-step confuses itself into writing a flight where build-amd64-freebsd uses itself as its freebsdbuildjob. This naturally does not work very well.

I think the right approach is for cs-bisection-step to spot when it its recursion through the jobs, via *job runvars, would descend into a job name which it was already encoutered earlier in the dependency chain, and, when that occurs, to simply skip regenerating that deeper copy of the job.

That is achieved here by filtering the subjob out of the list, before we go looking for jobs to reuse. As a result, not only will no new job be created, but the original deeper job will be reused because the runvar value will not be updated.

FTR, the circular dependency produces this error from sg-execute-flight:

wait for process failed: no children
while executing
"wait -nohang"
(procedure "main_iteration" line 14)
invoked from within
"main_iteration"
(procedure "main" line 8)
invoked from within
"main"

      (file "./sg-execute-flight" line 238)

This is because sg-execute-flight's algorithm assumes that if there are no jobs running there must be some job whose dependencies are done. That is true if the job graph has no cycles.

Improving the error message from sg-execute-flight is left as an exercise for the future.

---
 cs-bisection-step | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
cs-bisection-step +21 -0
index 01ee6e5..a7e0336 100755
@@ -1133,6 +1133,7 @@ END
 
 our %jobs_created;
 our %builds_investigated; # $builds_investigated{$popjob} = 0, or {..row..}
+our %recursion_track;
 
 sub preparejob ($$$);
 sub preparejob ($$$) {
@@ -1144,6 +1145,11 @@ sub preparejob ($$$) {
 	return $jobs_created{$popjob};
     }
 
+    local $recursion_track{$popjob} = {
+        Depth => (1 + keys %recursion_track),
+        Spec => "$copyflight.$popjob"
+    };
+
     print STDERR "Need $popflight.$popjob (like $copyflight)\n";
 
     # Create a temporary table containing the runvars we want
@@ -1208,6 +1214,21 @@ END
         }
     }
 
+    @$subjobs = grep {
+        if ($recursion_track{ $_->{job} }) {
+            print STDERR "Not recursively creating another $_->{job} (".
+                (
+                 join " -> ",
+                 map { $_->{Spec} }
+                 sort { $a->{Depth} <=> $b->{Depth} }
+                 values %recursion_track
+                ). " -> $_->{orgflight}.$_->{job}\n";
+            0;
+        } else {
+            1;
+        }
+    } @$subjobs;
+
     # See if there's a build we can reuse
 
     my ($recipe) = $dbh_tests->selectrow_array(<<END,{}, $copyflight,$popjob);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw

PATCH 5/5 cs-bisection-step: Do explicitly set runvar for suppressed recursion

In reply to Ian Jackson

When we detect that we are considering a job which is identically named to one earlier in the dependency chain, it could happen that the final referencing runvar in the job at which we break the cycle is actually to an unqualified job name.

(This cannot happen unless the cycle has more than 2 jobs, and therefore more than one job name, because otherwise the job we would be copying would have a self-reference. So it cannot occur right now.)

So when breaking the cycle, we should update the job we are building to refer to the exact flight and job we want it to reuse.

The most convenient way to do this is to reorganise the new recursion suppression code: we retain the suppressed entries in $subjobs, and filter them as appropriate.

---
 cs-bisection-step | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)
cs-bisection-step +20 -16
index a7e0336..05bfaa0 100755
@@ -1214,20 +1214,17 @@ END
         }
     }
 
-    @$subjobs = grep {
-        if ($recursion_track{ $_->{job} }) {
-            print STDERR "Not recursively creating another $_->{job} (".
-                (
-                 join " -> ",
-                 map { $_->{Spec} }
-                 sort { $a->{Depth} <=> $b->{Depth} }
-                 values %recursion_track
-                ). " -> $_->{orgflight}.$_->{job}\n";
-            0;
-        } else {
-            1;
-        }
-    } @$subjobs;
+    foreach my $subjob (@$subjobs) {
+        next unless $recursion_track{ $subjob->{job} };
+        $subjob->{suppress} = 1;
+        print STDERR "Not recursively demanding another $subjob->{job} (".
+            (
+             join " -> ",
+             map { $_->{Spec} }
+             sort { $a->{Depth} <=> $b->{Depth} }
+             values %recursion_track
+            ). " -> $subjob->{orgflight}.$subjob->{job}\n";
+    }
 
     # See if there's a build we can reuse
 
@@ -1237,7 +1234,8 @@ END
 
     my $usejob;
 
-    if ($cache_option and $cacheok and $recipe =~ m/^build/ and !@$subjobs) {
+    if ($cache_option and $cacheok and $recipe =~ m/^build/
+        and !grep { !$_->{suppress} } @$subjobs) {
 	my $reusejob= $builds_investigated{$popjob};
 	if (!defined $reusejob) {
 	    print STDERR "Searching for $popjob (like $copyflight) to reuse...\n";
@@ -1309,7 +1307,13 @@ END
 END
     foreach my $subjob (@$subjobs) {
         my $target;
-        $target= preparejob($subjob->{job}, $subjob->{orgflight}, 1);
+        if ($subjob->{suppress}) {
+            $target = "$subjob->{orgflight}.$subjob->{job}";
+            print STDERR "Reusing $target for $subjob->{name}".
+                " in $popflight.$popjob\n";
+        } else {
+            $target= preparejob($subjob->{job}, $subjob->{orgflight}, 1);
+        }
         $jobsetq->execute($target, $popflight, $popjob, $subjob->{name});
     }
     $jobsetq->finish();
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel