Repository navigation
Pigeonhole 0.2.3: cross-shard timestamp-order fix (D244, D245)
A fix for a lost write under concurrent cross-shard and single-shard commits. Upgrade recommended for every 0.2.x user whose writes span shards. The file format is unchanged, and files written by 0.2.0 to 0.2.2 open as before. Every published crate moves to 0.2.3 together. 0.3.0, released alongside, has the same fix.
Fixed
- A write could be lost behind an earlier cross-shard commit to the same row (#653, D244, D245).
- When: a commit wrote rows on more than one shard, and another thread wrote the same rows on one of those shards just after it, without explicit timestamps. More likely with many threads and busy shards, with tablet changes on or off.
- What happened: the shard could give the later single-shard write a default timestamp below the cross-shard commit's. Reads then returned the cross-shard commit's older value, and the later write was lost.
- The fix: the coordinating shard raises every participant's timestamp floor before it takes the commit's sequence number, so later writes there stamp above the commit (D245). A participant also refuses a commit whose timestamp would land out of order with writes it has already made, and the commit is retried with a fresh timestamp (D244).
- Side effect: a cross-shard commit refused this way is retried internally. Like one refused for a tablet change, it gets
Busyafter 16 refusals or the write-stall timeout. That is rare, since the floor raise prevents almost every refusal.
Known issue
#655, also in 0.2.2: a cross-shard commit that finds a participant's memtable arena full waits for room while holding its sequence number, and that participant's flush waits for the same sequence number to become visible. With a real clock the wait ends at the write-stall timeout (Options::write_stall_timeout, 30 s by default): the commit, and writes queued behind it on that shard, get Busy and can be retried. It needs a full arena, so a larger Options::memtable_budget makes it rarer. 0.3.0 refuses such a commit and retries it once room frees, instead of letting it wait (D245); that change is not backported.
Upgrading
Change nothing but the version: pigeonhole = "0.2" resolves to 0.2.3 after cargo update -p pigeonhole. The fix can't repair a write already lost: a cell whose newest value is older than one you wrote after it keeps that value until it is written again. Single-shard workloads, and writes that set explicit timestamps, were not affected.
How it was tested
- The fix is a port of main's D244 and D245 onto
release/0.2.x's structure (#719). Main's tests were ported with it, and the #653 regression test fails on 0.2.2 and passes on 0.2.3. - Mutation checks: dropping the coordinator's floor raise fails six tests, and dropping the participant's floor check fails the move test.
- The full
pigeonhole-enginesuite, clippy, rustdoc and four seed sweeps on CI runners, all green.
Details: #653 (the bug and its reproduction), D244 and D245 (the rule changes), #654 and #679 (main), #719 (this backport), #722 (release prep).