From bb51c9abdbebe366e635cd0a07c8efa55aefccc4 Mon Sep 17 00:00:00 2001 From: daguimu Date: Wed, 25 Mar 2026 19:27:50 +0800 Subject: [PATCH] [ISSUE #9728] Fix correctMinOffset handling of incomplete consume queue records Change the size check from `result.getSize() == 0` to `result.getSize() < CQ_STORE_UNIT_SIZE` to properly handle partially written consume queue records. When the buffer contains fewer bytes than a complete CQ unit (20 bytes), the subsequent getLong() call would throw BufferUnderflowException. Fixes #9728 --- .../src/main/java/org/apache/rocketmq/store/ConsumeQueue.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java index d1a36c9e136..fe7af222e2c 100644 --- a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java +++ b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java @@ -612,8 +612,8 @@ public void correctMinOffset(long minCommitLogOffset) { } try { - // No valid consume entries - if (result.getSize() == 0) { + // No valid consume entries or incomplete record + if (result.getSize() < ConsumeQueue.CQ_STORE_UNIT_SIZE) { log.debug("ConsumeQueue[topic={}, queue-id={}] contains no valid entries", topic, queueId); return; }