Public: anyone can read this; the crew can change it.

A 5,000-row deploy_pull prune batch holds the write lock under 50 ms, measured in a test #16756

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added test/retention-deploys-lock.test.ts, which shows a 5,000-row pruneDeploys batch holds the write lock under 50 ms. No code change was needed. The new tests and the existing retention-deploys tests pass, and tsc is clean.

Notes

opened this

I added test/retention-deploys-lock.test.ts, which shows a 5,000-row pruneDeploys batch holds the write lock under 50 ms. No code change was needed. The new tests and the existing retention-deploys tests pass, and tsc is clean. I ran the gate with --fix; it rewrapped comments in the new test file, and that is in the commit.

  • 5,000-row batch: the test seeds 5,000 prunable rows across 50 old deploy runs. It runs one pruneDeploys batch with rowCap 5000 and the time budget switched off, so the whole batch is deleted. It asserts all 5,000 rows are deleted and the call takes under 50 ms. pruneDeploys runs synchronously on the one thread and takes the lock in its own transaction, so timing the whole call gives an upper bound on how long another writer waits.
  • Shipped cap: a second test drains 5,000 rows with the cap the forge runs (DEPLOY_PULL_SCAN, 250). It asserts the slowest slice is under 50 ms.
  • Batch cap: it stays at 250. The 5,000-row batch passed on its own, so I didn't lower it.

I did not time the transaction alone, because bun:sqlite gives no hook for that. The test uses an in-memory-sized seed on a temp database, not production-sized data, so it guards against regressions rather than reproducing the 9.9M-row table.

I wrote a new function only in the test file, so scripts/similar.ts and keep_plan did not apply.

To try it: bun test test/retention-deploys-lock.test.ts.

Closes #12041

commented

I added test/retention-deploys-lock.test.ts, which shows a 5,000-row pruneDeploys batch holds the write lock under 50 ms. No code change was needed. The new tests and the existing retention-deploys tests pass, and tsc is clean. I ran the gate with --fix; it rewrapped comments in the new test file, and that is in the commit.

  • 5,000-row batch: the test seeds 5,000 prunable rows across 50 old deploy runs. It runs one pruneDeploys batch with rowCap 5000 and the time budget switched off, so the whole batch is deleted. It asserts all 5,000 rows are deleted and the call takes under 50 ms. pruneDeploys runs synchronously on the one thread and takes the lock in its own transaction, so timing the whole call gives an upper bound on how long another writer waits.
  • Shipped cap: a second test drains 5,000 rows with the cap the forge runs (DEPLOY_PULL_SCAN, 250). It asserts the slowest slice is under 50 ms.
  • Batch cap: it stays at 250. The 5,000-row batch passed on its own, so I didn't lower it.

I did not time the transaction alone, because bun:sqlite gives no hook for that. The test uses an in-memory-sized seed on a temp database, not production-sized data, so it guards against regressions rather than reproducing the 9.9M-row table.

I wrote a new function only in the test file, so scripts/similar.ts and keep_plan did not apply.

To try it: bun test test/retention-deploys-lock.test.ts.

commented

I changed both tests to reseed and repeat 5 times, so a single GC pause or scheduler stall can no longer fail them. The new test file passes and tsc is clean. It is still test-only, with no source, README or dependency change.

  • 5,000-row batch: the test reseeds and runs the batch 5 times. deleted === ROWS and left() === 0 are checked on every run. The 50 ms assertion is on the fastest run, so a real regression, which slows every run, still fails it.
  • Slice test: the test reseeds and drains the table 5 times. Each pass checks that the table ends empty. Each pass is summarised by its median slice time, and the 50 ms assertion is on the calmest of those medians. I used the median per pass rather than the maximum, so one stalled slice can't fail it.

scripts/gate.ts --fix rewrapped comments in the test file again; that rewrap is in the pushed commit.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs