Skip to content

Commit 2e65b10

Browse files
committed
adjust exponential backoff to match 48 hours of retries by starting at 42 seconds for 12 retries
1 parent de73dba commit 2e65b10

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

api/resolvers/domain.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ export default {
7979
})
8080

8181
// schedule domain verification in 5 seconds, apply exponential backoff and keep it for 2 days
82+
// 12 retries, 42 seconds of delay between retries will fit 48 hours of trying for DNS propagation
8283
await models.$executeRaw`INSERT INTO pgboss.job (name, data, retrylimit, retrybackoff, retrydelay, startafter, keepuntil)
8384
VALUES ('domainVerification',
8485
jsonb_build_object('domainId', ${updatedDomain.id}::INTEGER),
85-
21,
86+
12,
8687
true,
87-
'30', -- 30 seconds of delay between retries
88+
'42', -- 42 seconds of delay between retries
8889
now() + interval '5 seconds',
8990
now() + interval '2 days')`
9091

worker/domainVerification.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ async function verifyDomain (domain, models) {
5353

5454
if (data.verification?.dns?.state === 'FAILED' || data.verification?.ssl?.state === 'FAILED') {
5555
data.failedAttempts += 1
56-
data.updatedAt = new Date()
57-
const oneDayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000)
58-
// TODO: discussion
59-
if (data.failedAttempts > 10 && data.updatedAt < oneDayAgo) {
56+
// exponential backoff at the 11th attempt is roughly 48 hours
57+
if (data.failedAttempts > 11) {
6058
data.status = 'HOLD'
59+
data.failedAttempts = 0
6160
}
6261
}
6362

0 commit comments

Comments
 (0)