From 1617b7c0d6686e7db298e0553fbd41f424586e8b Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Mon, 6 Feb 2023 16:08:21 +0100 Subject: [PATCH] add jitter to the retries by the queue --- queue/queue.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/queue/queue.go b/queue/queue.go index cd2d34a..9838659 100644 --- a/queue/queue.go +++ b/queue/queue.go @@ -68,6 +68,8 @@ var dial = func(ctx context.Context, timeout time.Duration, addr string, laddr n return dialer.DialContext(ctx, "tcp", addr) } +var jitter = mox.NewRand() + var queueDB *bstore.DB // Msg is a message in the queue. @@ -456,7 +458,7 @@ func deliver(resolver dns.Resolver, m Msg) { // 8h, 16h (send permanent failure DSN). // ../rfc/5321:3703 // todo future: make the back off times configurable. ../rfc/5321:3713 - backoff := (7*60 + 30) * time.Second + backoff := time.Duration(7*60+30+jitter.Intn(10)-5) * time.Second for i := 0; i < m.Attempts; i++ { backoff *= time.Duration(2) }