TECHNOLOGY

Coordinate artifact publishers with a stable local lock file

In this article
THE QUICK TAKE

Lock a stable coordination inode, not the manifest being replaced, and account for shared descriptor lifetime across dup, fork and cleanup.

Two artifact publishers both believe they own the same exclusive lock after replacing a manifest. They locked the data file being replaced, so later openers reached a different inode. Advisory flock coordinates a shared file object, not the permanent spelling of a pathname. Use a stable coordination object and preserve its lifecycle separately from the revision being published.

Choose a stable lock identity

Keep a dedicated local lock file whose underlying identity is not replaced during publication. Every cooperating publisher must open and lock that same object before entering the protected operation. Deleting and recreating the lock pathname while a holder remains active can split coordination again. A familiar filename is insufficient if participants no longer refer to the same underlying file.

Define the cooperating boundary

Flock is advisory under the ordinary local-file semantics discussed here. An unrelated writer that ignores the protocol can still modify the artifact. Define which publishers and cleanup processes participate and which operations the lock covers. Do not call the lock an authorization boundary or assume it validates model contents, revision identity or the safety of files prepared before acquisition.

Preserve descriptor lifetime

Linux associates these locks with an open file description. Duplicated or fork-inherited descriptors share the lock, and release depends on explicit unlocking or closure of all corresponding references. A child that retains an inherited descriptor can therefore extend ownership unexpectedly. Independent opens behave differently, even within one process. Record the actual descriptor relationships when diagnosing a lock that appears to survive its expected owner.

Handle contention explicitly

Choose blocking or nonblocking acquisition under a documented application deadline. Preserve contention, interruption and other failures as separate outcomes. Flock does not supply application-level deadlock detection or an ordering scheme for several resources. If publication requires multiple locks, define a consistent acquisition order and cleanup path rather than treating an exclusive flag as proof that the broader workflow cannot deadlock.

Publish and release deliberately

Under the acquired lock, prepare, validate and atomically publish the intended local revision according to its own protocol. Release only after the protected decision is complete, while keeping durability requirements explicit. Test concurrent publishers, holder failure and inherited descriptors in an isolated equivalent. A useful result establishes mutual exclusion among cooperating participants; network-filesystem locking behavior and distributed ownership need separate qualification.

Primary references

Linux Advisory flock Lifetime.

Linux Open File Descriptions and Directory Handles.

Linux Atomic Rename and Filesystem Boundaries.

Related reading: Init container downloads an artifact again: making preparation idempotent; Keep tokenizer vocabulary, special tokens and chat templates in one release.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles