{"record":{"id":"9a7828854f3cafa6","repo":"nats-io/nats-server","slug":"partial-cache-offset-slot-index-d-is-less-zero","errorCode":null,"errorMessage":"Partial cache: offset slot index %d is less zero","messagePattern":"Partial cache: offset slot index (.+?) is less zero","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":6612,"sourceCode":"\t// Make sure we clear the cache since no longer valid.\n\tmb.clearCacheAndOffset()\n\t// If we entered with the msgs loaded make sure to reload them.\n\tif wasLoaded {\n\t\tif err := mb.loadMsgsWithLock(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\n// Grab info from a slot.\n// Lock should be held.\nfunc (mb *msgBlock) slotInfo(slot int) (uint32, uint32, bool, error) {\n\tswitch {\n\tcase mb.cache == nil: // Shouldn't be possible, but check it anyway.\n\t\treturn 0, 0, false, errNoCache\n\tcase slot < 0:\n\t\tmb.fs.warn(\"Partial cache: offset slot index %d is less zero\", slot)\n\t\treturn 0, 0, false, errPartialCache\n\tcase slot >= len(mb.cache.idx):\n\t\tmb.fs.warn(\"Partial cache: offset slot index %d is greater than index len %d\", slot, len(mb.cache.idx))\n\t\treturn 0, 0, false, errPartialCache\n\t}\n\n\tbi := mb.cache.idx[slot]\n\tri, hashChecked := (bi &^ cbit), (bi&cbit) != 0\n\n\t// If this is a deleted slot return here.\n\tif bi == dbit {\n\t\treturn 0, 0, false, errDeletedMsg\n\t}\n\n\t// Determine record length\n\tvar rl uint32\n\t// Need to account for dbit markers in idx.\n\t// So we will walk until we find valid idx slot to calculate rl.","sourceCodeStart":6594,"sourceCodeEnd":6630,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L6594-L6630","documentation":"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.","triggerScenarios":"Thrown at server/filestore.go:6612 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report to maintainers with the stream/sequence numbers: negative slot indices signal an internal bug","Verify sequence numbers requested against the block's first sequence (cache fseq)","Restart the server to rebuild block caches"],"exampleFix":null,"handlingStrategy":"type-guard","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-08T15:18:49.778Z"}