AETERNAE AI RESEARCH LLC INDEPENDENT RESEARCH
ÆAETERNAERESEARCH
Sign inRequest access
← Malware catalog

Attributed metadata history

REPORTPUBLIC METADATA

Distributed locks are leases: why you need fencing tokens

Here's how a distributed lock ends up held by two processes at once, with no bug in the lock itself: Worker 1 acquires the lock, with a 10-second lease so that a crashed holder can't block everyone forever. Worker 1 pauses. A long garbage-collection pause, a virtual machine being migrated, a process swapped to disk, a slow network call. Fifteen seconds pass. The lease expires. Worker 2 acquires the lock and starts its work. Worker 1 resumes. From its point of view, no time has passed: it holds the lock. It carries on writing. Two writers, one "exclusive" resource. Martin Kleppmann laid this out clearly in his 2016 essay on distributed locking, and it applies to every lock with a timeout, whichever store implements it: Redis, ZooKeeper, etcd, a database row. The underlying point: a distributed lock with a timeout is a lease, and a lease can end without its holder finding out in time. Checking "do I still hold the lock?" before writing doesn't help, because the pause can happen between the check and the write. The fix: fencing tokens Every time the lock service grants the lock, it also hands out a number that only ever increases: the fencing token. The holder includes the token with every write to the protected resource, and the resource rejects any write whose token is lower than the highest it has already accepted. The lock can't stop a paused holder. The resource can. Explore the interactive diagram The important shift is where the check happens. The lock service can't stop a paused process from waking up and writing; only the thing being written to can. So the resource does the final check, at the moment of the write, which is the only moment that matters. Where the token comes from You need a counter that increases with every grant: ZooKeeper: the transaction id or the node's version number, or a sequential node, increases with every change. etcd: the revision number of the lock key increases with every write. A database: the lock is a row, and acquiring it increments a column in the same statement. -- acquire: succeeds only if the lease is free or expired; returns the new token UPDATE locks SET holder = :me, token = token + 1, expires_at = now() + interval '10 seconds' WHERE name = 'invoice-run' AND (holder IS NULL OR expires_at < now()) RETURNING token; A plain Redis SET key value NX PX 10000 gives you a lease but no ordered token. You can add one (an INCR on a separate key in the same Lua script), but at that point consider whether a store with ordering built in is the better tool. Where the check happens The resource has to remember the highest token it has accepted and compare. In a database, that's a conditional write: UPDATE invoice_runs SET status = :status, last_token = :token WHERE id = :id AND last_token < :token; -- 0 rows updated: a newer lock holder has already written; stop For files or object storage, keep the last token alongside the data (in metadata, or a version field) and make the write conditional on it. Many object stores support conditional writes on a version or ETag, which you can build this on. If the resource can't check tokens (a third-party API, an email being sent), a fencing token can't protect it. Then the operation itself has to be safe to do twice: an idempotency key the third party honours, or a record of "already sent" checked in the same transaction as the work. Efficiency locks vs correctness locks Kleppmann's essay makes a distinction worth keeping: Efficiency locks stop two workers doing the same work twice, to save cost. If the lock occasionally fails, you waste some compute. A simple lease (one Redis key with a timeout) is fine. Correctness locks stop two workers corrupting data. If the lock fails, you get wrong data. These need fencing, or a design that doesn't depend on the lock at all. Before choosing a lock implementation, decide which kind you have. Most arguments about locking alg

Reference details

Source category
research-report
First reported
Dec 03, 2026 06:21 UTC
Last reported
Dec 03, 2026 06:21 UTC
Catalog updated
Dec 03, 2026 06:25 UTC
Record ID
805625f47bf22f12dffb3495975339dba791c1437829cf2b31912cd844ae234f

Published indicators

Network indicators are visibly defanged. This page does not make them clickable or send them to another service.

No validated file hashes or network indicators are stored for this record.

Source observations

intelligence_src_6dc544294b7f21f98a

Source-provided label
Publisher RSS metadata
Evidence class
mentioned in report
Confidence
Not reported
Observed
Dec 03, 2026 06:21 UTC
Retrieved
Dec 03, 2026 06:25 UTC

This record contains metadata and attribution only. It does not host, download, unpack, render, or execute malware samples.

Feed collection status

Sources represented on this page. Publication and observation dates describe the content; successful batch dates describe local collection. A recent batch does not certify complete coverage or current provider availability.

1 sources: 0 stale, 0 needing attention, 0 paused, 0 unverified.

Review source update dates and status
  • intelligence_src_6dc544294b7f21f98aRecent successful batchLast successful batch: Last attempt:

Stale means older than twice the recorded collection interval, with a minimum of one hour; without an interval, the threshold is 24 hours. Cached content remains available while a feed is stale, paused, or unverified.