RockteMQ-AI commented on issue #11439:
URL: https://github.com/apache/rocketmq/issues/11439#issuecomment-6167904416

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase at commit 
`0dd48c39dbdf`.
   
   **Root Cause:** When a compaction round is interrupted (broker restart, 
exception, etc.), the scratch folder (`compacting/`) retains stale files from 
the aborted round. The next compaction round creates a new `TopicPartitionLog` 
over the same scratch path without cleaning it. Since 
`MappedFileQueue.tryCreateMappedFile` opens the existing file `rw` without 
truncating and with `wrotePosition = 0`, new content is written from offset 0 
while stale bytes beyond the new content remain. `replaceFiles` then moves this 
corrupted file into the live compaction log.
   
   **Contributing factors verified in code:**
   - `compactAndReplace()` (line 611-624) has no `finally` block — cleanup is 
skipped on failure
   - `doCompaction()` (line 626-638) catches and logs `Throwable` without 
cleanup
   - `clean(MappedFileQueue)` (line 1095-1104) iterates the in-memory file 
list, which is empty for a freshly constructed scratch `TopicPartitionLog`, so 
on-disk residuals are invisible
   - `TopicPartitionLog` constructor (line 992-1006) only wires paths, never 
loads or cleans the folder
   
   **Impact:** Compaction log and consume queue data corruption for topics 
using compaction. Silent data integrity loss — no exception is thrown, stale 
bytes are spliced into the live log.
   
   **Severity:** Critical — data corruption path with no error signal.
   
   An automated fix proposal will be generated. Reply `/approve` to proceed 
with PR generation, `/revise` to request changes to the approach, or `/reject` 
to decline.
   
   ---
   *Automated evaluation by RocketMQ-AI*


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