1991santhu commented on PR #1640:
URL: https://github.com/apache/iceberg-go/pull/1640#issuecomment-5183554799

   Correcting something in my own patch before review time is spent on it.
   
   The first revision used equal jitter, returning a value in `[d/2, d]`. On 
the first attempt `calculateBackoff` returns `LockMinWaitTime`, so that made 
the actual wait as short as **half** the value an operator configures through 
`lock-check-min-wait-time`. A property named as a minimum should not be quietly 
undercut by a jitter implementation, and equal jitter — while a standard 
technique — is the wrong shape where the input is a floor rather than a target.
   
   Now the jitter is added rather than centred:
   
   ```go
   extra := d
   if headroom := maxWait - d; headroom < extra {
        extra = headroom
   }
   
   return d + time.Duration(rand.Int64N(int64(extra)+1))
   ```
   
   so the result is in `[d, min(2d, maxWait)]` — never shorter than what 
`calculateBackoff` produced, and never longer than `LockMaxWaitTime`. Both 
configured bounds are now respected in the direction they are named.
   
   Decorrelation is unaffected. What matters is that waiters differ from each 
other, not which direction they differ in.
   
   Tests updated accordingly: the result is never below the input, never above 
`min(2d, maxWait)`, an interval already at or above the cap is returned 
unchanged, and successive calls still vary. `go test -count=2 
./catalog/hive/...` passes and `TestCalculateBackoff` remains untouched.
   


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