Code RoomThundering herd in concurrent retries
HardPrep Room Coding #1724

Thundering herd in concurrent retries

Code reviewCode quality & reviewSenior–Staff~30 min

Review this Go retry wrapper used across many concurrent goroutines.

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 30 min
Mark a line and say what kind of problem it is.0 findings
1func withRetry(ctx context.Context, fn func() error) error {
2 var err error
3 for attempt := 0; attempt < 5; attempt++ {
4 err = fn()
5 if err == nil {
6 return nil
7 }
8 delay := time.Duration(attempt*attempt) * time.Second
9 time.Sleep(delay)
10 }
11 return err
12}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.