Repository navigation
Conversation
…ely; superseded rows of retired crawls collected once, in budgeted cursor chunks #288 #289 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/retention-289-288
branch
from
October 30, 2026 19:34
d9035d0 to
1e622aa
Compare
… lock stays short #289 Signed-off-by: Nik Cubrilovic <[email protected]>
Contributor
Author
|
Landed in v0.0.145 as nik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #288
Fixes #289
#288: an audit killed while building its report (reworked after review: conservative, never delete when in doubt)
SQLiteStorage.listInterruptedReports()lists abuildingcrawl only when ALL hold: its build began more than 6 hours ago (newcrawls.building_at, stamped bysetReportStatus(..., "building"), migration 40; a crawl from before that waits 7 days on its last page write), a LATER audit of the project completed with a report, and its owner is not live (isLeaseLive: a heartbeat under 5 min, or an owner pid alive on this host however old the heartbeat, so a laptop asleep over a weekend is live; another host with a stale heartbeat cannot be probed, so only the 6 h build clock covers it).retainRecentAuditsretires one only when at leastkeepopenable audits are newer than it, so the candidate ordering stays the authority on the window: a crawlsquirrel analyzerebuilt (it leavesbuildingon purpose, #955) and that sits inside the window is never retired.retireCrawlsDetailedre-checks the predicate inside its transaction.self disk --pruneplans around a still-building crawl (listed under skipped asbuilding, not counted, not retired) and reports how many audits the transaction held back.#289: rows superseded before automatic retention
Migration 39 only creates a marker table.
repairSupersededPagesOnce()walks the retired crawls' rows by rowid in transactions of 500 rows (a legacy inline-html db measured about 3 s of write lock per 5,000 rows, so the chunk is small) with a cursor stored beside the marker (a row that stays is examined once, not once per chunk), stops after a 2 s budget per call (at least one chunk), and writes the marker only when a pass finds nothing left to examine and runs fromretainRecentAuditsandrunProjectPrune, never frominit(), so no command that merely opens project databases (self disk) pays for it and no writer waits on one long transaction. A url whose only row is in a retired crawl keeps it. The CHANGELOG notes that a removed row was the db's only pointer to that page's stored HTML (corpus users).Tests
packages/crawler/tests/retention-289-288.test.ts(14): init does not delete; repair removes superseded rows once, keeps only copies, is chunked and resumable (partial run leaves no marker); building_at is stamped and untouched by analyze's keepBuilding; 7 h building is listed, 1 h is not whatever its pages' age, legacy NULL waits a week; owner pid alive with a 3-day-old heartbeat is live; fresh other-host heartbeat live, stale one only after the clock; newer-than-every-finished never listed; in-transaction re-check; query plan scans no pages or frontier.apps/cli/tests/audit/retention.test.ts: killed audit recovered with 3 newer audits, an analyze-rebuilt audit inside the window is not retired, a just-started build is left alone.tests/self/disk-prune.test.ts: the plan skips a building crawl.Gates: tsgo in crawler and apps/cli, apps/cli lint and format, crawler liveness, abandoned, url-index, lease and migration tests, retention and disk-prune tests,
make validate. Schema version is now 40 (39 marker table, 40 building_at). Schema 39 collides with draft #1205: whoever merges second renumbers. Skill: no change needed. CHANGELOG under Unreleased / Fixed.Re-review follow-ups: rowid cursor + per-call 2 s budget (tests: many only-copy rows cost chunks not chunks squared; budget 0 does one chunk per call and later calls finish); the pid-reuse limit of
isLeaseLiveis documented in code (space only, never data). Rebased on main (schema 38 there; 39 and 40 here).Chunk round: default chunk 500 (was 5,000); retention-289-288 now has 17 tests (new: default chunk is 500).