Code Room
Code reviewHard
Question
Review this Go code that retries a flaky downstream call from inside an open DB transaction.
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.
Learn the concepts
tx, _ := db.Begin()if _, err := tx.Exec("UPDATE accounts SET balance = balance - $1 WHERE id=$2", amt, id); err != nil { tx.Rollback(); return err}var resp Respfor i := 0; i < 5; i++ { resp, err = ledger.Post(ctx, id, amt) // external HTTP, ~1s timeout each if err == nil { break } time.Sleep(time.Second)}tx.Commit()Run or narrate your approach, then ask the coach.