Repository navigation
[ZC: WW.3.S] UM-1689: let the cleanup wait for the application's write lock - #2130
Conversation
|
@kody start-review |
This comment has been minimized.
This comment has been minimized.
|
Automatic approval held Kody's assessment:
|
…it back The cleanup writes to the same database the application writes to, and the connection's busy timeout was the driver's default of five seconds while the application's fifteen-minute maintenance cycle holds the write lock for longer than that, so the cleanup failed with SQLITE_BUSY on the writer lock, twice. Waiting is only half of it: SQLite has one writer, and the cleanup takes the write lock a thousand times over, so the application's own writes wait behind it and time out. That is not a theoretical cost, because the application's scheduler tick failed with SQLITE_BUSY while the cleanup was running. The cleanup now waits up to two minutes for the lock, gives the transaction five minutes, and pauses between shards so the application can have the lock. The pause costs about four minutes over the whole run and keeps the service it is cleaning up working. Nothing about what is deleted changes: the plan is the reviewed plan, every shard's digest is checked, every row is re-read and compared with its fingerprint, and the backup is verified before the first shard.
7b00571 to
775fec4
Compare
This comment has been minimized.
This comment has been minimized.
The cleanup now waits for the application's write lock, and the timeout it sets has to survive a client that cannot set it: the test suite's stubbed client has no raw-query method, so the pragma was failing the run before the work it was meant to protect. The pragma is best effort now, and a client that cannot set it still runs: the lock wait falls back to the driver's default and a busy database is reported as the busy database it is, rather than the cleanup failing for a reason of its own.
|
@kody start-review |
This comment has been minimized.
This comment has been minimized.
514e239 to
26e45f8
Compare
The cleanup finished and verified itself: 448,977 rows deleted across 4,490 shards, every shard with a receipt, zero candidates left, zero keeper checks failed, and a tombstone for every removed row. The ledger says the same thing from the other side: grouping the Claude Code rows on the transcript's session id, the message id inside it and the label, and counting the groups that span two collector instances gives zero, where there were 447,209. The row counts per day are the distinct counts exactly: November 29 holds 11,165 rows and November 30 holds 18,288, where the ledger held 22,316 and 36,564.
26e45f8 to
8dc9bdf
Compare
This comment has been minimized.
This comment has been minimized.
|
@kody start-review |
Code Review Could Not Complete
|
| Options | Enabled |
|---|---|
| Bug | ✅ |
| Performance | ✅ |
| Security | ✅ |
| Business Logic | ✅ |
[ZC: WW.3.S] UM-1689: let the cleanup wait for the application's write lock
Fixes UM-1689 (follow-up to #2125).
Summary
Increase the cleanup’s wait for the application’s SQLite write lock: it now uses a 30-second busy timeout, and each shard transaction has a 60-second timeout. This gives the resumable cleanup more time to wait for application maintenance writes instead of failing with
SQLITE_BUSYand requiring the run to be resumed.Add a test that checks the transaction timeout remains longer than the configured busy timeout. The deletion plan and safeguards are unchanged.
Summary
The duplicate-line cleanup now waits up to 120 seconds for the database write lock instead of failing after the driver’s short default wait. Its transaction timeout is extended to five minutes, giving lock waits room to complete, and the cleanup pauses for 50 ms between shards so the live application can write to the SQLite database.
The deletion plan, per-shard receipts, fingerprint checks, and backup verification are unchanged. A test was added to ensure the transaction timeout remains longer than the configured busy timeout; no test execution is reported.
Summary
Updated the Claude duplicate cleanup to tolerate contention with the live application's SQLite writes. The cleanup now requests a 120-second busy timeout and allows up to five minutes for each shard transaction, so it can wait for a write lock rather than failing immediately. It also pauses for 50 ms between shards to give the application opportunities to write and avoid making its own writes time out.
Added a test that checks the transaction timeout is longer than the configured busy timeout. The deletion plan, row verification, and backup checks are unchanged.
The rollout document reports a completed cleanup and continued application operation; those outcomes are documented there, not established by the code changes or test evidence in this patch.
Summary
Cleanup now waits longer for the application’s SQLite write lock and pauses briefly between shards so the application can acquire the lock while cleanup runs. The cleanup transaction timeout is extended to allow the lock wait, and a test checks that it remains longer than the configured busy timeout.
The cleanup’s deletion plan and verification safeguards are unchanged. The rollout notes report a completed run with 448,977 rows deleted across 4,490 shards, but this description does not independently verify those results.