{"record":{"id":"c154665938fd2b89","repo":"nats-io/nats-server","slug":"file-system-permission-denied-when-flushing-stream","errorCode":null,"errorMessage":"File system permission denied when flushing stream state, disabling JetStream: %v","messagePattern":"File system permission denied when flushing stream state, disabling JetStream: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/filestore.go","lineNumber":12131,"sourceCode":"\n// This go routine periodically writes out our full stream state index.\nfunc (fs *fileStore) flushStreamStateLoop(qch, done chan struct{}) {\n\t// Signal we are done on exit.\n\tdefer close(done)\n\n\t// Make sure we do not try to write these out too fast.\n\t// Spread these out for large numbers on a server restart.\n\tconst writeThreshold = 2 * time.Minute\n\twriteJitter := time.Duration(mrand.Int63n(int64(30 * time.Second)))\n\tt := time.NewTicker(writeThreshold + writeJitter)\n\tdefer t.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase <-t.C:\n\t\t\terr := fs.writeFullState()\n\t\t\tif isPermissionError(err) && fs.srv != nil {\n\t\t\t\tfs.warn(\"File system permission denied when flushing stream state, disabling JetStream: %v\", err)\n\t\t\t\t// messages in block cache could be lost in the worst case.\n\t\t\t\t// In the clustered mode it is very highly unlikely as a result of replication.\n\t\t\t\tfs.srv.ShutdownJetStream()\n\t\t\t\treturn\n\t\t\t}\n\n\t\tcase <-qch:\n\t\t\treturn\n\t\t}\n\t}\n}\n\n// Helper since unixnano of zero time undefined.\nfunc timestampNormalized(t time.Time) int64 {\n\tif t.IsZero() {\n\t\treturn 0\n\t}\n\treturn t.UnixNano()","sourceCodeStart":12113,"sourceCodeEnd":12149,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/filestore.go#L12113-L12149","documentation":"A warning logged by fileStore.flushStreamStateLoop() when the periodic writeFullState() of a stream's state fails with a permission error. JetStream for that stream is then disabled because the store can no longer persist state safely; the underlying directory or state file is not writable by the server process.","triggerScenarios":"Thrown at server/filestore.go:12131 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix permissions/ownership on the stream's store directory so the server user can write","Check for the directory being read-only (mounted ro, disk full-quota, ransomware protection)","Restore write access and restart the server or recreate the stream"],"exampleFix":null,"handlingStrategy":"fallback","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"}