{"record":{"id":"cd156e324b508cc7","repo":"dagger/dagger","slug":"wipe-unclean-persistence-db-w","errorCode":null,"errorMessage":"wipe unclean persistence db: %w","messagePattern":"wipe unclean persistence db: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dagql/cache.go","lineNumber":458,"sourceCode":"\t\tc.pdb = persistDB\n\t}\n\n\tcleanShutdownVal, found, err := c.pdb.SelectMetaValue(ctx, persistdb.MetaKeyCleanShutdown)\n\tif err != nil {\n\t\tif closeErr := closeCacheDBs(db, c.pdb); closeErr != nil {\n\t\t\treturn nil, errors.Join(fmt.Errorf(\"read clean_shutdown metadata: %w\", err), closeErr)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"read clean_shutdown metadata: %w\", err)\n\t}\n\tif found && cleanShutdownVal != \"1\" {\n\t\tc.persistenceResetReason = CachePersistenceResetUncleanShutdown\n\t\tc.tracePersistStoreWipedUncleanShutdown(ctx, cleanShutdownVal)\n\t\tslog.Warn(\"dagql persistence store marked unclean; wiping and cold-starting\", \"cleanShutdown\", cleanShutdownVal)\n\t\tif closeErr := closeCacheDBs(db, c.pdb); closeErr != nil {\n\t\t\treturn nil, errors.Join(fmt.Errorf(\"close db before wipe\"), closeErr)\n\t\t}\n\t\tif err := wipeSQLiteFiles(dbPath); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"wipe unclean persistence db: %w\", err)\n\t\t}\n\n\t\tdb, persistDB, err = prepareCacheDBs(ctx, dbPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tc.sqlDB = db\n\t\tc.pdb = persistDB\n\t}\n\tif err := c.importPersistedState(ctx); err != nil {\n\t\tc.persistenceResetReason = CachePersistenceResetImportFailure\n\t\tc.tracePersistStoreWipedImportFailure(ctx, err)\n\t\tslog.Warn(\"dagql persistence import failed; wiping and cold-starting\", \"err\", err)\n\t\tif closeErr := closeCacheDBs(db, c.pdb); closeErr != nil {\n\t\t\treturn nil, errors.Join(fmt.Errorf(\"close db before import-wipe\"), closeErr)\n\t\t}\n\t\tif err := wipeSQLiteFiles(dbPath); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"wipe persistence db after import failure: %w\", err)","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/dagql/cache.go#L440-L476","documentation":"After detecting an unclean shutdown, NewCache wipes the SQLite persistence files via wipeSQLiteFiles(dbPath) so the engine can cold-start with a fresh cache. If that deletion fails (permissions, file locks, read-only mount), this wrapped error aborts cache initialization.","triggerScenarios":"NewCache finds cleanShutdownVal != \"1\", successfully closes both DBs, then wipeSQLiteFiles(dbPath) fails to unlink the db/-wal/-shm files.","commonSituations":"Cache directory on a read-only or full volume after a crash; another process holding the deleted files open; immutable attribute or wrong ownership on cache files; container with a mounted cache dir lacking write access.","solutions":["Verify the cache volume is writable and has space (mount options, df).","Ensure no other process holds the DB files open, then retry startup.","Fix file ownership/permissions (chown/chmod) or remove immutable flags (chattr -i).","Manually delete dbPath cache files while stopped and start the engine again."],"exampleFix":"// before: crash leaves unclean DB on read-only volume\nwipe unclean persistence db: permission denied\n// after\n$ sudo mount -o remount,rw /var/lib/dagger && rm -f /var/lib/dagger/cache.db*","handlingStrategy":"validation","validationCode":"// before engine start, ensure the wipe is possible: writable dir, no leftover locks\nfunc wipeable(dbPath string) error {\n\tif err := unix.Access(dbPath, unix.W_OK); err != nil { return err }\n\tfor _, f := range []string{dbPath + \"-wal\", dbPath + \"-shm\"} {\n\t\tif err := os.Remove(f); err != nil && !os.IsNotExist(err) { return err }\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mount the cache volume read-write with adequate free space","Chown the cache dir to the engine's runtime user","Prevent concurrent engines on shared cache volumes","Use local SSD/local storage rather than network mounts"],"tags":["sqlite","persistence","filesystem","wipe"],"backgroundTag":"sqlite-db-wipe-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}