lollipopjin commented on code in PR #10473:
URL: https://github.com/apache/rocketmq/pull/10473#discussion_r3400404544


##########
tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatAppendFile.java:
##########
@@ -81,22 +81,15 @@ public void recover() {
      * @see <a href="https://github.com/apache/rocketmq/issues/9544";>Related 
GitHub Issue</a>
      */
     public long getFileCorrectSize(FileSegment fileSegment) {
-        while (true) {
+        for (int retry = 0; retry < 3; retry++) {

Review Comment:
   Changing `getFileCorrectSize()` from infinite-retry to bounded-retry 
introduces a silent message loss path:
   
   1. Returns -1 → `initPosition(-1)` → `commitPosition=-1`
   2. Subsequent `append()` succeeds (no lower-bound check on appendPosition)
   3. `commitAsync()` fails writing at position -1 in remote storage
   4. `correctPosition()` resets commitPosition to actual file size but 
discards the uncommitted buffer
   5. Dispatch offset has already advanced — those messages are never retried
   
   This trades a liveness issue (startup hangs) for a correctness issue (silent 
data loss). Suggest either throwing on exhausted retries (fail-fast) or adding 
a `-1` guard in `recoverFileSize()` / `initOffset()` callers.



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