{"record":{"id":"6bea1c765adf1ebe","repo":"databendlabs/databend","slug":"transfer-target-page-index-is-out-of-bounds","errorCode":null,"errorMessage":"transfer target page index is out of bounds","messagePattern":"transfer target page index is out of bounds","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/expression/src/aggregate/payload.rs","lineNumber":100,"sourceCode":"impl PayloadTransferStateOffsets {\n    fn record(&mut self, payload_index: usize, offsets: Vec<(usize, usize)>) {\n        self.offsets.extend(\n            offsets\n                .into_iter()\n                .map(|(page_index, offset)| (payload_index, page_index, offset)),\n        );\n    }\n\n    fn commit(self, payloads: &mut [Payload]) {\n        for (payload_index, page_index, offset) in self.offsets {\n            let payload = payloads\n                .get_mut(payload_index)\n                .expect(\"transfer target payload index is out of bounds\");\n\n            let page = payload\n                .pages\n                .get_mut(page_index)\n                .expect(\"transfer target page index is out of bounds\");\n            let next_state_offsets = page\n                .state_offsets\n                .checked_add(offset)\n                .expect(\"transfer target state offsets overflow\");\n            let initialized_states = page\n                .rows\n                .checked_mul(payload.aggrs.len())\n                .expect(\"transfer target initialized states overflow\");\n\n            assert!(\n                next_state_offsets <= initialized_states,\n                \"transfer target state offsets exceed initialized aggregate states\"\n            );\n            page.state_offsets = next_state_offsets;\n        }\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/expression/src/aggregate/payload.rs#L82-L118","documentation":"Same commit() path as the payload-index panic, but here the target payload exists and payload.pages.get_mut(page_index) returns None: the recorded page index is out of bounds for the destination payload's pages. It indicates the state transfer offsets were recorded against pages that no longer exist.","triggerScenarios":"commit_transferred_state_offsets committing an offset whose page_index >= payload.pages.len() for the target payload — e.g. pages evicted/compacted after offsets were recorded.","commonSituations":"Aggregate state transfer across payload arenas during multi-phase aggregation (partial → final) where page allocation or recycling changes between recording and commit.","solutions":["Ensure pages of the target payload are not freed/compacted between recording transfer offsets and calling commit.","Validate page_index < payload.pages.len() when recording the offset to fail fast with context.","Recompute the transfer offsets from the current arena state instead of reusing stale records.","Report the failing query plan; this is an internal invariant violation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"assert!(page_index < payload.pages.len(), \"transfer offset references invalid page {}\", page_index);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep target payload pages alive until commit completes","Recompute transfer offsets after any arena restructuring","Fail fast at record time with contextual asserts"],"tags":["rust","panic","index-out-of-bounds","aggregation"],"backgroundTag":"index-out-of-bounds","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}