Resyncs build-utils/lib/XCAT/NFSLock.pm with xcat-dep, where the defect was
found and fixed.
release deleted the owner metadata and marked the guard released before it
knew the removal could finish. A build lock with a live worker group
therefore lost its metadata when the rmdir failed, and every later build
refused it for ever rather than recovering it when the previous build died.
The sweep had the same ordering and left the same wreck.
Both clear the records of completed workers first and delete the metadata
only once the directory holds nothing else. release retries while a worker
blocks the removal, so cancel_build's retention finishes the release when
the group finally goes.
Depends on xcat-dep/#93, which carries the same change to the original.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
BuildUtils::sh() runs each build command in its own process group, so
SIGKILL on the wrapper leaves that group running. The lock records the
wrapper, so the next build proved the wrapper dead and took the lock, and
two builds then wrote one checkout and one mock target. cancel_build keeps
the lock on purpose when a group survives its cleanup, and that recovery
undid the retention.
sh() now records the group on every lock this process holds, before it
restores the signal mask, so a cancellation cannot land between the fork
and the record. It drops the record after the group is reaped.
cancel_build drops it only when kill(0, -pgid) answers ESRCH, which is the
test it already used to decide it may release; on the retention path the
record stays, and a later acquire reads it and refuses the lock.
The vendored XCAT::NFSLock carries the rule: an owner is recoverable only
when it is provably dead and every attached group is gone. detach refuses
while any process is in the group, so the retention does not depend on
which call site remembered to run.
Depends on xcat-dep/#93, which carries the same change to the original.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
BuildUtils::sh() runs each build command in its own process group, so
SIGKILL on the wrapper leaves that group running. A lock recovered from the
dead wrapper then lets a second build into the same checkout, and
cancel_build's retention is undone by the same recovery: it keeps the lock
when workers survive, and the next build reads a dead owner and takes it.
build_lock_stale_owner.t covers a wrapper and nothing below it. The name
reads wider than the check: the holder it kills has no build worker, so the
worker case was never measured. Its comment says so now.
A new check is the reviewer's case. A worker runs in its own process group,
a wrapper takes the build lock and records it, the wrapper alone is killed,
and a second build must stay blocked. Then the worker exits and the same
build must take the lock: without that half, a lock that recovers nothing
would pass.
The handshake is two one-byte reads on separate pipes, each bounded. One
read of two bytes made it a timing test, which passed on this host and
killed the wrapper before it held the lock.
The vendored XCAT::NFSLock gains attach, detach and live_workers, which
these checks drive.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
Resyncs build-utils/lib/XCAT/NFSLock.pm with xcat-dep, where the defect was
found and fixed. The module reclaimed a stranded lock.borrow by path after
validating its metadata, and rmdir names a path and not the inode that was
validated, so a contender stopped between the two steps removed whatever
was at the path when it resumed. Two builds of one target could then both
hold the build lock, which is the collision the lock exists to prevent.
The borrow is numbered now, and a transition whose taker is provably dead
is ended by creating the next generation rather than by removing the one
that was validated. A process removes only a generation it created and
still holds.
acquire_lock_dir's comment said the retry budget covers reclaiming a borrow
with no metadata over two attempts. That rule is withdrawn, because a live
taker can pause for any length of time before its first write. A take-over
needs one attempt; the budget leaves two for a contended lock.
Depends on xcat-dep/#93, which carries the same change to the original.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
acquire_lock_dir dies with "another build of <what> already holds
<lockdir>" whenever XCAT::NFSLock->acquire fails, whatever the failure was.
A lockdir under a directory that does not exist, or one the build cannot
write, both tell the operator to look for a build that is not running, and
both print the advice about --mock-uniqueext. The nested text said "Trying
to unlock", which is the reverse of what acquire was doing.
acquire_lock_dir now reports contention only when the retry budget ran out,
and prints the error that happened otherwise. The vendored
XCAT::NFSLock is resynced with xcat-dep: its refusal names which failure it
was, and it reclaims a lock.borrow that has no metadata and that two
attempts find unchanged, which was a permanent strand. A lock.d with no
metadata stays refused, so a directory left by a build from before this
change is not recovered by acquire; sweep_stranded removes that one, and
only under an exclusive claim on the root.
buildrpms.pl kept "use POSIX (); # EEXIST, for the directory build lock",
and the lock has not used EEXIST since it became an XCAT::NFSLock. The
import is still needed for WNOHANG in abort_builds.
Depends on xcat-dep/#93, which carries the same change to the original
copy of XCAT/NFSLock.pm.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The build lock is a directory created with mkdir, which cannot release itself. A
build killed with SIGKILL or by the OOM-killer leaves it behind, and every later
build of the same target fails until an operator removes it by hand. No test
covered that case.
These checks take the lock in a child, confirm a second build is refused by name
while the child lives, kill the child with SIGKILL, and assert the lock is
recovered. One more holds the boundary that recovery must not widen what a lock
excludes: a build of a different checkout still runs beside it.
XCAT::NFSLock arrives with them, vendored at build-utils/lib/XCAT/NFSLock.pm
beside BuildUtils.pm, because xcat-core builds with no xcat-dep checkout. Its
header names the other two copies and records that the three must stay
identical. Nothing calls it yet, so these checks fail here.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>