Migration 7400 moves pending_releases (with its two HDD indexes), release_inspections and probe_cache to the default tablespace (nvme on homelab): the edge's batch upserts into pending_releases took minutes each on the HDD and the prober's flushes waited on them (LOG.md (137)). Homelab moved them by hand with the services stopped: 66 GB in 10.5 minutes. With everything the prober touches on the NVMe, the nightly pause leaves the prober running (usenet-rebuild-pause.sh), and a deploy while paused recreates it with node-api and web (deploy.sh). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
38 lines
1.7 KiB
TypeScript
38 lines
1.7 KiB
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
|
/**
|
|
* Everything the prober reads or writes in the catalog's tablespace (default_tablespace: nvme on homelab), out of
|
|
* CHUNK_TABLESPACE (the HDD): pending_releases with its two HDD indexes (migration 6300), release_inspections
|
|
* (6000), probe_cache with its toast. The edge's batch upserts into pending_releases took minutes each on the HDD and
|
|
* the prober's flushes waited on them (LOG.md 2026-11-03 (137)); and with these on the NVMe the prober can run
|
|
* through the night without the HDD. Homelab moved them by hand (edge, node-api and the workers stopped; ~66 GB);
|
|
* a no-op where they're there already, or without a default tablespace (tests).
|
|
*/
|
|
export default class extends BaseSchema {
|
|
async up() {
|
|
this.defer(async (db) => {
|
|
const { rows: setting } = await db.rawQuery(
|
|
`SELECT current_setting('default_tablespace') AS target`
|
|
)
|
|
const target = setting[0].target
|
|
if (!target) return
|
|
for (const table of ['pending_releases', 'release_inspections', 'probe_cache']) {
|
|
const { rows } = await db.rawQuery(
|
|
`SELECT c.relname, c.relkind FROM pg_class c LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
|
|
WHERE (c.relname = ? OR c.oid IN (SELECT indexrelid FROM pg_index WHERE indrelid = ?::regclass))
|
|
AND c.relkind IN ('r', 'i') AND coalesce(t.spcname, 'pg_default') <> ?
|
|
ORDER BY c.relkind DESC, c.relname`,
|
|
[table, table, target]
|
|
)
|
|
for (const { relname, relkind } of rows) {
|
|
await db.rawQuery(
|
|
`ALTER ${relkind === 'i' ? 'INDEX' : 'TABLE'} ${relname} SET TABLESPACE ${target}`
|
|
)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
async down() {}
|
|
}
|