wang-jiahua commented on code in PR #10566:
URL: https://github.com/apache/rocketmq/pull/10566#discussion_r3510559369


##########
store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java:
##########
@@ -1271,7 +1279,13 @@ public void initializeWithOffset(long offset, long 
minPhyOffset) {
 
         // transientStorePool is null, only need set wrote position here
         MappedFile mappedFile = mappedFileQueue.getLastMappedFile(offset * 
ConsumeQueue.CQ_STORE_UNIT_SIZE, true);
-        fillPreBlank(mappedFile, offset * ConsumeQueue.CQ_STORE_UNIT_SIZE);
+        if (mappedFile != null && mappedFile.hold()) {
+            try {
+                fillPreBlank(mappedFile, offset * 
ConsumeQueue.CQ_STORE_UNIT_SIZE);
+            } finally {
+                mappedFile.release();
+            }
+        }

Review Comment:
   Good catch. Fixed in the latest commit — instead of silently skipping 
`fillPreBlank()`, the method now logs an error and returns early (aborts 
initialization) when `mappedFile` is null or `hold()` fails:
   
   ```java
   if (mappedFile == null) {
       log.error("initializeWithOffset failed: mappedFile is null for offset 
{}", offset);
       return;
   }
   if (!mappedFile.hold()) {
       log.error("initializeWithOffset failed: mappedFile hold() failed for 
offset {}", offset);
       return;
   }
   ```
   
   This ensures the consume queue is not left in an inconsistent state (no 
`flush(0)` called) when file creation/availability fails, while keeping the 
`hold()` reference to prevent the SIGSEGV.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to