{"record":{"id":"021592f3296a8238","repo":"rqlite/rqlite","slug":"scanning-snapshots-for-crc-check-w","errorCode":null,"errorMessage":"scanning snapshots for CRC check: %w","messagePattern":"scanning snapshots for CRC check: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"snapshot/store.go","lineNumber":887,"sourceCode":"\t}\n\tfor _, e := range entries {\n\t\tif e.IsDir() && isTmpName(e.Name()) {\n\t\t\ttmpPath := filepath.Join(s.dir, e.Name())\n\t\t\ts.logger.Printf(\"removing leftover temporary directory %s\", tmpPath)\n\t\t\tif err := os.RemoveAll(tmpPath); err != nil {\n\t\t\t\treturn fmt.Errorf(\"removing temporary directory %s: %w\", tmpPath, err)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// checkCRCs verifies the CRC32 of every data file in every snapshot directory.\nfunc (s *Store) checkCRCs() error {\n\tstartT := time.Now()\n\tsnapshots, err := s.catalog.Scan(s.dir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"scanning snapshots for CRC check: %w\", err)\n\t}\n\tif len(snapshots.items) == 0 {\n\t\treturn nil\n\t}\n\n\tchecker := NewCRCChecker()\n\tfor _, snap := range snapshots.items {\n\t\tif snap.dbFile != nil {\n\t\t\tchecker.Add(snap.dbFile)\n\t\t}\n\t\tfor _, wf := range snap.walFiles {\n\t\t\tchecker.Add(wf)\n\t\t}\n\t}\n\n\tif err := <-checker.Check(); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":869,"sourceCodeEnd":905,"githubUrl":"https://github.com/rqlite/rqlite/blob/7586a4d1bdbd9a5a80021664c5a863cd850adb60/snapshot/store.go#L869-L905","documentation":"checkCRCs verifies the CRC32 of every data file in every snapshot directory. This error is returned when the catalog's Scan(s.dir) fails before any CRC checking starts, so snapshot integrity could not even be enumerated.","triggerScenarios":"Verify() or an anonymous caller invokes checkCRCs while catalog.Scan fails, e.g. unreadable/missing snapshot directories or malformed catalog state on disk.","commonSituations":"Manual deletion or modification of files inside the rqlite data directory; disk errors; permission problems after user change; corrupted snapshot store after power loss.","solutions":["Inspect the wrapped error and check the snapshot directories under the data dir are readable","Restore from backup if snapshot metadata is corrupted","Fix permissions/ownership on the data and snapshot directories","Run on a healthy disk; check dmesg for I/O errors"],"exampleFix":"// before: CRC check fails to scan snapshots\nsudo chown -R rqlite:rqlite /var/lib/rqlite\n// after: verification proceeds\nrqlite status  # verify passes","handlingStrategy":"try-catch","validationCode":"// ensure snapshot subdirs are readable before verification\nentries, err := os.ReadDir(snapshotRoot)\nif err != nil { return err }\nfor _, e := range entries {\n    if !e.IsDir() { continue }\n    if _, err := os.ReadDir(filepath.Join(snapshotRoot, e.Name())); err != nil {\n        return fmt.Errorf(\"snapshot dir %s unreadable: %w\", e.Name(), err)\n    }\n}","typeGuard":null,"tryCatchPattern":"// Go\nif err := verifier.CheckCRCs(); err != nil {\n    if strings.Contains(err.Error(), \"scanning snapshots\") {\n        logger.Printf(\"snapshot store unreadable, restoring from backup: %v\", err)\n        // fall back to restoring a known-good backup\n    }\n    return err\n}","preventionTips":["Never edit or delete files inside the snapshot store manually","Take regular backups so a corrupted store can be restored","Monitor disk health (SMART) to catch I/O errors early","Keep consistent ownership/permissions across upgrades and user changes"],"tags":["snapshot","crc","integrity","scan"],"backgroundTag":"snapshot-scan-failed","analyzedSha":"7586a4d1bdbd9a5a80021664c5a863cd850adb60","analyzedAt":"2026-09-03T07:03:02.260Z","contentChangedAt":"2026-09-03T07:03:02.260Z","schemaVersion":2},"datasetVersion":"2026-09-10T12:17:11.382Z"}