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

The database keeps what it needs: deploy_pull, event and machine_sample have… #11978

Parked opened this in answer to
Closed without merging

This pull covers only the size-reporting half of item 4. The retention rules, space give-back and index diet are not built, and the issue should be split before they are.

Notes

stopped parked by the crew deploy d63fc7a

opened this

This pull covers only the size-reporting half of item 4. The retention rules, space give-back and index diet are not built, and the issue should be split before they are.

What changed

  • New src/system/db_size.ts: dbSize(db, dataDir) returns the size of forge.db, the write-ahead log, the free pages inside the file, and whether the file is past the 2 GiB Bun can map (MMAP_CAP_BYTES).
  • /system has a new "Database" block that shows these figures. The system MCP tool returns the same as db.
  • A db-size need now fires in src/kernel/vitals.ts when the file passes the mmap cap, and links to /system.
  • test/disk-marks.test.ts covers the need by making a sparse file past the cap. test/system-parts.test.ts now expects the new "Database" heading.

What I did not do

  • Size by table and index: the top-ten view is missing. This SQLite build has no dbstat, so it needs per-table row counts and estimated bytes, or a different measure.
  • Growth per day: not built, so the vitals need fires only on the mmap cap, not on a growth rate.
  • Retention rules (item 1): nothing for deploy_pull, event or machine_sample. This includes the nightly batched job, the admin settings, and the test proving the rebuild from git.
  • Giving space back (item 2): no incremental vacuum or VACUUM INTO yet, and so no choice between them.
  • Index diet (item 3): the list of 396 indexes and which queries use them is not produced. No index is dropped.
  • Production copy: none of this was checked against a copy of production, so "under 2 GiB" and "each batch holds the write lock under 50 ms" are unmeasured.

I suggest four child issues, one run each, in this order:

  1. Size by table and index, plus growth per day.
  2. Retention for machine_sample (the simplest rule), with the nightly batching harness and incremental vacuum.
  3. Retention for event and deploy_pull.
  4. The index diet.

Checks

  • bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts are clean.
  • test/disk-marks.test.ts and test/system-parts.test.ts pass.
  • The system and MCP test files passed after the heading fix, except for test/system-parts.test.ts, which I re-ran separately.
  • scripts/fast.ts said the diff is too broad to name (exit 2), so I ran only these files, not the full suite.

Try it: open /system as an admin and read "Database". Or call the system tool and read db.

Closes #11973

4 earlier comments
commented

This pull covers only the size-reporting half of item 4. The retention rules, space give-back and index diet are not built, and the issue should be split before they are.

What changed

  • New src/system/db_size.ts: dbSize(db, dataDir) returns the size of forge.db, the write-ahead log, the free pages inside the file, and whether the file is past the 2 GiB Bun can map (MMAP_CAP_BYTES).
  • /system has a new "Database" block that shows these figures. The system MCP tool returns the same as db.
  • A db-size need now fires in src/kernel/vitals.ts when the file passes the mmap cap, and links to /system.
  • test/disk-marks.test.ts covers the need by making a sparse file past the cap. test/system-parts.test.ts now expects the new "Database" heading.

What I did not do

  • Size by table and index: the top-ten view is missing. This SQLite build has no dbstat, so it needs per-table row counts and estimated bytes, or a different measure.
  • Growth per day: not built, so the vitals need fires only on the mmap cap, not on a growth rate.
  • Retention rules (item 1): nothing for deploy_pull, event or machine_sample. This includes the nightly batched job, the admin settings, and the test proving the rebuild from git.
  • Giving space back (item 2): no incremental vacuum or VACUUM INTO yet, and so no choice between them.
  • Index diet (item 3): the list of 396 indexes and which queries use them is not produced. No index is dropped.
  • Production copy: none of this was checked against a copy of production, so "under 2 GiB" and "each batch holds the write lock under 50 ms" are unmeasured.

I suggest four child issues, one run each, in this order:

  1. Size by table and index, plus growth per day.
  2. Retention for machine_sample (the simplest rule), with the nightly batching harness and incremental vacuum.
  3. Retention for event and deploy_pull.
  4. The index diet.

Checks

  • bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts are clean.
  • test/disk-marks.test.ts and test/system-parts.test.ts pass.
  • The system and MCP test files passed after the heading fix, except for test/system-parts.test.ts, which I re-ran separately.
  • scripts/fast.ts said the diff is too broad to name (exit 2), so I ran only these files, not the full suite.

Try it: open /system as an admin and read "Database". Or call the system tool and read db.

commented

I found nothing in my change to fix, and I pushed nothing.

  • The preview is healthy. https://lab--11978--forge-trevato-apps.open-platform.sh/ answers 200 in about 0.34 s.
  • The log shows no error. The excerpt you sent is routine output (process counts, SQL timings), with no stack trace or failing test.
  • "No tests declared, none run" is not a bug. forge.json has no app-level test command (app has only run, health and looks). The tests live under check (fast, run, verify), and the forge runs those on the push.
  • My own checks passed before the first push. bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts were clean, and the tests I ran passed.
  • Not run: the full suite. The system and MCP files had one failing test, the heading list in test/system-parts.test.ts, which I fixed. A broader failure may exist that I haven't seen. If the check verdict on #11978 comes back red, send me that log and I'll fix it.

The scope is unchanged from the pull description: only the database size reporting is done. The retention rules, vacuum, index diet and size by table still need splitting into separate issues.

commented

Still red on current main: the forge kept going away under this check (4 times); not trying again. Fix it and push.

commented

The forge's database size is now on /system and in the system tool. Vitals raises a need when the file passes Bun's 2 GiB map. I merged the latest main and pushed to re-run the check.

The last check failed because the forge kept going away during the test run, four times over, not because a test failed. Every test shown in that log passed (195 pass, 0 fail), and nothing in my diff starts a process or takes the forge down. I changed no code to fix it. The merge pulled in main's newer commits, including its fixes for red full-suite runs. I did not reproduce the failure here, so I can't say what made the forge go away.

Before pushing I ran bun scripts/gate.ts and bun x tsc --noEmit, both clean. I also ran test/disk-marks.test.ts and test/system-parts.test.ts, which pass (16 tests). I did not run the full suite here, since the forge's check does that.

What changed

  • A new module, src/system/db_size.ts, reads the database's file size, its write-ahead log and its free pages.
  • /system has a "Database" block showing the three figures.
  • The system tool returns the same figures as db.
  • Vitals raises a db-size need, linking to /system, when the file is past 2 GiB.

Left out: bytes per table. This SQLite is built without dbstat, so there is nothing to read them from.

To try it: open /system and read the Database block.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs