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

   ## What changes were proposed in this pull request?
   
   **Problem**
   
   SCM can mark a Ratis pipeline OPEN before the pipeline's Ratis leader is 
ready. If a WriteChunk arrives in that window, the leader rejects it with 
`LeaderNotReadyException`. A PutBlock sent right after it can still be 
accepted. Applying that PutBlock without its chunk marks the container 
UNHEALTHY, and the pipeline is closed. The window comes from two places:
   - RATIS/ONE: `PipelineReportHandler` records the reporting datanode as 
leader on any report, so the pipeline opens before the datanode has even 
elected a leader.
   - RATIS/THREE: SCM waits for a report with `isLeader=true`, but the datanode 
sets that flag in `notifyLeaderChanged`, right after the election. The leader 
is not ready at that point.
   
   **Implementation idea**
   
   - Datanode: `ContainerStateMachine` overrides `notifyLeaderReady()`, which 
calls the new `XceiverServerRatis.handleLeaderReadyNotification()`. That method 
sets the leader flag and sends a pipeline report. 
`handleLeaderChangedNotification` now only clears the flag and no longer sends 
a report.
   - SCM: `PipelineReportHandler.setPipelineLeaderId` sets the leader only when 
the report has `isLeader=true`. The RATIS/ONE special case is removed. Recon 
inherits this through `ReconPipelineReportHandler`.
   
   **Key decisions**
   
   - The fix is on the datanode side, using Ratis' leader-ready callback. SCM 
keeps its existing rule that a pipeline opens only once its leader is known. 
Having SCM poll or wait for readiness would add delay and an extra mechanism.
   - Re-elections on OPEN pipelines go through the same path, so SCM learns the 
new leader once that leader is ready. Clients should only be sent to a leader 
at that point anyway.
   
   **Side effects**
   
   - A new pipeline opens slightly later: after the leader applies its first 
entry of the term, instead of right after the election.
   - Compatibility: older datanodes already report `isLeader=true` for 
RATIS/ONE groups, because a single-node group elects itself and gets a 
leader-change notification for itself. A new SCM therefore still opens 
RATIS/ONE pipelines on old datanodes. No proto change.
   - Followers send no pipeline report on leader change, which they did not do 
before either. The leader sends one report when it is ready instead of when it 
is elected.
   
   Co-authored-by: Claude Opus 5.5 <[email protected]>
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-17334
   
   ## 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