Stability: specs that are not repeat- or parallel-safe (--workers=2 --repeat-each=10): shared vault grows, what is known #1182

Open
opened 2026-11-15 23:49:29 +00:00 by kayg · 1 comment
Owner

Opened at the orchestrator's request (the #1136 lane saw --workers=2 --repeat-each=10 failures at dev 42c219afd that a --workers=1, no-repeat train does not: chromium-1440 tasks-card, tasks-swipe, tasks-tick 43 / 180; chromium-390 journal-trash, search-palette, swipe-rows, task-check, tasks-tick 32 / 540; webkit-1440 tasks-board, window-layout 9 / 140, see #1136 (comment)).

All of the e2e specs share one server and one vault for the whole run: every repeat and every worker adds tasks (made()), notes and tags, and nothing is removed. The Today list therefore keeps growing during a run (the link-states request in one trace carried 17 Tasks/*.md paths; it carries one more per task made), and a spec that was written against a short list meets a different page from the third repeat on. What I found, with evidence, for the tasks-tick family (the only one I could take apart in this lane):

Cause Kind Evidence Status
A forced click (click({ force: true })) on a tick box that Playwright left at the bottom edge of the phone's window lands on the floating Search pill and opens Search test race that grows with the list #1165, deterministic red (pill field press at y=819.8 of 844) PR #1167
tasks.set-status answered 503 not_saved_yet (retryable) while the server publishes, shown as a failure product bug trace of a failing repeat; #1179 PR #1181
tasks.set-status answered 409 block_changed while the task note's room still holds the save of the write that made it (the spec's own made()), for several seconds on a busy server (answers took 2.9 to 4.8 s); the client retried only within 3 s of its own write and counted the window in seconds product bug (client policy), server slowness behind it traces of failing repeats; #1179 PR #1181
notes.link-states asked about ~27 times a second for ever on the open Tasks screen, every request carrying all Tasks/*.md paths of the vault: load on the server that grows with the vault product bug #1178: 80 requests in 3 s on dev PR #1180

Measured on dev-02, chromium-1440, tasks-tick.spec.ts, --workers=2 --repeat-each=10: dev 6 / 80 fail; #1181 alone 1 / 100; #1180 + #1181 together 1 / 100 (the one left is a server answering changed for more than 14 s, i.e. server latency under load, not examined). At --workers=1 --repeat-each=30 the unfixed spec failed 1 / 240 on webkit-390 (the covered click), then 239 / 240 on webkit-1440 and webkit-390 (a request answered after 20 s on a loaded host) and 240 / 240 chromium-1440 with #1167.

Not examined here (no root cause claimed): tasks-card, tasks-swipe (#1176), journal-trash, swipe-rows, task-check, tasks-board, window-layout, search-palette:47 (#1113). Suggested first step for each: look at the page's network log in the failing repeat (a trace has it) for 503 / 409 answers and for link-states volume, and check whether the spec's target row is at the edge of the window (the elementFromPoint check in #1165). A spec that needs a short list should make its own list (a tag or project of its own, as pane-transition does for notes) instead of reading Today.

Added: with #1167 + #1178 + #1179 together, chromium-390 --repeat-each=30 on one server still fails from about repeat 22 on (every test: set-status sent, no answer in 20 s; dev-01 shows the same without the fixes: 84 / 240 fail). Server-side cause not found.

Opened at the orchestrator's request (the #1136 lane saw `--workers=2 --repeat-each=10` failures at dev `42c219afd` that a `--workers=1`, no-repeat train does not: chromium-1440 tasks-card, tasks-swipe, tasks-tick 43 / 180; chromium-390 journal-trash, search-palette, swipe-rows, task-check, tasks-tick 32 / 540; webkit-1440 tasks-board, window-layout 9 / 140, see https://git.kayg.org/kayg/calternal/pulls/1136#issuecomment-97985). All of the e2e specs share **one server and one vault for the whole run**: every repeat and every worker adds tasks (`made()`), notes and tags, and nothing is removed. The Today list therefore keeps growing during a run (the `link-states` request in one trace carried 17 `Tasks/*.md` paths; it carries one more per task made), and a spec that was written against a short list meets a different page from the third repeat on. What I found, with evidence, for the `tasks-tick` family (the only one I could take apart in this lane): | Cause | Kind | Evidence | Status | |---|---|---|---| | A forced click (`click({ force: true })`) on a tick box that Playwright left at the bottom edge of the phone's window lands on the floating Search pill and opens Search | test race that grows with the list | #1165, deterministic red (`pill field press` at y=819.8 of 844) | PR #1167 | | `tasks.set-status` answered **503 `not_saved_yet`** (retryable) while the server publishes, shown as a failure | product bug | trace of a failing repeat; #1179 | PR #1181 | | `tasks.set-status` answered **409 `block_changed`** while the task note's room still holds the save of the write that made it (the spec's own `made()`), for several seconds on a busy server (answers took 2.9 to 4.8 s); the client retried only within 3 s of its own write and counted the window in seconds | product bug (client policy), server slowness behind it | traces of failing repeats; #1179 | PR #1181 | | `notes.link-states` asked about ~27 times a second for ever on the open Tasks screen, every request carrying all `Tasks/*.md` paths of the vault: load on the server that grows with the vault | product bug | #1178: 80 requests in 3 s on dev | PR #1180 | Measured on dev-02, chromium-1440, `tasks-tick.spec.ts`, `--workers=2 --repeat-each=10`: **dev 6 / 80 fail; #1181 alone 1 / 100; #1180 + #1181 together 1 / 100** (the one left is a server answering `changed` for more than 14 s, i.e. server latency under load, not examined). At `--workers=1 --repeat-each=30` the unfixed spec failed 1 / 240 on webkit-390 (the covered click), then 239 / 240 on webkit-1440 and webkit-390 (a request answered after 20 s on a loaded host) and 240 / 240 chromium-1440 with #1167. **Not examined here (no root cause claimed):** tasks-card, tasks-swipe (#1176), journal-trash, swipe-rows, task-check, tasks-board, window-layout, search-palette:47 (#1113). Suggested first step for each: look at the page's network log in the failing repeat (a trace has it) for `503` / `409` answers and for `link-states` volume, and check whether the spec's target row is at the edge of the window (the `elementFromPoint` check in #1165). A spec that needs a short list should make its own list (a tag or project of its own, as pane-transition does for notes) instead of reading Today. **Added:** with #1167 + #1178 + #1179 together, chromium-390 `--repeat-each=30` on one server still fails from about repeat 22 on (every test: `set-status` sent, no answer in 20 s; dev-01 shows the same without the fixes: 84 / 240 fail). Server-side cause not found.
Author
Owner

#1182 root cause found and fixed in PR #1184 (fix/server-1182, head c5e152a7c): not a deadlock, the executor journal was re-read in full on every write

What hung, and how it was found

On dev-02 I reproduced the failure with one server, tasks-tick.spec.ts, chromium-390 --workers=1 --repeat-each=30, on dev 81c7fb951. While it ran I took 8 gdb -p samples of the live debug server (thread apply all bt), 3 s apart.

  • The server was busy at about 75 % CPU, so nothing was blocked.
  • Every busy thread was in serde_json inside write_executor::journal::read ← NoteWriteExecutor::load / records(), deserialising Payload/Image byte arrays or re-serialising records for their checksum.
  • The data dir held 196 journal records, 33 MB (users/<id>/notes/write-executor/*.json). The newest record was 338 KB, for a 15 KB daily note.

Why that is slow: each Home write (tasks.set-status) loads the executor journal about 7 times (replay lookup, recovery ×3, admission, after commit), and every load parsed and re-hashed every record. Payload compaction is withheld, so the journal gains one record per tick. A tick therefore costs O(all earlier ticks).

  • No lock, channel or task was stuck.
  • Requests queued behind the Home's jobs mutex while each write took seconds. From about repeat 22 (dev-02) or repeat 16 (dev-01, a busier host) the 20 s poll expired.
  • The long transactions also held room leases and the inventory window open much longer, which made the 503/409 answers seen in the #1179 traces more likely.

Test time per repeat on the baseline (dev 81c7fb951, chromium-390, one server, --workers=1):

Repeats dev-02 median / max dev-01 median / max
1–3 1.1 s / 1.9 s 3.6 s / 5.4 s
10–12 4.6 s / 8.6 s 14.5 s / 28.0 s
16–18 7.7 s / 14.7 s 23.1 s / 41.8 s (4 failed)
28–30 18.5 s / 37.8 s stopped at repeat 18 to free dev-01
Total 239/240, 33.0 min 4 of 126 failed by repeat 18

Fix 1: parse each journal file once (journal::read cache)

Validated records are kept per journal dir, keyed by the file's identity (inode, size, mtime, ctime, taken from the handle that read it). Records are only ever replaced by rename, so new bytes are always parsed and validated again, and the ancestry check still runs over all records. The cache is released when the Home unloads after going idle.

Deterministic test a_write_parses_only_the_records_it_wrote_however_long_the_journal:

  • red at 0db09e0dc: "one write parsed 40 record files";
  • green at the fix: at most 2 files for a write plus the next read, and 0 for a re-read of an unchanged journal.
  • Also new: a same-length record replaced by rename is refused again; a forgotten cache reads the same records.

Fix 2: plan again when the Home moved (the 409/503 "while saving")

Every task's owning line is in the same daily note, so concurrent ticks and captures all write that note.

  • 409: the executor refuses a stale plan before recording anything ("callers may plan again", write_executor::home::core). Tasks answered that as 409 block_changed, although the client's version was right.
  • 503: a plan that read the day's note while another tick's transaction held it got 503 not_saved_yet. One such 503 was seen 5 ms after the request in a --workers=2 trace on the first fix.
  • Fix: tasks.set-status / tasks.move now plan again, at most 4 times (10–160 ms apart). A stale task version is still refused at once.
  • Tests: an owner write between plan and submit is planned again (red with REPLANS = 0, which is the old single pass); a Home that keeps moving is refused after 5 plans; a busy note while planning is planned again; a stale task version gets 1 plan and a 409.

After

tasks-tick chromium-390 --workers=1 --repeat-each=30, one server:

Build Host Result Wall time Median per repeat
72948d1ec (fix 1) dev-01 240/240 11.9 min 2.1 s → 4.0 s
72948d1ec (fix 1) dev-02 239/240, 4.8 min flat ~1.0 s
head 3e51db3ac dev-02 240/240 3.9 min (baseline 33.0 min) 0.7 s → 1.2 s, max 2.1 s

The one dev-02 failure on fix 1 was Playwright's own ENOENT on a trace file: I started a second run in the same worktree, which cleared test-results. That was my mistake, not the product.

tasks-tick chromium-1440 --workers=2 --repeat-each=10 (the #1179 setup, dev-02):

  • dev: 6/80 failed.
  • Fix 1: 2/80 failed. One was a 409 in 34 ms, which fix 2 removes; the other was the "typing" test, with set-status answered 200.
  • 7e9ed92ed: 80/80.
  • Head 3e51db3ac: 79/80. The one failure (tasks-tick:107, box not checked) has no tasks.set-status request in its trace: the forced click never reached the row while the other worker's tasks reflowed the shared Today list. That is a client/test race of the #1165 kind, not the server.

Gates at head (dev-02; per the orchestrator, chromium logic specs also ran on dev-02)

  • Rust: cargo fmt --all -- --check rc 0 at c5e152a7c; cargo clippy --workspace --all-targets -- -D warnings rc 0; cargo test --workspace 1905 passed, 0 failed at 3e51db3ac.
  • One earlier workspace run had a single failure, notes tests::event_visibility::save_outside_retry, while other jobs were running. It passed 10/10 on dev 81c7fb951 and 10/10 on 3e51db3ac, so it does not block under the flaky rule.
  • Playwright e2e/tasks- at 3e51db3ac, --workers=1: webkit-1440 57/57, webkit-390 43 passed / 14 skipped, chromium-1440 57/57, chromium-390 43 passed / 14 skipped.
  • c5e152a7c only reformats test-only code; the release binary's code is unchanged.

Perf: ticket srv1182 is queued on perf-01, behind tf1b, dav794, mail-1011 and nf3c. Arms: dev e0808d27… = dev2, inert faf1a014… (inert-patch seed 1), cand bb97fba5… (3e51db3ac). Layouts: --state and single root; cells save_ack/typing; plus idle and typing wake-up runs. Results will follow on #1184.

#1181: not needed for these failures. The 409s and 503s it retried came from the slow writes and from server-internal races that the server now absorbs. Its 503 retry still matches the retryable: true contract, so keeping only that part is harmless; I'd drop the retry of block_changed the device didn't cause.

Open (separate): the executor journal still grows until its 1 GiB budget and then refuses Home writes, because payload compaction is withheld pending a retention decision. With about 300 KB per tick on a 200-task day, that is a few thousand ticks per Home.

## #1182 root cause found and fixed in PR #1184 (`fix/server-1182`, head `c5e152a7c`): not a deadlock, the executor journal was re-read in full on every write ### What hung, and how it was found On dev-02 I reproduced the failure with one server, `tasks-tick.spec.ts`, `chromium-390 --workers=1 --repeat-each=30`, on dev `81c7fb951`. While it ran I took 8 `gdb -p` samples of the live debug server (`thread apply all bt`), 3 s apart. - The server was busy at about 75 % CPU, so nothing was blocked. - Every busy thread was in `serde_json` inside `write_executor::journal::read` ← `NoteWriteExecutor::load` / `records()`, deserialising `Payload`/`Image` byte arrays or re-serialising records for their checksum. - The data dir held **196 journal records, 33 MB** (`users/<id>/notes/write-executor/*.json`). The newest record was 338 KB, for a 15 KB daily note. **Why that is slow:** each Home write (`tasks.set-status`) loads the executor journal about 7 times (replay lookup, recovery ×3, admission, after commit), and every load parsed and re-hashed **every** record. Payload compaction is withheld, so the journal gains one record per tick. A tick therefore costs O(all earlier ticks). - No lock, channel or task was stuck. - Requests queued behind the Home's jobs mutex while each write took seconds. From about repeat 22 (dev-02) or repeat 16 (dev-01, a busier host) the 20 s poll expired. - The long transactions also held room leases and the inventory window open much longer, which made the 503/409 answers seen in the #1179 traces more likely. **Test time per repeat on the baseline** (dev `81c7fb951`, chromium-390, one server, `--workers=1`): | Repeats | dev-02 median / max | dev-01 median / max | |---|---|---| | 1–3 | 1.1 s / 1.9 s | 3.6 s / 5.4 s | | 10–12 | 4.6 s / 8.6 s | 14.5 s / 28.0 s | | 16–18 | 7.7 s / 14.7 s | 23.1 s / 41.8 s (**4 failed**) | | 28–30 | 18.5 s / 37.8 s | stopped at repeat 18 to free dev-01 | | Total | 239/240, 33.0 min | 4 of 126 failed by repeat 18 | ### Fix 1: parse each journal file once (`journal::read` cache) Validated records are kept per journal dir, keyed by the file's identity (inode, size, mtime, ctime, taken from the handle that read it). Records are only ever replaced by rename, so new bytes are always parsed and validated again, and the ancestry check still runs over all records. The cache is released when the Home unloads after going idle. Deterministic test `a_write_parses_only_the_records_it_wrote_however_long_the_journal`: - **red** at `0db09e0dc`: "one write parsed 40 record files"; - **green** at the fix: at most 2 files for a write plus the next read, and 0 for a re-read of an unchanged journal. - Also new: a same-length record replaced by rename is refused again; a forgotten cache reads the same records. ### Fix 2: plan again when the Home moved (the 409/503 "while saving") Every task's owning line is in the same daily note, so concurrent ticks and captures all write that note. - **409:** the executor refuses a stale plan before recording anything ("callers may plan again", `write_executor::home::core`). Tasks answered that as 409 `block_changed`, although the client's version was right. - **503:** a plan that read the day's note while another tick's transaction held it got 503 `not_saved_yet`. One such 503 was seen 5 ms after the request in a `--workers=2` trace on the first fix. - **Fix:** `tasks.set-status` / `tasks.move` now plan again, at most 4 times (10–160 ms apart). A stale task version is still refused at once. - **Tests:** an owner write between plan and submit is planned again (red with `REPLANS = 0`, which is the old single pass); a Home that keeps moving is refused after 5 plans; a busy note while planning is planned again; a stale task version gets 1 plan and a 409. ### After **`tasks-tick` `chromium-390 --workers=1 --repeat-each=30`, one server:** | Build | Host | Result | Wall time | Median per repeat | |---|---|---|---|---| | `72948d1ec` (fix 1) | dev-01 | **240/240** | 11.9 min | 2.1 s → 4.0 s | | `72948d1ec` (fix 1) | dev-02 | 239/240, 4.8 min | | flat ~1.0 s | | head `3e51db3ac` | dev-02 | **240/240** | **3.9 min** (baseline 33.0 min) | 0.7 s → 1.2 s, max 2.1 s | The one dev-02 failure on fix 1 was Playwright's own `ENOENT` on a trace file: I started a second run in the same worktree, which cleared `test-results`. That was my mistake, not the product. **`tasks-tick` `chromium-1440 --workers=2 --repeat-each=10`** (the #1179 setup, dev-02): - dev: 6/80 failed. - Fix 1: 2/80 failed. One was a 409 in 34 ms, which fix 2 removes; the other was the "typing" test, with set-status answered 200. - `7e9ed92ed`: **80/80**. - Head `3e51db3ac`: 79/80. The one failure (`tasks-tick:107`, box not checked) has **no `tasks.set-status` request in its trace**: the forced click never reached the row while the other worker's tasks reflowed the shared Today list. That is a client/test race of the #1165 kind, not the server. ### Gates at head (dev-02; per the orchestrator, chromium logic specs also ran on dev-02) - Rust: `cargo fmt --all -- --check` rc 0 at `c5e152a7c`; `cargo clippy --workspace --all-targets -- -D warnings` rc 0; `cargo test --workspace` **1905 passed, 0 failed** at `3e51db3ac`. - One earlier workspace run had a single failure, `notes tests::event_visibility::save_outside_retry`, while other jobs were running. It passed 10/10 on dev `81c7fb951` and 10/10 on `3e51db3ac`, so it does not block under the flaky rule. - Playwright `e2e/tasks-` at `3e51db3ac`, `--workers=1`: webkit-1440 57/57, webkit-390 43 passed / 14 skipped, chromium-1440 57/57, chromium-390 43 passed / 14 skipped. - `c5e152a7c` only reformats test-only code; the release binary's code is unchanged. **Perf:** ticket `srv1182` is queued on perf-01, behind tf1b, dav794, mail-1011 and nf3c. Arms: dev `e0808d27…` = dev2, inert `faf1a014…` (inert-patch seed 1), cand `bb97fba5…` (`3e51db3ac`). Layouts: `--state` and single root; cells save_ack/typing; plus idle and typing wake-up runs. Results will follow on #1184. **#1181:** not needed for these failures. The 409s and 503s it retried came from the slow writes and from server-internal races that the server now absorbs. Its 503 retry still matches the `retryable: true` contract, so keeping only that part is harmless; I'd drop the retry of `block_changed` the device didn't cause. **Open (separate):** the executor journal still grows until its 1 GiB budget and then refuses Home writes, because payload compaction is withheld pending a retention decision. With about 300 KB per tick on a 200-task day, that is a few thousand ticks per Home.
Sign in to join this conversation.
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
kayg/calternal#1182
No description provided.