slfan1989 opened a new pull request, #1356:
URL: https://github.com/apache/ratis/pull/1356

   ## What changes were proposed in this pull request?
   
   This PR fixes a bug in `NettyRpcProxy.Connection.offer()` where 
`CompletableFuture` objects were added to the replies queue before sending 
requests via `writeAndFlush()`. 
   
   When `writeAndFlush()` failed (either synchronously or asynchronously), the 
futures were not removed from the queue, causing:
   
   - **Memory leak**: Unreplied futures accumulate in the queue, holding 
references to large proto messages
   - **Reply mismatch**: Subsequent responses are matched to wrong futures, 
causing Raft protocol errors and potential data corruption
   
   **Changes made:**
   - Added try-catch in `NettyRpcProxy.Connection.offer()` to remove the future 
from queue when `writeAndFlush()` throws `AlreadyClosedException`
   - Added a `ChannelFuture` listener to handle asynchronous write failures and 
clean up the queue
   - Added unit test `TestNettyRpcProxy.testOfferRollbackOnAlreadyClosed()` to 
verify the fix
   
   
   ## What is the link to the Apache JIRA
   
   JIRA: RATIS-2415. Fix queue corruption in NettyRpcProxy when request sending 
fails.
   
   ## How was this patch tested?
   
   Added `TestNettyRpcProxy.testOfferRollbackOnAlreadyClosed()`
   


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