forked from lix-project/hydra
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();
|
STDOUT->autoflush();
|
||||||
|
|
||||||
|
my $lastTime;
|
||||||
|
|
||||||
#$SIG{CHLD} = 'IGNORE';
|
#$SIG{CHLD} = 'IGNORE';
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,13 +28,7 @@ sub unlockDeadBuilds {
|
||||||
my $pid = $build->locker;
|
my $pid = $build->locker;
|
||||||
my $unlock = 0;
|
my $unlock = 0;
|
||||||
if ($pid == $$) {
|
if ($pid == $$) {
|
||||||
# Work around sqlite locking timeouts: if the child
|
if (!defined $lastTime || $build->starttime < $lastTime - 300) {
|
||||||
# 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) {
|
|
||||||
$unlock = 1;
|
$unlock = 1;
|
||||||
}
|
}
|
||||||
} elsif (kill(0, $pid) != 1) { # see if we can signal the process
|
} elsif (kill(0, $pid) != 1) { # see if we can signal the process
|
||||||
|
@ -190,6 +186,8 @@ while (1) {
|
||||||
unlockDeadBuilds;
|
unlockDeadBuilds;
|
||||||
|
|
||||||
checkBuilds;
|
checkBuilds;
|
||||||
|
|
||||||
|
$lastTime = time();
|
||||||
};
|
};
|
||||||
warn $@ if $@;
|
warn $@ if $@;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue