@@ -738,6 +738,7 @@ public void recoverAbnormally(long maxPhyOffsetOfConsumeQueue) throws RocksDBExc
738738 // recover by the minimum time stamp
739739 boolean checkCRCOnRecover = this .defaultMessageStore .getMessageStoreConfig ().isCheckCRCOnRecover ();
740740 boolean checkDupInfo = this .defaultMessageStore .getMessageStoreConfig ().isDuplicationEnable ();
741+ boolean checkCommitLogOffsetOnRecover = this .defaultMessageStore .getMessageStoreConfig ().isCheckCommitLogOffsetOnRecover ();
741742 int maxRecoverNum = this .defaultMessageStore .getMessageStoreConfig ().getCommitLogRecoverMaxNum ();
742743 if (maxRecoverNum <= 0 ) {
743744 maxRecoverNum = 10 ;
@@ -793,13 +794,16 @@ public void recoverAbnormally(long maxPhyOffsetOfConsumeQueue) throws RocksDBExc
793794 DispatchRequest dispatchRequest = this .checkMessageAndReturnSize (byteBuffer , checkCRCOnRecover , checkDupInfo );
794795 int size = dispatchRequest .getMsgSize ();
795796 if (dispatchRequest .isSuccess ()) {
796- if (dispatchRequest .getCommitLogOffset () < mappedFile .getFileFromOffset ()
797- || dispatchRequest .getCommitLogOffset () > mappedFile .getFileFromOffset () + mappedFile .getFileSize ()) {
798- log .warn ("found illegal commitlog offset {} in {}, current pos={}, it will be truncated." ,
799- dispatchRequest .getCommitLogOffset (), mappedFile .getFileName (), processOffset + mappedFileOffset );
800- log .info ("recover physics file end, {} pos={}" , mappedFile .getFileName (), byteBuffer .position ());
797+ // Check commitlog offset validity if enabled
798+ if (checkCommitLogOffsetOnRecover ) {
799+ if (dispatchRequest .getCommitLogOffset () < mappedFile .getFileFromOffset ()
800+ || dispatchRequest .getCommitLogOffset () > mappedFile .getFileFromOffset () + mappedFile .getFileSize ()) {
801+ log .warn ("found illegal commitlog offset {} in {}, current pos={}, it will be truncated." ,
802+ dispatchRequest .getCommitLogOffset (), mappedFile .getFileName (), processOffset + mappedFileOffset );
803+ log .info ("recover physics file end, {} pos={}" , mappedFile .getFileName (), byteBuffer .position ());
801804
802- break ;
805+ break ;
806+ }
803807 }
804808 // Normal data
805809 if (size > 0 ) {
0 commit comments