[
https://issues.apache.org/jira/browse/ROCKETMQ-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16149969#comment-16149969
]
ASF GitHub Bot commented on ROCKETMQ-279:
-----------------------------------------
Github user zhouxinyu commented on a diff in the pull request:
https://github.com/apache/incubator-rocketmq/pull/159#discussion_r136491053
--- Diff: store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
---
@@ -84,6 +84,58 @@ public boolean load() {
return result;
}
+ public void checkCommitLogAndConsumeQueueConsistent() {
+
+ String queueDir = this.storePath
+ + File.separator + topic
+ + File.separator + queueId + File.separator;
+
+ long lastRecordOffset = Math.max(getMaxOffsetInQueue() - 1, 0);
+
+ if (lastRecordOffset == 0) {
+ return;
+ }
+
+ SelectMappedBufferResult consumeQueueBuffer =
getIndexBuffer(lastRecordOffset);
+
+ if (consumeQueueBuffer == null) {
+ String errorMsg = String.format("Can't find consume queue
mappedBuffer by offset %s,queueDir %s", lastRecordOffset, queueDir);
+ log.error(errorMsg);
+ throw new IllegalStateException(errorMsg);
+ }
+
+ //position latest consume queue offset,
+ long offsetPy = consumeQueueBuffer.getByteBuffer().getLong();
+ int sizePy = consumeQueueBuffer.getByteBuffer().getInt();
+ consumeQueueBuffer.getByteBuffer().getLong();
--- End diff --
Do we need the side effect of `getLong`?
> add commit log data and consume queue data logic consistent check when start
> mq
> -------------------------------------------------------------------------------
>
> Key: ROCKETMQ-279
> URL: https://issues.apache.org/jira/browse/ROCKETMQ-279
> Project: Apache RocketMQ
> Issue Type: Bug
> Components: rocketmq-store
> Affects Versions: 4.0.0-incubating, 4.1.0-incubating
> Reporter: yubaofu
> Assignee: yukon
> Fix For: 4.2.0-incubating
>
>
> commit log and consume data may logic inconsistent ,
> because [ROCKETMQ-265|https://issues.apache.org/jira/browse/ROCKETMQ-265],
> so we add data consistent check,when mq start.
> if check failed, start failed.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)