{"record":{"id":"af7443a0156b0902","repo":"risingwavelabs/risingwave","slug":"truncate-offset-earlier-than-prev-truncate-of","errorCode":null,"errorMessage":"truncate offset {:?} earlier than prev truncate offset {:?}","messagePattern":"truncate offset (.+?) earlier than prev truncate offset (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/stream/src/common/log_store_impl/kv_log_store/reader.rs","lineNumber":529,"sourceCode":"                    },\n                )\n            }\n        })\n    }\n\n    fn truncate(&mut self, offset: TruncateOffset) -> LogStoreResult<()> {\n        if offset > self.latest_offset.expect(\"should exist before truncation\") {\n            return Err(anyhow!(\n                \"truncate at a later offset {:?} than the current latest offset {:?}\",\n                offset,\n                self.latest_offset\n            ));\n        }\n        if offset.epoch() >= self.first_write_epoch.expect(\"should have init\") {\n            if let Some(truncate_offset) = &self.truncate_offset\n                && offset <= *truncate_offset\n            {\n                return Err(anyhow!(\n                    \"truncate offset {:?} earlier than prev truncate offset {:?}\",\n                    offset,\n                    truncate_offset\n                ));\n            }\n            self.rx.truncate_buffer(offset);\n            self.truncate_offset = Some(offset);\n        } else {\n            // For historical data, no need to truncate at seq id level. Only truncate at barrier.\n            if let TruncateOffset::Barrier { epoch } = &offset {\n                if let Some(truncate_offset) = &self.truncate_offset\n                    && offset <= *truncate_offset\n                {\n                    return Err(anyhow!(\n                        \"truncate offset {:?} earlier than prev truncate offset {:?}\",\n                        offset,\n                        truncate_offset\n                    ));","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/stream/src/common/log_store_impl/kv_log_store/reader.rs#L511-L547","documentation":"Guard in the KV log store reader's truncate: the requested truncate offset is earlier than (or equal to) the previously truncated offset. Truncation must be monotonically increasing; a backward truncate request is a caller bug and is rejected.","triggerScenarios":"Thrown at src/stream/src/common/log_store_impl/kv_log_store/reader.rs:529 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the offset bookkeeping: a truncate request is below the previously applied truncate offset, indicating out-of-order or duplicate truncation.","Check the upstream barrier/truncate sequencing; restart the fragment so the log store reader re-initializes its offsets.","If reproducible, report as a bug with the job and offsets from the message."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}