RockteMQ-AI commented on issue #11379:
URL: https://github.com/apache/rocketmq/issues/11379#issuecomment-6124830823
**Issue Evaluation**
Category: `type/bug` | Status: **Confirmed**
The reported issue has been verified against the current codebase on
`develop` branch (commit `b764205`).
**Root Cause:**
`MessageStoreDispatcherImpl#doScheduleDispatch` has preflight null guards
for the *first* offset (lines 240-255), but the subsequent group-commit loop
(lines 275-310) re-fetches `CqUnit` and `SelectMappedBufferResult` without any
null checks:
```java
for (; offset < targetOffset; offset++) {
cqUnit = consumeQueue.get(offset); // can return null after CQ
truncation
bufferSize += cqUnit.getSize(); // NPE here
// ...
message = defaultStore.selectOneMessageByOffset(cqUnit.getPos(),
cqUnit.getSize());
appendingBufferList.add(message); // adds null if expired
ByteBuffer byteBuffer = message.getByteBuffer(); // NPE here
```
When consume-queue entries or commitlog data expire mid-batch (e.g., after
downtime > file retention), the loop throws NPE. Only `ConsumeQueueException`
is caught, so the NPE escapes.
**Buffer Leak:**
Every `SelectMappedBufferResult` added to `appendingBufferList` is only
released through `GroupCommitContext#release()`. When the loop dies with NPE,
the context is never constructed, so all previously fetched buffers leak their
`MappedFile` references. A similar leak occurs when `appendCommitLog` succeeds
but `appendConsumeQueue` fails on the first message — `dispatchRequestList`
stays empty, the `if (!dispatchRequestList.isEmpty())` block is skipped, and
the context is silently dropped.
**Impact:**
- Repeated mapped-buffer/reference leaks on queues whose data expires while
dispatch lags
- Eventually holding expired file references, preventing file cleanup
- NPE crashes the dispatch thread for that cycle
**Severity:** High — affects data reliability and resource management in
tiered storage
**Affected Components:** `tieredstore` module, `MessageStoreDispatcherImpl`
An automated fix proposal will be generated. Reply `/approve` to proceed
with PR generation.
---
*Automated evaluation by github-manager*
--
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]