{"record":{"id":"02008d911036dd43","repo":"nats-io/nats-server","slug":"snapshot-check-failed-w","errorCode":null,"errorMessage":"snapshot check failed: %w","messagePattern":"snapshot check failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":12915,"sourceCode":"\t// Only allow one at a time.\n\tif fs.sips > 0 {\n\t\tfs.mu.Unlock()\n\t\treturn nil, ErrStoreSnapshotInProgress\n\t}\n\t// Mark us as snapshotting\n\tfs.sips += 1\n\tfs.mu.Unlock()\n\n\tif checkMsgs {\n\t\tld, err := fs.checkMsgs()\n\t\tclearSips := func() {\n\t\t\tfs.mu.Lock()\n\t\t\tfs.sips--\n\t\t\tfs.mu.Unlock()\n\t\t}\n\t\tif err != nil {\n\t\t\tclearSips()\n\t\t\treturn nil, fmt.Errorf(\"snapshot check failed: %w\", err)\n\t\t}\n\t\tif ld != nil && len(ld.Msgs) > 0 {\n\t\t\tclearSips()\n\t\t\treturn nil, fmt.Errorf(\"snapshot check detected %d bad messages\", len(ld.Msgs))\n\t\t}\n\t}\n\n\tpr, pw := net.Pipe()\n\n\t// Set a write deadline here to protect ourselves.\n\tif deadline > 0 {\n\t\tpw.SetWriteDeadline(time.Now().Add(deadline))\n\t}\n\n\t// We can add to our stream while snapshotting but not \"user\" delete anything.\n\tvar state StreamState\n\tfs.FastState(&state)\n","sourceCodeStart":12897,"sourceCodeEnd":12933,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L12897-L12933","documentation":"Wraps the underlying error from a snapshot check during a stream snapshot/backup operation. The file store runs a catch-up read to verify the snapshot state is consistent; if that check call returns an error, the snapshot fails with this message and the in-progress count (sips) is decremented. It guards against producing backups from an inconsistent state.","triggerScenarios":"Stream snapshot (e.g. via the JetStream API backup/consumer leader transfer flows) where the internal check read (ld lookup) returns an I/O or state error.","commonSituations":"Snapshotting a file-backed stream concurrently with heavy writes or catchup activity; disk I/O failures while reading messages for verification.","solutions":["Inspect the wrapped cause (%w) and fix the underlying I/O or state error.","Retry the snapshot after write load subsides; quiesce publishers during snapshot.","Verify the stream data directory integrity; restore from backup if corruption is reported.","Ensure adequate disk space and that the server has not hit file descriptor limits."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go: inspect the wrapped error\nif err != nil {\n    cause := errors.Unwrap(err)\n    log.Printf(\"snapshot check failed, cause=%v\", cause)\n    // fix cause then re-attempt snapshot\n}","preventionTips":["Quiesce heavy publishers during snapshots","Ensure ample disk space and fd limits","Monitor storage health before backup operations","Retry snapshots with backoff on transient I/O errors"],"tags":["jetstream","filestore","snapshot","backup"],"backgroundTag":"snapshot-check-failed","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}