{"record":{"id":"29a09a74f9dcbcab","repo":"benbjohnson/litestream","slug":"ensure-test-table-w","errorCode":null,"errorMessage":"ensure test table: %w","messagePattern":"ensure test table: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream-test/load.go","lineNumber":88,"sourceCode":"\t\t\"read_ratio\", c.ReadRatio,\n\t\t\"workers\", c.Workers,\n\t)\n\n\treturn c.generateLoad(ctx)\n}\n\nfunc (c *LoadCommand) generateLoad(ctx context.Context) error {\n\tdb, err := sql.Open(\"sqlite3\", c.DB+\"?_journal_mode=WAL\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"open database: %w\", err)\n\t}\n\tdefer db.Close()\n\n\tdb.SetMaxOpenConns(c.Workers + 1)\n\tdb.SetMaxIdleConns(c.Workers)\n\n\tif err := c.ensureTestTable(db); err != nil {\n\t\treturn fmt.Errorf(\"ensure test table: %w\", err)\n\t}\n\n\tctx, cancel := context.WithTimeout(ctx, c.Duration)\n\tdefer cancel()\n\n\tsigChan := make(chan os.Signal, 1)\n\tsignal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)\n\tgo func() {\n\t\t<-sigChan\n\t\tslog.Info(\"Received interrupt signal, stopping load generation\")\n\t\tcancel()\n\t}()\n\n\tstats := &LoadStats{\n\t\tstartTime:  time.Now(),\n\t\tlastReport: time.Now(),\n\t}\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream-test/load.go#L70-L106","documentation":"generateLoad wraps any failure from ensureTestTable (which creates the load_test table and its index if missing) as \"ensure test table\". This means the schema-setup step for the load generator failed — most often a SQLite error executing the CREATE TABLE/CREATE INDEX statements or a connection failure to the database.","triggerScenarios":"Running `litestream-test load` where the CREATE TABLE IF NOT EXISTS load_test or CREATE INDEX statement fails: the existing file is not a valid SQLite database, the file is corrupted, the disk is full, or the connection dropped.","commonSituations":"Pointing -db at a non-SQLite file (random bytes, another DB engine's file); a corrupted database from a previous crashed run; read-only filesystem or insufficient disk space; database locked by another process holding an exclusive lock.","solutions":["Verify the -db path is a valid SQLite database (`sqlite3 <path> '.tables'` or `file <path>`); recreate it with `litestream-test populate` if it is corrupt or not SQLite.","Check for other processes holding a write lock on the database and close them.","Check disk space and filesystem writability; free space or move the database to a writable location.","Inspect the wrapped inner error for the specific SQLite error code and address it directly."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify the file is a real SQLite database before running load\nimport { readFileSync } from \"fs\";\nconst header = readFileSync(dbPath).subarray(0, 16).toString(\"utf8\");\nif (header !== \"SQLite format 3\\u0000\") throw new Error(`${dbPath} is not a SQLite database`);","typeGuard":"function isSqliteFile(path) {\n  try { return readFileSync(path).subarray(0, 16).toString(\"latin1\") === \"SQLite format 3\\x00\"; } catch { return false; }\n}","tryCatchPattern":"try {\n  await run(\"litestream-test\", [\"load\", \"-db\", dbPath]);\n} catch (e) {\n  if (String(e).includes(\"ensure test table\")) {\n    console.error(\"Schema setup failed; recreate the DB with 'litestream-test populate -db \" + dbPath + \"'\");\n  }\n  throw e;\n}","preventionTips":["Only point -db at databases created by litestream-test populate.","Check disk space before long load runs.","Avoid concurrent writers on the same database file."],"tags":["sqlite","schema","cli"],"backgroundTag":"schema-validation-failed","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}