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 ...
This commit is contained in:
parent
5d9b7c6ab2
commit
40debf1515
|
@ -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 $@;
|
||||
|
||||
|
|
Loading…
Reference in a new issue