store: since 6ee9a77c a record written in place (uses.rs recorded) is freed while its entry names it; 288 missing at 243ff75d's start #91

Closed
opened 2026-11-16 22:22:20 +00:00 by xemmerling · 0 comments
Owner

Since 6ee9a77c ("store: a pass reads what changed since the pass before") the store's collection frees the record blob of an entry whose record was written in place, while the entry stands and names it.

What production showed. 243ff75d's start at 22:04Z to 22:09Z logged 291 times the record of a cache entry is not in the store: blob … missing (cargo/known.rs:425, KnownCache::add_page, read from entries.rec_hash), 288 distinct blobs. No saved log of an earlier build has the line once, 6ee9a77c's own start at 20:18Z included. The blobs were gone before this server deleted anything (its first store pass ended 22:14:17Z), so the passes of 6ee9a77c's leadership (20:28Z to 22:03Z) took them. No entry was dropped for a blob the store lacks (lost="the store": none), so only records went.

The mechanism, read in the code.

  • CacheServer::recorded (jobs/cache/uses.rs:134, the UPDATE at line 209, from 31f6e3ac) keeps the record a job made of an entry it found: it puts the record's blob and writes UPDATE entries SET rec_hash = $3 WHERE key1 = $1 AND trust = $2, committed with Last::Nothing. The row keeps its seq, and the log gets no record.
  • CacheServer::named (jobs/cache/collect.rs:320) after the first whole read takes in only rows with a seq past its cursor (entries_page) and the log's removals (removals_page). A row whose rec_hash changed in place has neither, so Named keeps the key's old blobs.
  • The new record's blob is then named by nothing, and goes with "what nothing names past the short grace". The old one stays named until the entry goes.

Before 6ee9a77c every pass read every row as it was, so the row's current rec_hash was a root each time.

What it costs. By record_read's own words such an entry is "a hit all the same": only the forecast of its unit loses its record, at the next start. It also repeats: the next job that finds the entry sees its record missing, records it again, and the blob goes again a pass later. Nothing was judged wrongly.

The invariant it breaks is the one named states: "what every pass reaches is exactly what its live entries name", the record's blob among them.

What I am doing. As a fix that restores a documented invariant I am having it made now, built on your code and touching nothing else of the pass: recorded tells the collection's Named the key's new record blob after its commit (the old hash swapped for the new where the key is known; a key the whole read has not reached is read as it is), with a test in collect.rs that a pass after an in-place record keeps the new blob. If you would rather have the update take a log number, or have already fixed it, say so here and I drop mine.

22:42Z 11-16: the fix is 3b1d9a5b on branch dev/record-named, in the check set

One commit on 243ff75d, four files (jobs/cache/collect.rs, jobs/cache/uses.rs, docs/spec.md, docs/storage.md):

  • Named keeps a second map, records: the record each key's row was given in place. blobs() returns those hashes beside the entries' own.
  • recorded puts every key it wrote into the map once its transaction has committed, whatever the entries' read has reached, so a page read before the write and taken in after it is harmless. removals_page lets go of the key in both maps.
  • The map is not trimmed when a page reads the row again: a record the row no longer names stays named until its entry goes, a few kilobytes, in exchange for no race between a page and the write.
  • recorded also marks its records used (keep) under the rows' locks just before it commits, as a put marks an entry's blobs, and writes nothing if one is missing. The store's put had marked them, but before the waits for a connection and the rows.
  • A test in collect.rs, a_record_written_in_place_is_named_until_its_entry_goes: a pass, a record written through the real recorded, a pass that must keep the record's blob and name it, the entry's removal, a pass that must free it.

t's whole check set is running for it on testing. It lands as a fast-forward only if every check passes and this issue has no comment by then. Beside it I run the same test on a commit that has the test and not the fix, to see it fail there; I will add both results here. I will not promote it in the middle of the push wave.

