Repository navigation
Description
Component
Memory and search
Describe what's wrong
On the default ClickHouse memory authority, memory.lock, memory.unlock and memory.verify replace a memory.update that has already returned.
Each op reads the head and inserts a full version through insert_versions_over_heads. With LOOM_STORAGE_AUTHORITY=clickhouse that insert does not check that the head is still the row that was read. version_over is taken when the copy is built, so the copy's version is later than an update committed from the same head a moment earlier. loom.memory is ReplacingMergeTree(version), so the copy becomes the head and still carries the value from the read.
strong=True on the head read waits out a lagging replica. It does not stop a writer that commits between the read and the insert.
With LOOM_STORAGE_AUTHORITY=postgres, the same insert commits only when the head is still that version (heads_unchanged(exact=True)). A moved head raises 503 ADMISSION_CONTENDED. The ClickHouse path does not.
Run on commit 5fbc62c with pg.enabled() false. handle_memory_lock read a head whose value was proposed at version 100. version_over of that head was taken first, standing in for an update that had already returned. The lock insert that followed stored proposed at a higher version. Two HTTP clients against ClickHouse were not run.
Does it reproduce on the latest release or main?
Yes
How to reproduce
Default settings (LOOM_STORAGE_AUTHORITY=clickhouse). Auth is not required for this sequence.
memory.seta key toproposed.- Start
memory.lockon that key and pause it after the head read, before the insert. memory.updatethe same key torejectedand wait until that call returns.- Let the lock insert finish.
memory.getthe key.
The get returns proposed, with the lock columns. The update already returned success for rejected.
memory.unlock and memory.verify do the same thing: build_memory_version_row from the head they read, then insert_versions_over_heads. No migration was read; ClickHouse was not queried.
Expected behavior
A write that has returned stays the head, unless a later write read that new value. docs/architecture/storage-authority.md says a copy on the ClickHouse authority is a plain insert, and a write with a lower version that lands between the read and the insert is overtaken and nothing reports it. The Postgres path refuses that copy. Lock, unlock and verify should refuse or retry when the head has moved, on both authorities.
Environment
Source: ClickHouse/loom main, commit 5fbc62c21a, package version 1.3.0
Python: 3.14.6
Platform: macOS arm64
LOOM_STORAGE_AUTHORITY: clickhouse (the default)
ClickHouse: not queried
Related issues and pull requests
Related: #142
How this was found
An AI tool found it, and I have not reproduced it myself
Additional context
The in-process lock insert is the reproduction. It shows the copy that ReplacingMergeTree(version) would keep. It is not two concurrent HTTP calls.
Redaction
- I removed tokens, keys, passwords and personal or customer data from everything above.
Activity
zlareb1 commentedon Nov 20, 2026
Related: #1029
The expiry sweep builds its version from the scanned head and inserts it through the same
insert_versions_over_headspath.