Code RoomThundering herd retry without backoff
HardPrep Room Coding #1937

Thundering herd retry without backoff

Code reviewCode quality & reviewSenior–Staff~22 min

Review this Go retry helper used by every instance of a fleet to call a shared downstream. It already retries on error.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1func fetch(ctx context.Context, url string) (*http.Response, error) {
2 var lastErr error
3 for i := 0; i < 5; i++ {
4 resp, err := http.Get(url)
5 if err == nil && resp.StatusCode < 500 {
6 return resp, nil
7 }
8 lastErr = err
9 time.Sleep(50 * time.Millisecond)
10 }
11 return nil, lastErr
12}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.