{"record":{"id":"34504268fa19c6ec","repo":"nats-io/nats-server","slug":"checkmsgs-v","errorCode":null,"errorMessage":"checkMsgs: %v","messagePattern":"checkMsgs: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":7519,"sourceCode":"\tlmb.mu.Unlock()\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Since fs lock is held need to unlock the mb in case we need to rebuild state.\n\tif ld != nil {\n\t\tfs.rebuildStateLocked(ld)\n\t}\n\treturn nil\n}\n\n// This will check all the checksums on messages and report back any sequence numbers with errors.\nfunc (fs *fileStore) checkMsgs() (*LostStreamData, error) {\n\tfs.mu.Lock()\n\tdefer fs.mu.Unlock()\n\n\tvar firstErr error\n\tstoreErr := func(err error) error {\n\t\tfs.warn(\"checkMsgs: %v\", err)\n\t\tif firstErr == nil {\n\t\t\tfirstErr = err\n\t\t}\n\t\treturn err\n\t}\n\n\tif err := fs.checkAndFlushLastBlock(); err != nil {\n\t\treturn nil, storeErr(fmt.Errorf(\"flush of last block failed: %w\", err))\n\t}\n\n\t// Clear any global subject state.\n\tfs.psim, fs.tsl = fs.psim.Empty(), 0\n\n\tfor _, mb := range fs.blks {\n\t\t// Make sure encryption loaded if needed for the block.\n\t\tif err := fs.loadEncryptionForMsgBlock(mb); err != nil {\n\t\t\t_ = storeErr(fmt.Errorf(\"loading encryption for block %d failed: %w\", mb.index, err))\n\t\t\tcontinue","sourceCodeStart":7501,"sourceCodeEnd":7537,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L7501-L7537","documentation":"A warning logged by fileStore.checkMsgs() via its storeErr helper for any error encountered while verifying message block checksums (flush failures, load errors, checksum mismatches). The first error is retained and returned as the check result so upper layers can report lost/corrupt stream data.","triggerScenarios":"Thrown at server/filestore.go:7519 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error to locate the failing message block","Run integrity checks on the store disk; look for disk corruption or full filesystems","Recover from the returned LostStreamData to understand which sequences are affected","Restore affected blocks from backup or let consumers re-fetch missing ranges"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}