{"record":{"id":"92ae58d4815d8bd8","repo":"nats-io/nats-server","slug":"writefullstate-took-v-d-bytes","errorCode":null,"errorMessage":"WriteFullState took %v (%d bytes)","messagePattern":"WriteFullState took (.+?) \\((.+?) bytes\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":12370,"sourceCode":"\tstatesEqual := trackingStatesEqual(&fs.state, &mstate)\n\t// Release lock.\n\tfs.mu.RUnlock()\n\n\t// Check consistency here.\n\tif !statesEqual {\n\t\tfs.warn(\"Stream state encountered internal inconsistency on write\")\n\t\t// Rebuild our fs state from the mb state.\n\t\tfs.rebuildState(nil)\n\t\treturn errCorruptState\n\t}\n\n\tif cap(buf) > sz {\n\t\tfs.debug(\"WriteFullState reallocated from %d to %d\", sz, cap(buf))\n\t}\n\n\t// Only warn about construction time since file write not holding any locks.\n\tif took := time.Since(start); took > time.Minute {\n\t\tfs.warn(\"WriteFullState took %v (%d bytes)\", took.Round(time.Millisecond), len(buf))\n\t}\n\n\t// Write our update index.db\n\t// Protect with dios.\n\tfs.dios.acquire()\n\terr := os.WriteFile(fn, buf, defaultFilePerms)\n\t// if file system is not writable isPermissionError is set to true\n\tfs.dios.release()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Update dirty if successful.\n\tfs.mu.Lock()\n\tfs.dirty -= priorDirty\n\tfs.mu.Unlock()\n\n\t// Attempt to write other index files, an error in one should not prevent the other from being written.","sourceCodeStart":12352,"sourceCodeEnd":12388,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L12352-L12388","documentation":"A performance watchdog, not an error: constructing the full stream state buffer for WriteFullState took over 1 minute (size in bytes included). Only construction time is measured since the file write happens without locks; a slow build signals a very large stream.","triggerScenarios":"Thrown at server/filestore.go:12370 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce stream scale (limits, retention) if state writes block operations repeatedly","Profile the server during state writes to find the hotspot","Treat as informational on very large deployments"],"exampleFix":null,"handlingStrategy":"validation","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"}