{"record":{"id":"15eba1c92e614357","repo":"nats-io/nats-server","slug":"failed-to-set-consumer-q-state-w","errorCode":null,"errorMessage":"failed to set consumer %q state: %w","messagePattern":"failed to set consumer %q state: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/stream_backup.go","lineNumber":452,"sourceCode":"\t\tisEphemeral := !isDurableConsumer(consumer.ConsumerConfig)\n\t\tif isEphemeral {\n\t\t\t// Keep ephemerals alive and interested until all messages have\n\t\t\t// been restored, then start their normal inactivity lifecycle.\n\t\t\tconsumer.Durable = name\n\t\t}\n\t\to, err := mset.addConsumerForRestore(consumer.ConsumerConfig)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to add consumer %q: %w\", name, err)\n\t\t}\n\t\tif isEphemeral {\n\t\t\tephemerals = append(ephemerals, o)\n\t\t}\n\t\trestoredConsumers = append(restoredConsumers, o)\n\t\to.mu.Lock()\n\t\terr = o.setStoreState(consumer.ConsumerState)\n\t\to.mu.Unlock()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to set consumer %q state: %w\", name, err)\n\t\t}\n\t}\n\n\tstore := mset.store\n\tlseq := nstate.FirstSeq - 1\n\teob := false\n\tmp := int64(s.getOpts().MaxPayload)\n\tfor {\n\t\thdr, err := tr.Next()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tseq := hdr.Sequence\n\t\tif seq == 0 {\n\t\t\t// Sentinel \"end of backup\" if all fields are zero.\n\t\t\tif hdr.Timestamp == 0 && hdr.HeaderSize == 0 && hdr.PayloadSize == 0 {\n\t\t\t\teob = true\n\t\t\t\tbreak","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream_backup.go#L434-L470","documentation":"Emitted during restore after the consumer was successfully recreated: writing the archived delivered/ack/pending state back into the consumer store via setStoreState failed. The consumer exists but its checkpoint state could not be applied, so the restore aborts rather than leave an inconsistent snapshot.","triggerScenarios":"Thrown at server/stream_backup.go:452 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped store error; disk full or state-file corruption on the target server are common causes","Free space / repair the target server's storage and re-run the restore","Remove the partially restored consumer and stream before retrying so state is applied to a clean consumer"],"exampleFix":null,"handlingStrategy":"try-catch","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"}