The previous algorithm was wrong here.

This commit was originally considerably later than the previous one.
I'm avoiding squshing this commit, to make future archaeology easier.
The effect of the bug is to report other tasks as live too often, so
hosts show up as shared rather than reused.

Signed-off-by: Ian Jackson <i...@xenproject.org>
---
 Osstest/JobDB/Executive.pm | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index cf82b4cf..3a8308e9 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -561,17 +561,15 @@ END
 END
 
     my $ojvn = "$ho->{Ident}_lifecycle";
-    my $firstrun;
 
     if (length $r{$ojvn}) {
        my ($oldsigil,) = reverse split / /, $r{$ojvn};
        $oldsigil = '' unless $oldsigil =~ m/^\W$/;
        return if $newsigil ne '' && $oldsigil eq $newsigil;
-    } else {
-       $firstrun = 1;
     }
 
     my @lifecycle;
+    my $seen_us;
     db_retry($dbh_tests,[], sub {
        my $elided;
        @lifecycle = ();
@@ -581,10 +579,10 @@ END
 
        while (my $o = $scanq->fetchrow_hashref()) {
            my $olive =
-             # Any job which appeared since we started thinking
-             # about this must have been concurrent with us,
-             # even if it is dead now.
-             (!$firstrun || $o->{live}) &&
+             # Any job with any entry after we put ourselves in the
+             # table must have been concurrent with us, even if it is
+             # dead now.
+             ($seen_us || $o->{live}) &&
              # If this task is still live, we need to have something
              # with a live mark, generally all the prep will have
              # occurred already, so we don't mark the prep as live
@@ -597,6 +595,7 @@ END
                $o->{job} eq $job) {
                # Don't put the + mark on our own entries.
                $olivemark = '';
+               $seen_us = 1;
            }
 
            my $oisprepmark = !!$o->{isprep} && '@';
-- 
2.20.1


Reply via email to