fn lock_node(dir: &Path, node: u32) -> Result<File>Expand description
Take this node’s writer lock under dir, or refuse to start.
Segments are named {node}-{first_seq}, so two processes over one
directory with one node id read the same files, resume to the same number
and then hand it out twice. O_APPEND keeps each frame whole, which is
what makes the damage quiet rather than obvious: replay finds two different
bodies at one sequence, and a block claiming the watermark for either
covers both. --node has a default, so nothing has to be misconfigured for
two replicas over one volume to land here.
Per node and not per directory, because a shared volume with one log per replica is the supported arrangement (section 12) — the collision is the id, not the path.
flock and not fcntl: the lock belongs to the open file description, so
the kernel drops it when the fd closes, including for a process that died.
A restart after a crash is never locked out by its own predecessor.