|
Description
|
Lock creation in the create_lock() function in nightly is racy. In particular, lock creation isn't
atomic. Not only is the test a separate operation from the set, but the set itself isn't atomic,
as it consists of writing to a file.
Given that we want to store data in the lock, a symlink is the best means available to us. Symlink
creation as our test-and-set is completely atomic, and even embeds the lock data atomically.
While the current mechanism is fine for accidentally running nightly on a workspace whose build is
already some time in progress -- likely the majority of the cases -- I've run into the problem
dozens of times because of the ON incremental builds, which are run from a cron job. When my
home directory disappears (because of a jurassic or network outage), the cron jobs pile up, and when
my home directory reappears, they all thunder towards this lock at pretty much the same time. With
the patch in the Suggested Fix applied, only one nightly actually succeeds, saving the workspace
from some pretty scary consequences.
|