nats-io/nats-server · error

checkMsgs: %v

Error message

checkMsgs: %v

What it means

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.

Source

Thrown at server/filestore.go:7519

	lmb.mu.Unlock()
	if err != nil {
		return err
	}
	// Since fs lock is held need to unlock the mb in case we need to rebuild state.
	if ld != nil {
		fs.rebuildStateLocked(ld)
	}
	return nil
}

// This will check all the checksums on messages and report back any sequence numbers with errors.
func (fs *fileStore) checkMsgs() (*LostStreamData, error) {
	fs.mu.Lock()
	defer fs.mu.Unlock()

	var firstErr error
	storeErr := func(err error) error {
		fs.warn("checkMsgs: %v", err)
		if firstErr == nil {
			firstErr = err
		}
		return err
	}

	if err := fs.checkAndFlushLastBlock(); err != nil {
		return nil, storeErr(fmt.Errorf("flush of last block failed: %w", err))
	}

	// Clear any global subject state.
	fs.psim, fs.tsl = fs.psim.Empty(), 0

	for _, mb := range fs.blks {
		// Make sure encryption loaded if needed for the block.
		if err := fs.loadEncryptionForMsgBlock(mb); err != nil {
			_ = storeErr(fmt.Errorf("loading encryption for block %d failed: %w", mb.index, err))
			continue

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Inspect the wrapped error to locate the failing message block
  2. Run integrity checks on the store disk; look for disk corruption or full filesystems
  3. Recover from the returned LostStreamData to understand which sequences are affected
  4. Restore affected blocks from backup or let consumers re-fetch missing ranges
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at server/filestore.go:7519 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/34504268fa19c6ec. Report an issue: GitHub.