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 2021/01/08 03:07:19 UTC

[GitHub] [rocketmq] horizonzy opened a new issue #2570: [Enhancement] Improve performance when org.apache.rocketmq.store.DefaultMessageStore#recover

horizonzy opened a new issue #2570:
URL: https://github.com/apache/rocketmq/issues/2570


   **BUG REPORT**
   
   1. Please describe the issue you observed:
   2. The code as follow:
   ```
       private void recover(final boolean lastExitOK) {
           long maxPhyOffsetOfConsumeQueue = this.recoverConsumeQueue();
   
           if (lastExitOK) {
               this.commitLog.recoverNormally(maxPhyOffsetOfConsumeQueue);
           } else {
               this.commitLog.recoverAbnormally(maxPhyOffsetOfConsumeQueue);
           }
   
           this.recoverTopicQueueTable();
       }
   ```
   After commitLog recover, it will clear redundant data in consumeQueue. 
   Now the judgement is
   ```
               // Clear ConsumeQueue redundant data
               if (maxPhyOffsetOfConsumeQueue >= processOffset) {
                   log.warn("maxPhyOffsetOfConsumeQueue({}) >= processOffset({}), truncate dirty logic files", maxPhyOffsetOfConsumeQueue, processOffset);
                   this.defaultMessageStore.truncateDirtyLogicFiles(processOffset);
               }
   ```
   In fact, use  ` if (maxPhyOffsetOfConsumeQueue > processOffset) ` will be better, because at most case, the `maxPhyOffsetOfConsumeQueue == processOffset`, The `this.defaultMessageStore.truncateDirtyLogicFiles(processOffset);` needn't process. 


----------------------------------------------------------------
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