fix(indexbuild): repair the one database a squash cannot reach
The index job's /cache volume is a real YJ_HOME that outlives every run, so plan 013's reshaped audio_files met a database still in the old shape: `CREATE INDEX ... album_id` against a table without that column, on every launch. "Delete and rescan" is the squash's answer and is free everywhere except here, where half the file is the catalog and deleting it costs ~205GB of downloading. indexbuild now drops every table datamap does not classify as Cache before the schema is applied. Nothing scans, plays or authors in that database, so its non-catalog half is empty by construction and a shape the schema stopped describing is pure liability; the catalog is never touched. TestRetireLibraryTables reproduces the failure symptom-first: build the real schema, put audio_files back the way the volume had it, assert the open fails, then assert the repair makes it open with the catalog row still there.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
@@ -127,6 +128,13 @@ func run(o opts) error {
|
||||
return fmt.Errorf("resolve data dir: %w", err)
|
||||
}
|
||||
|
||||
// Before the schema is applied, not after: applying it over a table
|
||||
// whose shape has since changed is what fails, and this database's
|
||||
// non-catalog half is disposable. See retireLibraryTables.
|
||||
if err := retireLibraryTables(context.Background(), logger); err != nil {
|
||||
return fmt.Errorf("retire stale tables: %w", err)
|
||||
}
|
||||
|
||||
db, err := database.NewDB(logger)
|
||||
if err != nil {
|
||||
return fmt.Errorf("open database: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user