t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: SQLite writer replies wake the WAL checkpoint worker on almost every statement

Open jonathanli12 opened this issue 2 days ago • 0 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

packages/shared

Steps to reproduce

  1. Open a disposable WAL database with the Node SQLite client and writerWorker: true.
  2. Count postMessage(0) calls on the checkpoint worker. Submit a burst of sequential inserts, awaiting each statement inside transactions.
  3. Compare the count with a fixed 50 ms timer started by the first reply. Subsequent replies share that timer without resetting it. Wait for the last scheduled notification before reading the count.

Expected behavior

A burst of writer replies should generate one worker notification per 50 ms window. A trailing notification should let the worker catch up when writes stop.

Actual behavior

The scheduler sends one notification per event-loop turn with a writer reply. Five paired runs of a disposable HTTP replay server persisted and streamed the same 3,000 events in 188 transactions. Median notifications fell from 10,381 to 54 (99.5%) with a fixed 50 ms deadline. Main-thread CPU medians were 1,409 ms and 1,394 ms. The median paired CPU reduction was 4.5%, with a range from 5.7% slower to 9.0% faster. Ordered event logs and projection digests matched across runs. The pinned-reader test still trimmed the WAL to its configured limit.

Impact

Minor bug or occasional failure

Version or commit

main at 8190a7f3098f has the same SQLite client code as the replay baseline.

Environment

Linux, Node 26.13.1

jonathanli12 avatar Nov 29 '26 19:11 jonathanli12