zjncs opened a new pull request, #11125:
URL: https://github.com/apache/rocketmq/pull/11125
## Motivation
`TimerMessageStore.convertMessage` rewrites a timer message back to its
destination when it is not rolled:
```java
msgInner.setTopic(msgInner.getProperty(MessageConst.PROPERTY_REAL_TOPIC));
msgInner.setQueueId(Integer.parseInt(msgInner.getProperty(MessageConst.PROPERTY_REAL_QUEUE_ID)));
```
A timer message in `rmq_sys_wheel_timer` whose destination properties are
missing or malformed (corrupted properties, or a message written straight into
the system topic) makes the second line throw `NumberFormatException`. In the
dequeue thread (`DequeuePutService`), the surrounding `catch (Throwable)` logs
"Unknown error" and then — because `timerSkipUnknownError` defaults to
**false** — calls `holdMomentForUnknownError()` and loops back to the *same*
`TimerRequest`: the conversion throws again, so one poison message wedges the
timer dequeue thread in an endless sleep-retry loop and no later timer message
is delivered.
## Modification
- `convertMessage` validates `PROPERTY_REAL_TOPIC` and
`PROPERTY_REAL_QUEUE_ID` before using them and returns `null` when the
destination is unusable, logging a `[BUG] ... discard` line (mirroring the
guard style of `ScheduleMessageService.messageTimeUp`).
- The dequeue call site skips a null conversion result ("Skipping message
due to missing or malformed destination"), releases the request and moves on.
## Test Evidence
New test `testConvertMessageWithMalformedDestination` covers: non-numeric
queue id, missing queue id, missing real topic, and the well-formed case.
```
docker exec rmq-build mvn -q -pl store test
-Dtest='TimerMessageStoreTest#testConvertMessageWithMalformedDestination'
-Dsurefire.failIfNoSpecifiedTests=true
```
Before the fix:
```
java.lang.NumberFormatException: For input string: "notANumber"
Tests run: 1, Failures: 0, Errors: 1
```
After the fix:
```
docker exec rmq-build mvn -q -pl store test -Dtest='TimerMessageStoreTest'
-Dsurefire.failIfNoSpecifiedTests=true
Tests run: 12, Failures: 0, Errors: 0, Skipped: 0
```
No associated issue (self-discovered during a store self-audit).
--
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]