From 40debf1515d5482f0eea7c906e9789af04d75b51 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 7 Jun 2013 20:10:45 +0000 Subject: [PATCH] hydra-queue-runner: Don't unlock builds we just started This happens if the previous iteration took more than 60 seconds. Then the queue runner may think that builds failed to start properly and unlock them, e.g. build 5264936 pid 19248 died, unlocking build 5264951 pid 19248 died, unlocking build 5257073 pid 19248 died, unlocking ... --- src/script/hydra-queue-runner | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/script/hydra-queue-runner b/src/script/hydra-queue-runner index 0b9224c1..5937656a 100755 --- a/src/script/hydra-queue-runner +++ b/src/script/hydra-queue-runner @@ -15,6 +15,8 @@ my $db = Hydra::Model::DB->new(); STDOUT->autoflush(); +my $lastTime; + #$SIG{CHLD} = 'IGNORE'; @@ -26,13 +28,7 @@ sub unlockDeadBuilds { my $pid = $build->locker; my $unlock = 0; if ($pid == $$) { - # Work around sqlite locking timeouts: if the child - # barfed because of a locked DB before updating the - # `locker' field, then `locker' is still set to $$. - # So if after a minute it hasn't been updated, - # unlock the build. !!! need a better fix for those - # locking timeouts. - if ($build->starttime + 60 < time) { + if (!defined $lastTime || $build->starttime < $lastTime - 300) { $unlock = 1; } } elsif (kill(0, $pid) != 1) { # see if we can signal the process @@ -190,6 +186,8 @@ while (1) { unlockDeadBuilds; checkBuilds; + + $lastTime = time(); }; warn $@ if $@;