nats-io/nats-server · error

loadBlock error: %v

Error message

loadBlock error: %v

What it means

A warning logged when msgBlock.loadBlock() fails while loading a whole message block from disk (e.g. during cache loading after pending flush). For errNoBlkData the block is treated as empty; other errors indicate I/O or corruption problems reading the block file, which propagate to the caller.

Source

Thrown at server/filestore.go:8922

	// FIXME(dlc) - We could be smarter here.
	if buf, _ := mb.bytesPending(); len(buf) > 0 {
		ld, err := mb.flushPendingMsgsLocked()
		if ld != nil && mb.fs != nil {
			// We do not know if fs is locked or not at this point.
			// This should be an exceptional condition so do so in Go routine.
			go mb.fs.rebuildState(ld)
		}
		if err != nil {
			return err
		}
		goto checkCache
	}

	// Load in the whole block.
	// We want to hold the mb lock here to avoid any changes to state.
	buf, err := mb.loadBlock(nil)
	if err != nil {
		mb.fs.warn("loadBlock error: %v", err)
		if err == errNoBlkData {
			if ld, _, _ := mb.rebuildStateLocked(); ld != nil {
				// Rebuild fs state too.
				go mb.fs.rebuildState(ld)
			}
		}
		return err
	}

	// Check if we need to decrypt.
	if err = mb.encryptOrDecryptIfNeeded(buf); err != nil {
		return err
	}
	// Check for compression.
	if buf, err = mb.decompressIfNeeded(buf); err != nil {
		return err
	}

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Check disk health and filesystem errors for the block file path in the wrapped error
  2. If errNoBlkData, the block is handled as empty — usually benign
  3. Restore corrupt or missing block files from backup
  4. Verify available disk space and permissions in the store directory
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at server/filestore.go:8922 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/99fb09d49cc683fa. Report an issue: GitHub.