{"record":{"id":"e39f9b6da3de553f","repo":"nats-io/nats-server","slug":"partial-purges-not-supported-on-memory-store","errorCode":null,"errorMessage":"partial purges not supported on memory store","messagePattern":"partial purges not supported on memory store","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/memstore.go","lineNumber":1675,"sourceCode":"\treturn purged, nil\n}\n\n// Purge will remove all messages from this store.\n// Will return the number of purged messages.\nfunc (ms *memStore) Purge() (uint64, error) {\n\treturn ms.purge(0)\n}\n\nfunc (ms *memStore) purge(fseq uint64) (uint64, error) {\n\tms.mu.Lock()\n\tpurged := uint64(len(ms.msgs))\n\tcb := ms.scb\n\tbytes := int64(ms.state.Bytes)\n\tif fseq == 0 {\n\t\tfseq = ms.state.LastSeq + 1\n\t} else if fseq < ms.state.LastSeq {\n\t\tms.mu.Unlock()\n\t\treturn 0, fmt.Errorf(\"partial purges not supported on memory store\")\n\t}\n\tms.state.FirstSeq = fseq\n\tms.state.LastSeq = fseq - 1\n\tms.state.FirstTime = time.Time{}\n\tms.state.Bytes = 0\n\tms.state.Msgs = 0\n\tif ms.msgs != nil {\n\t\tms.msgs = make(map[uint64]*StoreMsg)\n\t}\n\tms.fss = stree.NewSubjectTree[SimpleState]()\n\tms.dmap.Empty()\n\tms.sdm.empty()\n\tms.mu.Unlock()\n\n\tif cb != nil {\n\t\tcb(-int64(purged), -bytes, 0, _EMPTY_)\n\t}\n","sourceCodeStart":1657,"sourceCodeEnd":1693,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/memstore.go#L1657-L1693","documentation":"Returned by memStore.purge when a purge request carries an fseq lower than the current LastSeq, i.e. a request to purge only messages up to a sequence already below the stream state. The in-memory store does not support partial (mid-stream) purges, unlike the file store.","triggerScenarios":"Thrown at server/memstore.go:1675 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request a full purge (fseq 0) or a sequence at/after LastSeq on memory streams","Route partial-purge semantics only to file-backed streams"],"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"}