nats-io/nats-server · error

Partial cache: offset slot index %d is less zero

Error message

Partial cache: offset slot index %d is less zero

What it means

A warning logged by msgBlock.slotInfo() when a negative slot index is requested from the partial cache (cache == nil and slot < 0 case aside, this guards slot < 0). It indicates an internal accounting bug — the computed offset of a sequence into the cache index is negative — and slotInfo returns errPartialCache to the caller.

Source

Thrown at server/filestore.go:6612

	// Make sure we clear the cache since no longer valid.
	mb.clearCacheAndOffset()
	// If we entered with the msgs loaded make sure to reload them.
	if wasLoaded {
		if err := mb.loadMsgsWithLock(); err != nil {
			return err
		}
	}
	return nil
}

// Grab info from a slot.
// Lock should be held.
func (mb *msgBlock) slotInfo(slot int) (uint32, uint32, bool, error) {
	switch {
	case mb.cache == nil: // Shouldn't be possible, but check it anyway.
		return 0, 0, false, errNoCache
	case slot < 0:
		mb.fs.warn("Partial cache: offset slot index %d is less zero", slot)
		return 0, 0, false, errPartialCache
	case slot >= len(mb.cache.idx):
		mb.fs.warn("Partial cache: offset slot index %d is greater than index len %d", slot, len(mb.cache.idx))
		return 0, 0, false, errPartialCache
	}

	bi := mb.cache.idx[slot]
	ri, hashChecked := (bi &^ cbit), (bi&cbit) != 0

	// If this is a deleted slot return here.
	if bi == dbit {
		return 0, 0, false, errDeletedMsg
	}

	// Determine record length
	var rl uint32
	// Need to account for dbit markers in idx.
	// So we will walk until we find valid idx slot to calculate rl.

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Report to maintainers with the stream/sequence numbers: negative slot indices signal an internal bug
  2. Verify sequence numbers requested against the block's first sequence (cache fseq)
  3. Restart the server to rebuild block caches
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at server/filestore.go:6612 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/9a7828854f3cafa6. Report an issue: GitHub.