yandrey321 opened a new pull request, #11890:
URL: https://github.com/apache/ozone/pull/11890

   ## What changes were proposed in this pull request?
   
   **Problem.** When an ALL_COMMITTED watch fails, 
`XceiverClientRatis.watchForCommit` sends a MAJORITY_COMMITTED watch
   from inside the `exceptionally` handler of the first one. If the client was 
closed in the meantime, `getClient()`
   throws `NullPointerException("client is null")` there (`close()` sets the 
client to `null`). The exception is
   swallowed by the handler's own future, so the future returned by 
`watchForCommit` is never completed, and
   `BlockOutputStream.waitForAllPendingFlushes()` waits for it forever with an 
untimed `get()`.
   
   The client can be closed while a watch is pending because 
`BlockOutputStream.handleFlush(true)` releases it in a
   `finally` block after a failed flush, while the watch for another putBlock 
is still running. Since HDDS-17491, the
   periodic `cleanUp()` then closes the released client once its cache entry 
has expired, so master hits this in
   `TestKeyInputStream#readAfterReplication(boolean)[2]`, which times out after 
5 minutes.
   
   **Change.** `watchForCommit` always completes the future it returns:
   - If sending the MAJORITY_COMMITTED watch fails, the future fails with the 
original watch failure, with the fallback
     failure attached as suppressed.
   - If the ALL_COMMITTED watch failed because the client is closed 
(`AlreadyClosedException`), the
     MAJORITY_COMMITTED watch is not attempted, since it cannot succeed on a 
closed client.
   
   The write then fails over to a new block, as it does when the client is not 
closed.
   
   **Key decisions.**
   - **Fix the never-completed future, not the client lifecycle.** Releasing a 
client while its async work is still
     pending predates HDDS-17491 (before it, any cache access after the idle 
threshold could close it the same way).
     Keeping the client referenced until its futures complete is a larger 
change to the write path, and is left to a
     follow-up.
   - **Report the original failure,** so the retry logic in `KeyOutputStream` 
sees the same exception types as when the
     fallback watch fails normally.
   
   
   Generated-by: Claude Code (Claude Opus 5.5)
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-17648
   
   ## How was this patch tested?
   
   Unit and integration tests


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to