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:
[email protected]


Reply via email to