Skip to content

test: give the flushed compaction loop a timeout that fits it - #54

Merged
AndresSaa merged 1 commit into
mainfrom
test/give-the-fsync-compaction-loop-room
Aug 8, 2026
Merged

test: give the flushed compaction loop a timeout that fits it#54
AndresSaa merged 1 commit into
mainfrom
test/give-the-fsync-compaction-loop-room

Conversation

@AndresSaa

Copy link
Copy Markdown
Owner

The failure

Node 24 / windows-latest went red on #48 — a pull request bumping publint and typescript-eslint, neither of which can reach this code:

Error: Test timed out in 5000ms.
 ❯ test/wal.security.test.ts:125:3

Re-running the job passed, and it is the only CI failure in the last 25 runs. So: a real flake, not a regression, and not caused by the pull request it blocked.

Why this test is slow

It is the only test in the suite that loops flushed writes. With fsync: true, each of its 20 iterations costs five storage flushes:

Operation Flushes
append the log descriptor
checkpoint the checkpoint file (flush: true) + syncDirectory after the rename
compact the compacted file + syncDirectory after the rename

A hundred flushes in total. On my Windows machine that is 134 ms; on a loaded CI runner it exceeded 5000 ms — a 37× spread. That number is a property of the host filesystem, not of the code, which is the same reason the README quotes the fsync: true append cost as a range (0.47–1.49 ms) rather than a figure.

Since the test body is synchronous, the timeout cannot interrupt it — it is a "this took too long" assertion measured after the fact.

The fix, and what it deliberately is not

Raised to 30_000, matching what wal.property.test.ts already uses.

Neither cheaper option was acceptable:

  • Fewer iterations — accumulation is precisely what repetition exposes. A loop of 3 stops testing the thing.
  • Dropping fsync: true — that moves the test off the path that writes the temporaries it is checking for.

Both would have been weakening a test to make CI green, which is the one thing AGENTS.md rules out.

Proof the limit is real

That the test passes proves nothing — it passed before. So I checked the argument is actually honoured, by setting it to 1 ms:

Error: Test timed out in 1ms.
 Tests  1 failed | 6 skipped (7)

The limit is wired, not decorative. Restored to 30_000 afterwards.

npm run lint → clean
npm test     → 69 passed (5 files)

Contract impact

None. Test-only, and no changelog entry — nothing observable changes for a consumer.

This test failed once on a Windows runner at the 5 s default, on a pull request
that bumped two lint packages — nothing that could touch it. It runs a hundred
storage flushes: twenty appends, and per iteration a checkpoint file plus its
directory and a compacted file plus the directory its rename lands in. Locally
that is 134 ms; on a loaded runner it passed 5 s.

Raising the limit rather than shrinking the test is the point. Dropping
iterations would weaken what it checks — accumulation is what repetition
exposes — and dropping `fsync` would move it off the path that writes the
temporaries at all. What varies here is the filesystem, not the code, which is
the same reason the measured append range spans 0.47-1.49 ms between NTFS and
ext4.

30 s matches what the property tests already use. Confirmed the argument is
honoured rather than assumed: set to 1 ms it fails with "Test timed out in
1ms", so the limit is real and not decorative.
@AndresSaa
AndresSaa merged commit 46abba1 into main Aug 8, 2026
12 checks passed
@AndresSaa
AndresSaa deleted the test/give-the-fsync-compaction-loop-room branch August 8, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant