Repository navigation
test(timeline): pin the refused directory fsync - #3304
Conversation
|
@Birfy — review request for this tip: T2 ( Two commits, deliberately: Controls that stay red-by-design and are the reason this is not a duplicate of Birfy's #3300: a file A |
785238c to
daa1837
Compare
|
@Birfy — review request for this tip: T2 ( Three commits, each with one job: Why it is not a duplicate of Red first, stated by method because the two readings differ:
Narrow mutations at the tip, each against the full 22: delete the directory A |
f290a36 to
9efc2dc
Compare
Windows answers EPERM for `fsync` on a directory handle (EINVAL on a filesystem without directory flushes), and it is the last step of `writeWhole`, after the temporary file was synced and renamed. Since ThinkFlowLab#3300 `flushDirectory` tolerates that refusal, so a segment that is already in place still counts as saved and is not rewritten on every flush (ThinkFlowLab#3298, ThinkFlowLab#3301). A Linux directory fsync is a no-op success, so the three cases pin the `fsyncSync` binding `store.js` imports (through node:module's `syncBuiltinESMExports()`) and refuse only directory handles: EPERM still saves the segment (flush true, `failing` false, not rewritten by the next flush, records read back after a reopen), EINVAL is tolerated the same way, and a rotation still prunes to the cap while the directory fsync is refused. Emptying the tolerated set turns all three red. Docs-not-needed: tests only; no product behaviour and no documented write order changes. Refs ThinkFlowLab#3301
9efc2dc to
c4940e7
Compare
|
Verdict: PASS at c4940e7 Scope: 1 file, Ran at this tip: Red first — with #3300's tolerance removed from
Checks at c4940e7: The one red in the full-suite run is environmental, not this PR: |
…d file fsync still fail the write (#3314) Fixes #3311 Bot: FlyBot Dev-3 Owner: Dev-3 Written-by: Dev-3 ## What this adds Three cases in `plugins/timeline/test/store.test.js`, in the same style the merged `#3304` cases use: `fs.fsyncSync` is replaced for the duration of the case through `syncBuiltinESMExports`, refusing only the handles that case needs. No product file changes — the behaviour `main` ships is `#3300`'s tolerance. - **file `EIO`**: a file fsync that fails still fails the write — `flush() === false`, `stats().failing === true`, exactly one warning carrying `EIO`, and the segment is not published; - **directory `EACCES`**: a directory fsync refused for a reason beyond the platform refusals (`EPERM`/`EINVAL`) still fails the write; - **deferred lock**: a `retryLock` trace adopts the lock once the live writer closes, writes its records once with the directory fsync refused, and a reopen reads them back (`#3298` measured that hand-over never settling). ## Red first (mutation) At the tip, `node --test plugins/timeline/test/store.test.js` → **22/22**. Each case is red under the mutation it exists for, and only that case: | mutation to `plugins/timeline/src/store.js` | reading | | --- | --- | | the file `fsyncSync` wrapped in the same swallowing `try` | 21/22 — `not ok 20`, `a file fsync that fails with EIO still fails the write` | | `noDirectoryFlush` widened to `['EPERM', 'EINVAL', 'EACCES']` | 21/22 — `not ok 21`, `a directory fsync refused with EACCES is still a failed write` | | `noDirectoryFlush` emptied (the pre-`#3300` shape) | 18/22 — `not ok 17, 18, 19, 22`; the deferred case fails at `false !== true`, `the adopted lock plus a refused directory sync still saves` | The deferred case also has its red on the record from our `#3304` branch: on `848bc314` (`store.js` with the directory fsync and no tolerance) the same assertion reads `false !== true`. Reproduced here by running this test file against that commit's `store.js` — red at `plugins/timeline/test/store.test.js:407`. ## Verification at the tip - tip `5bb1486aa8cf8349692a8f4b7912f6c2ba2e29f3`, tree `ca25f53c437d5323cedd90330fe0c334d22d136f`, base `9a48f5aa4bd49c8cae0d80fb4da3a74d02af0f99` - `node --test plugins/timeline/test/store.test.js` → 22/22, rc 0 - `npm --prefix plugins/timeline test` (with `DSH_HARNESS` at the DSH install) → 178/178, 0 fail, rc 0 - `node .github/scripts/changelog.mjs check` → 0 fragments - `ARCH_DOCS_BASE=9a48f5aa node scripts/check-arch-docs.mjs` → `OK (1 changed file(s))` - Not run: plugin lint — `oxlint` is not installed on this box; CI runs it. Docs-not-needed: tests only under `plugins/timeline/test`; no behaviour and no architecture change — the tolerance `main` ships is `#3300`'s. ## Checkpoint <!-- flybot:checkpoint --> ```json { "pr": 3314, "claim": "Dev-3", "issue": 3311, "summary": "Adds the three cases our #3304 branch carried that the merged rewrite dropped: a file fsync that fails with EIO, a directory fsync refused with EACCES, and a deferred retryLock writer saving once after the live writer leaves with the directory fsync refused. Each is red under the product mutation it exists for. Tests only; no product file changes.", "files": ["plugins/timeline/test/store.test.js"], "checks": { "ran": "node --test plugins/timeline/test/store.test.js", "result": "green", "at": "5bb1486aa8cf8349692a8f4b7912f6c2ba2e29f3" }, "next": "draft pending the FlyBot Test advisory at this tip; then ready and the verdict" } ``` <!-- /flybot:checkpoint -->
Fixes #3301
Owner: Dev
Written-by: Dev
Reviewer: Reviewer
Docs-not-needed: tests only; no product behaviour and no documented write order changes.
What this is
The fix is already in
main:#3300(merged as1d06764b) madeflushDirectorytolerate a refused directoryfsync— EPERM on Windows, EINVAL on a filesystem without directory flushes — so a segment that was synced and renamed is not rewritten on every flush. This branch is rebased ontomain(664f48fd); the old tip'ssrc/store.jschange andchangelog.d/3301.fixed.mdare gone. The diff is one file:plugins/timeline/test/store.test.js.mainhas nosyncoption to inject a refusal, so the cases pin thefsyncSyncbindingstore.jsimports withnode:module'ssyncBuiltinESMExports()— the seam the repo already uses inds-bot/test/store.test.js. Only directory handles are refused: the file sync stays real, so the cases cannot paper over a failing file sync.What the three cases pin
flush()is true,stats().failingis false, the segment is not rewritten by the next flush, and the records read back after a reopen.trace-000002.json/trace-000003.jsonand the surviving records are[3, 4, 5, 6].Red first, same tree with only
noDirectoryFlushemptied (new Set([]); src restored afterwards):node --test test/store.test.js→ 16 pass / 3 fail, exactly the three cases above.Ran at this tip:
Not run: real Windows (the refusal is Windows-only; the cases inject it), arch-docs (
core/scripts/check-arch-docs.mjsshells out togit, absent here; the commit carriesDocs-not-needed:), fullnpm run verify, and CI's Node 24 leg.Checkpoint
{
"pr": 3304,
"claim": "Dev",
"issue": 3301,
"summary": "Rebased onto main 664f48f with the implementation dropped: #3300 already tolerates a refused directory fsync, so the diff is one test file. Three cases pin it by refusing only directory handles through the fsyncSync binding store.js imports: EPERM still saves the segment and it is not rewritten, EINVAL is tolerated the same way, and a rotation still prunes to the cap. Emptying the tolerated set turns all three red.",
"files": [
"plugins/timeline/test/store.test.js"
],
"checks": {
"ran": "cd plugins/timeline && TZ=UTC npm test; TZ=UTC node --import ./test/resolve.mjs --test test/store.test.js; node scripts/lint-plugins.mjs timeline; node .github/scripts/changelog.mjs check",
"result": "green",
"at": "c4940e7977d0edc75a9167258a84ad9d6500a636"
},
"next": "none — ready for review"
}