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

"asks ledger failed: database is locked" two minutes after a release (v0.7.733) #18169

opened this in answer to

Merged 14h 43m ago, live in production

The asks ledger write that logged "database is locked" is now try-once, so it no longer holds the serving thread. A write behind a draining forge's lock is skipped and picked up again on the next tick. The new test and the asks, holds and job-slices suites pass, and tsc is clean.

Notes

opened this

The asks ledger write that logged "database is locked" is now try-once, so it no longer holds the serving thread. A write behind a draining forge's lock is skipped and picked up again on the next tick. The new test and the asks, holds and job-slices suites pass, and tsc is clean. I could not check the "three releases log 0 error lines" condition from here; that only shows after the next releases.

  • Which write: it was recordAskLedger in src/web/studio/asks.ts. It runs every 2 minutes, from the engine tick (src/engine/duties.ts) or the serving tick (src/main.ts). The earlier fix made the ledger take the write lock first, but each viewer's BEGIN IMMEDIATE still waited out the 5 s busy timeout while the old forge held the lock.
  • Fix: each viewer's sync now runs under withoutWaiting, like telemetry. If the database is busy, the tick stops and returns how many people it left, and logs nothing. The ledger is rebuilt from what asks people at each tick, so nothing is lost and the next tick catches up. Errors that are not "busy" still log as errors.
  • Log line: both call sites now add step ("engine tick: recordAskLedger" or "serving tick: recordAskLedger") to the "asks ledger failed" line.
  • Test (test/ask-ledger-lock.test.ts): a second connection holds BEGIN IMMEDIATE across recordAskLedger. The tick returns well under the 5 s timeout, reports people left, throws nothing and writes no rows. After the lock is released, the next tick writes the same rows a quiet database would.
  • Not done: I added no new retry loop or queue, since the next tick is the retry. The step is on the log line, not threaded through every write inside the ledger. There is no page, terminal or docs change, because this is a background tick, and the commit says so in No door and No look lines.
  • Reused: withoutWaiting and isBusy from src/kernel/db.ts; no new function was written.

To try it on the preview, open /asks. It lists the same asks, and the ledger line under it still counts them.

[{"go":"/asks","look":"the asks list and the 'Asks, 7 days' measure line","expect":"unchanged from production: same asks, same counts"}]

Closes #18157

commented

The asks ledger write that logged "database is locked" is now try-once, so it no longer holds the serving thread. A write behind a draining forge's lock is skipped and picked up again on the next tick. The new test and the asks, holds and job-slices suites pass, and tsc is clean. I could not check the "three releases log 0 error lines" condition from here; that only shows after the next releases.

  • Which write: it was recordAskLedger in src/web/studio/asks.ts. It runs every 2 minutes, from the engine tick (src/engine/duties.ts) or the serving tick (src/main.ts). The earlier fix made the ledger take the write lock first, but each viewer's BEGIN IMMEDIATE still waited out the 5 s busy timeout while the old forge held the lock.
  • Fix: each viewer's sync now runs under withoutWaiting, like telemetry. If the database is busy, the tick stops and returns how many people it left, and logs nothing. The ledger is rebuilt from what asks people at each tick, so nothing is lost and the next tick catches up. Errors that are not "busy" still log as errors.
  • Log line: both call sites now add step ("engine tick: recordAskLedger" or "serving tick: recordAskLedger") to the "asks ledger failed" line.
  • Test (test/ask-ledger-lock.test.ts): a second connection holds BEGIN IMMEDIATE across recordAskLedger. The tick returns well under the 5 s timeout, reports people left, throws nothing and writes no rows. After the lock is released, the next tick writes the same rows a quiet database would.
  • Not done: I added no new retry loop or queue, since the next tick is the retry. The step is on the log line, not threaded through every write inside the ledger. There is no page, terminal or docs change, because this is a background tick, and the commit says so in No door and No look lines.
  • Reused: withoutWaiting and isBusy from src/kernel/db.ts; no new function was written.

To try it on the preview, open /asks. It lists the same asks, and the ledger line under it still counts them.

[{"go":"/asks","look":"the asks list and the 'Asks, 7 days' measure line","expect":"unchanged from production: same asks, same counts"}]
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs