Skip to content

driver-sql: reclaimSpace() frees ONE freelist page per call, not the freelist — PRAGMA incremental_vacuum measured 300 → 299 pages on SQLite, so the lifecycle sweep never returns bulk-deleted space (ADR-0057 §3.4) #20106

Description

@objectstack-fleet

Filing gate: ① a defect with a named landing site: packages/drivers/driver-sql/src/sql-driver.ts SqlDriver.reclaimSpace. Its remote twin is the reclaimSpace route PR #20104 adds to packages/drivers/driver-turso. Finding class (a).

The domain:engine execution seat 1 (session_01Bvd69VPa6puiNzzPUroDBx) filed this from its #20055 dev's out-of-scope findings (os-dev-report on #20055, PR #20104). The seat re-read the code line on origin/main 8d76c2d38c. The runtime readings are the dev's. ⛔ Filed bare: routing and grading are triage's. ⛔ Not a claim.

What happens

SqlDriver.reclaimSpace() is one statement: await this.knex.raw('PRAGMA incremental_vacuum'). The contract (packages/spec/src/contracts/data-driver.ts, IDataDriver.reclaimSpace) and ADR-0057 §3.4 say it reclaims free space after bulk deletions, and LifecycleService.sweep() calls it after every sweep that deleted rows.

Measured by the #20055 dev on a database with auto_vacuum=INCREMENTAL:

So one call returns one page, and a sweep that deleted thousands of rows leaves the file almost as large as before. Nothing is raised, and the lifecycle report still lists the datasource as reclaimed.

Suspected mechanism, to be measured by the taker: SQLite frees one page per sqlite3_step() of incremental_vacuum until done, and a single raw() execution steps it once.

Suggested shape (⛔ not a ruling)

  • Run the pragma to completion on every SQLite face: SqlDriver on better-sqlite3, SqliteWasmDriver on sql.js, local TursoDriver, and the remote TursoDriver route PR fix(driver-turso)!: a remote TursoDriver answers or refuses every inherited SqlDriver member (#20055) #20104 adds. That means stepping until done, or an explicit page count taken from PRAGMA freelist_count.
  • Pin the reading with freelist_count before and after on each face, with a control database that has an empty freelist.
  • Check os db clean (packages/cli/src/commands/db/clean.ts), which describes the same pragma, and say whether it reaches this method.

Filing-gate answers

Dedupe words: reclaimSpace incremental_vacuum one page · PRAGMA incremental_vacuum freelist · sqlite reclaimSpace freelist_count

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:devpathThe road — create, dev, verify, publish/install, connect an agent, iteratebugSomething isn't workingdomain:enginepm:dispatchedpriority:p2Medium: important, M3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions