You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/08/26 01:40:19 UTC

[GitHub] [rocketmq] RongtongJin commented on a change in pull request #1405: [ISSUE #1397]Add abnormal recover for dleger modle

RongtongJin commented on a change in pull request #1405: [ISSUE #1397]Add abnormal recover for dleger modle
URL: https://github.com/apache/rocketmq/pull/1405#discussion_r317426574
 
 

 ##########
 File path: store/src/main/java/org/apache/rocketmq/store/dledger/DLedgerCommitLog.java
 ##########
 @@ -261,24 +258,96 @@ private void recover(long maxPhyOffsetOfConsumeQueue) {
             if (mappedFile != null) {
                 disableDeleteDledger();
             }
-            long maxPhyOffset = dLedgerFileList.getMaxWrotePosition();
+            List<MmapFile> mmapFiles = dLedgerFileList.getMappedFiles();
+            int index = mmapFiles.size() - 1;
+            MmapFile mmapFile = null;
+            for (; index >= 0; index--) {
+                mmapFile = mmapFiles.get(index);
+                if (isMappedFileMatchedRecover(mmapFile)) {
+                    log.info("Recover from this dleger mapped file " + mmapFile.getFileName());
+                    break;
+                }
+            }
+            if (index < 0) {
+                index = 0;
+                mmapFile = mmapFiles.get(index);
+            }
+
+            ByteBuffer byteBuffer = mmapFile.sliceByteBuffer();
+            long processOffset = mmapFile.getFileFromOffset();
+            long mappedFileOffset = 0;
+            while (true) {
+                DispatchRequest dispatchRequest = this.checkMessageAndReturnSize(byteBuffer, checkCRCOnRecover);
+                int size = dispatchRequest.getMsgSize();
 
 Review comment:
   This size does not contain dledger header, causing the process offset  to be wrong. Maybe should add DLedgerEntry.BODY_OFFSET.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services