hani-fouladgar opened a new pull request, #12138:
URL: https://github.com/apache/ozone/pull/12138

   ## What changes were proposed in this pull request?
   When OM sends block deletions to SCM faster than the SCM Ratis followers can 
apply them, the followers fall behind in applying committed transactions. This 
PR adds backpressure: OM reduces its key deletion batch size while any SCM is 
lagging, and goes back to the full batch size once the lag clears.
   
   This is a redesign of #11571, which was reverted in #11804. #11571 computed 
lag on the leader from the follower `nextIndex`, which only reflects log 
replication. The actual problem is follower-local apply lag (commit index vs. 
applied index), which the leader cannot see from append-entries replies.        
                                                                                
                                                                                
                                                                      
   
    **SCM**
    - New `FollowerApplyLagMonitor`: on the leader, every 
`ozone.scm.ha.follower.apply.lag.poll.interval` (default 5s) it asks each peer 
for its applied index through the Ratis group management API (`GroupInfoReply`).
       Lag = leader commit index − lowest applied index across all SCMs, so a 
single slow follower raises it.
   - Peers that do not answer are left out. If no follower answers, the 
previous value is kept. 
   - One `RaftClient` is reused across polls. It is rebuilt only when the group 
changes and closed when the node is not the leader.
   - The lag is returned on every `deleteKeyBlocks` response in a new optional 
proto field `DeleteScmKeyBlocksResponseProto.scmFollowerApplyLag`.
   
   **OM**
   - `KeyDeletingService` reads the last lag reported by SCM. If it is at or 
above `ozone.om.key.deleting.scm.follower.lag.throttle.threshold` (default 
100000), the per-task limit drops to 
`ozone.om.key.deleting.scm.lag.throttled.limit.per.task` (default 1000, must be 
> 0 so OM keeps getting fresh lag readings). A threshold of 0 or less disables 
throttling.
   - New metric `numKeyDeletionThrottledBySCMLag`. Throttle start and stop are 
each logged once.
   
   **Compatibility**
   - The new proto field is optional. An old SCM reports 0 (no throttling), and 
an old OM ignores the field. 
     
   ## What is the link to the Apache JIRA
   
    https://issues.apache.org/jira/browse/HDDS-17075
   
   ## How was this patch tested?
   - New unit test `TestFollowerApplyLagMonitor`: lag calculation, unreachable 
peers, non-leader, and a failed poll keeping the previous value.                
                                                                                
                                                                                
                                                                                
                        
   - New cases in `TestKeyDeletingService`: throttling above the threshold, the 
metric, and throttling disabled when the threshold is 0 or less.                
                                                                                
                                                                                
                                                                                
                        
   - New integration test `TestScmFollowerApplyLagThrottle` (3 SCMs): stalls 
apply on one follower and on both followers by blocking the block-deletion 
invoker of the `SCMStateMachine`. It verifies that the leader reports the lag, 
OM throttles, and OM goes back to the full limit after the followers catch up.
   


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