gyh-hhz opened a new pull request, #11581:
URL: https://github.com/apache/rocketmq/pull/11581

   ### Which Issue(s) This PR Fixes
   
   - Fixes #11420
   
   ### Brief Description
   
   In `CommitLog#asyncPutMessage` and `CommitLog#asyncPutMessages`, when the 
initial append returns `AppendMessageStatus.END_OF_FILE`, `CommitLog` rolls 
over to a new `MappedFile` and retries `appendMessage` / `appendMessages`.
   
   Previously, if the retry append also failed (for example, returning 
`END_OF_FILE` again when the encoded message or batch exceeds 
`mappedFileSizeCommitLog` while still within `maxMessageSize`, or returning 
`UNKNOWN_ERROR` / `ROCKSDB_ERROR`), execution broke out of the `switch`, 
skipped `increaseOffset`, and unconditionally constructed `new 
PutMessageResult(PutMessageStatus.PUT_OK, result)`, updated put statistics with 
`maxBlank`, and proceeded to flush/HA—causing `SendMessageProcessor` to 
acknowledge an unstored message as `SEND_OK`.
   
   This PR checks `result.getStatus()` after unlocking any warmed-up previous 
`MappedFile` and before building `PUT_OK`, mapping non-`PUT_OK` retry statuses 
consistently with the initial append failure branches (`END_OF_FILE` / 
`MESSAGE_SIZE_EXCEEDED` / `PROPERTIES_SIZE_EXCEEDED` -> 
`PutMessageStatus.MESSAGE_ILLEGAL`, others such as `UNKNOWN_ERROR` / 
`ROCKSDB_ERROR` -> `PutMessageStatus.UNKNOWN_ERROR`).
   
   ### How Did You Test This Change?
   
   Added unit tests covering both single-message and batch-message put paths:
   - `DefaultMessageStoreTest#testPutMessageLargerThanCommitLogFileRejected`: 
verifies a message larger than `mappedFileSizeCommitLog` returns 
`PutMessageStatus.MESSAGE_ILLEGAL` (`AppendMessageStatus.END_OF_FILE`), keeps 
queue offset and topic put stats at `0`, and allows subsequent valid messages 
on the same queue to be written and read at offset `0`.
   - `DefaultMessageStoreTest#testPutMessageRetryAppendUnknownErrorPropagated`: 
verifies `UNKNOWN_ERROR` on the retry append after `END_OF_FILE` is propagated 
as `PutMessageStatus.UNKNOWN_ERROR` without advancing queue offset.
   - `BatchPutMessageTest#testPutMessagesLargerThanCommitLogFileRejected`: 
verifies oversized `MessageExtBatch` returns `PutMessageStatus.MESSAGE_ILLEGAL` 
and subsequent valid batches succeed at offset `0`.
   - `BatchPutMessageTest#testPutMessagesRetryAppendUnknownErrorPropagated`: 
verifies retry `UNKNOWN_ERROR` in batch put path returns 
`PutMessageStatus.UNKNOWN_ERROR` with zero queue offset and topic put stats.
   - Verified Checkstyle (`0 violations`) and SpotBugs (`0 warnings`) on 
`rocketmq-store`.


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