22:50Z 11-16: the test fails without the fix and passes with it; the first check set was red on another test

  • Without the fix (a commit never to land: 3b1d9a5b's tree with uses.rs as on 243ff75d, so the collection has the map and nothing fills it), test/t alone on testing, run r643a4f47d8: failed on exactly jobs::cache::collect::tests::a_record_written_in_place_is_named_until_its_entry_goes, at collect.rs:682: "the record the entry names stays: Collected { reached: 1, deleted: 1, … }". The second pass deleted the record, as production's did.
  • With the fix (candidate 3ed89cc3 = 243ff75d + 3b1d9a5b), t's whole check set on testing, run re9d49d5f8d: that test and the rest of jobs::cache passed; fmt, the three clippy checks, test/t-cache, test/t-wrapper and vm-cargo passed.
  • That set was red all the same, on one test the change does not touch: ci::tests::checks_failing_across_a_range_of_heads_share_log2_probe_runs (#88, at ci/tests.rs:764). So it did not land. The whole set is running again.

23:05Z 11-16: landed as 1497415d; not on production yet

  • Was the red set the fix's? No. I ran test/t whole and fresh on testing for two trees that differ only by the fix (main's head plus a comment line, and main's head plus the fix plus the same line): both were red on checks_failing_across_a_range_of_heads_share_log2_probe_runs alone, and both were green when that test was asked again by itself (runs r8fa2540463 and rb3b32a1b30, then r080abab381 and re2bd368668). Details in #88.
  • The third set for the fix was green: run r7095430754, 8 passed, 7 cached, none failed. This issue had no comment, so it landed as a fast-forward at 23:03:28Z: main is 1497415d (243ff75d before).
  • Production still serves 243ff75d. The fault costs forecasts, not verdicts, and a restart in the middle of the push wave costs more than it saves, so I promote it when the heads' queue has drained, or it rides your next promote if that comes first. This issue stays open until a start after the promote shows no record missing for blobs written under the fixed build.

23:31Z 11-16: on production since 23:29:53Z

Testing took 1497415d at 23:09Z and its whole check set was green there (run redc036f57d); the forge workflow on it is green too (run 1517). I promoted it at the first quiet minute: production held 8 CI jobs at 23:29:14Z. New server pod t-58fd9f769b-wwndd, epoch 593; the worker fetched the build at 23:29:55Z and re-attached 33 jobs, none unattachable, no error.

The records this start finds missing are what the passes before it freed; I save their hashes. The proof is the start after this one: it must name no missing record that is not in that list. This issue stays open until then.

23:44Z 11-16: twelve minutes on production, nothing against it

  • Hand-over: 30 jobs crossed the restart and ended with a verdict, none as an error, and no check had a second job started while its first still ran (8 checks in 4 runs at the 22:03Z promote, 3 in 1 at 20:18Z): a quiet minute cuts nothing.
  • Store passes: the first whole pass 535 s, then 51, 22, 25 and 30 s (57 s mean before). Memory: 10.2 GB resident at ten minutes with 20 runs held, as 6ee9a77c had at that age.
  • Entries dropped for a blob the store lost: none.
  • Records missing at this start: 27 so far, none of them among the 306 hashes the build before named missing. They are records written in place under 243ff75d and freed by its passes; their list is kept. The next start has to name no missing record outside it.

01:41Z 11-17: proven at the next start; closed

The proof owed was the next server start: every record it finds missing had to be one the faulty builds had already lost.

server start build "the record of a cache entry is not in the store"
22:03:58Z 11-16 243ff75d, without the fix 291 lines, 288 blobs
23:29:53Z 11-16 1497415d, the fix 27 lines in its first 12 minutes, 131 blobs by 00:53Z: what the builds before had freed
00:59:13Z 11-17 f4172b7f, the fix plus three commits 0 lines in 42 minutes and 21,238 log lines

Between the last two starts the server on 1497415d wrote records in place for 89 minutes under full load. None of them is missing at the 00:59Z start, so a record written in place is now named until its entry goes. Also 0 entries dropped for lost="the store" on both fixed starts.

Since 6ee9a77c ("store: a pass reads what changed since the pass before") the store's collection frees the record blob of an entry whose record was written in place, while the entry stands and names it. **What production showed.** 243ff75d's start at 22:04Z to 22:09Z logged 291 times `the record of a cache entry is not in the store: blob … missing` (`cargo/known.rs:425`, `KnownCache::add_page`, read from `entries.rec_hash`), 288 distinct blobs. No saved log of an earlier build has the line once, 6ee9a77c's own start at 20:18Z included. The blobs were gone before this server deleted anything (its first store pass ended 22:14:17Z), so the passes of 6ee9a77c's leadership (20:28Z to 22:03Z) took them. No entry was dropped for a blob the store lacks (`lost="the store"`: none), so only records went. **The mechanism, read in the code.** - `CacheServer::recorded` (`jobs/cache/uses.rs:134`, the UPDATE at line 209, from 31f6e3ac) keeps the record a job made of an entry it found: it puts the record's blob and writes `UPDATE entries SET rec_hash = $3 WHERE key1 = $1 AND trust = $2`, committed with `Last::Nothing`. The row keeps its `seq`, and the log gets no record. - `CacheServer::named` (`jobs/cache/collect.rs:320`) after the first whole read takes in only rows with a `seq` past its cursor (`entries_page`) and the log's removals (`removals_page`). A row whose `rec_hash` changed in place has neither, so `Named` keeps the key's old blobs. - The new record's blob is then named by nothing, and goes with "what nothing names past the short grace". The old one stays named until the entry goes. Before 6ee9a77c every pass read every row as it was, so the row's current `rec_hash` was a root each time. **What it costs.** By `record_read`'s own words such an entry is "a hit all the same": only the forecast of its unit loses its record, at the next start. It also repeats: the next job that finds the entry sees its record missing, records it again, and the blob goes again a pass later. Nothing was judged wrongly. **The invariant it breaks** is the one `named` states: "what every pass reaches is exactly what its live entries name", the record's blob among them. **What I am doing.** As a fix that restores a documented invariant I am having it made now, built on your code and touching nothing else of the pass: `recorded` tells the collection's `Named` the key's new record blob after its commit (the old hash swapped for the new where the key is known; a key the whole read has not reached is read as it is), with a test in `collect.rs` that a pass after an in-place record keeps the new blob. If you would rather have the update take a log number, or have already fixed it, say so here and I drop mine. ## 22:42Z 11-16: the fix is 3b1d9a5b on branch `dev/record-named`, in the check set One commit on 243ff75d, four files (`jobs/cache/collect.rs`, `jobs/cache/uses.rs`, `docs/spec.md`, `docs/storage.md`): - `Named` keeps a second map, `records`: the record each key's row was given in place. `blobs()` returns those hashes beside the entries' own. - `recorded` puts every key it wrote into the map once its transaction has committed, whatever the entries' read has reached, so a page read before the write and taken in after it is harmless. `removals_page` lets go of the key in both maps. - The map is not trimmed when a page reads the row again: a record the row no longer names stays named until its entry goes, a few kilobytes, in exchange for no race between a page and the write. - `recorded` also marks its records used (`keep`) under the rows' locks just before it commits, as a put marks an entry's blobs, and writes nothing if one is missing. The store's `put` had marked them, but before the waits for a connection and the rows. - A test in `collect.rs`, `a_record_written_in_place_is_named_until_its_entry_goes`: a pass, a record written through the real `recorded`, a pass that must keep the record's blob and name it, the entry's removal, a pass that must free it. t's whole check set is running for it on testing. It lands as a fast-forward only if every check passes and this issue has no comment by then. Beside it I run the same test on a commit that has the test and not the fix, to see it fail there; I will add both results here. I will not promote it in the middle of the push wave. ## 22:50Z 11-16: the test fails without the fix and passes with it; the first check set was red on another test - **Without the fix** (a commit never to land: 3b1d9a5b's tree with `uses.rs` as on 243ff75d, so the collection has the map and nothing fills it), `test/t` alone on testing, run r643a4f47d8: failed on exactly `jobs::cache::collect::tests::a_record_written_in_place_is_named_until_its_entry_goes`, at `collect.rs:682`: "the record the entry names stays: Collected { reached: 1, deleted: 1, … }". The second pass deleted the record, as production's did. - **With the fix** (candidate 3ed89cc3 = 243ff75d + 3b1d9a5b), t's whole check set on testing, run re9d49d5f8d: that test and the rest of `jobs::cache` passed; fmt, the three clippy checks, `test/t-cache`, `test/t-wrapper` and `vm-cargo` passed. - That set was red all the same, on one test the change does not touch: `ci::tests::checks_failing_across_a_range_of_heads_share_log2_probe_runs` (#88, at `ci/tests.rs:764`). So it did not land. The whole set is running again. ## 23:05Z 11-16: landed as 1497415d; not on production yet - **Was the red set the fix's?** No. I ran `test/t` whole and fresh on testing for two trees that differ only by the fix (main's head plus a comment line, and main's head plus the fix plus the same line): both were red on `checks_failing_across_a_range_of_heads_share_log2_probe_runs` alone, and both were green when that test was asked again by itself (runs r8fa2540463 and rb3b32a1b30, then r080abab381 and re2bd368668). Details in #88. - **The third set** for the fix was green: run r7095430754, 8 passed, 7 cached, none failed. This issue had no comment, so it landed as a fast-forward at 23:03:28Z: main is 1497415d (243ff75d before). - **Production** still serves 243ff75d. The fault costs forecasts, not verdicts, and a restart in the middle of the push wave costs more than it saves, so I promote it when the heads' queue has drained, or it rides your next promote if that comes first. This issue stays open until a start after the promote shows no record missing for blobs written under the fixed build. ## 23:31Z 11-16: on production since 23:29:53Z Testing took 1497415d at 23:09Z and its whole check set was green there (run redc036f57d); the forge workflow on it is green too (run 1517). I promoted it at the first quiet minute: production held 8 CI jobs at 23:29:14Z. New server pod t-58fd9f769b-wwndd, epoch 593; the worker fetched the build at 23:29:55Z and re-attached 33 jobs, none unattachable, no error. The records this start finds missing are what the passes before it freed; I save their hashes. The proof is the start after this one: it must name no missing record that is not in that list. This issue stays open until then. ## 23:44Z 11-16: twelve minutes on production, nothing against it - **Hand-over:** 30 jobs crossed the restart and ended with a verdict, none as an error, and no check had a second job started while its first still ran (8 checks in 4 runs at the 22:03Z promote, 3 in 1 at 20:18Z): a quiet minute cuts nothing. - **Store passes:** the first whole pass 535 s, then 51, 22, 25 and 30 s (57 s mean before). **Memory:** 10.2 GB resident at ten minutes with 20 runs held, as 6ee9a77c had at that age. - **Entries dropped for a blob the store lost:** none. - **Records missing at this start:** 27 so far, none of them among the 306 hashes the build before named missing. They are records written in place under 243ff75d and freed by its passes; their list is kept. The next start has to name no missing record outside it. **01:41Z 11-17: proven at the next start; closed** The proof owed was the next server start: every record it finds missing had to be one the faulty builds had already lost. | server start | build | "the record of a cache entry is not in the store" | |---|---|---| | 22:03:58Z 11-16 | 243ff75d, without the fix | 291 lines, 288 blobs | | 23:29:53Z 11-16 | 1497415d, the fix | 27 lines in its first 12 minutes, 131 blobs by 00:53Z: what the builds before had freed | | 00:59:13Z 11-17 | f4172b7f, the fix plus three commits | 0 lines in 42 minutes and 21,238 log lines | Between the last two starts the server on 1497415d wrote records in place for 89 minutes under full load. None of them is missing at the 00:59Z start, so a record written in place is now named until its entry goes. Also 0 entries dropped for `lost="the store"` on both fixed starts.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
tilo/t#91
No description provided.