Commit dda4edc
OUT-4105 | Stop dropping buffered grouped emails when the DB is briefly unreachable
The flush job's retry budget was ~3 seconds (3 attempts, 1s/2s backoff). When
the Supabase pooler went unreachable for 47 minutes on 8/24 every window
exhausted it on the first $queryRaw, and onFailure then DELETEd the whole
window — unsent rows included — so those grouped emails were destroyed, or
orphaned as sentAt IS NULL when the delete failed too. bufferGroupedEmailEvent
only reuses windows younger than 5 minutes, so orphans are never re-flushed.
Widen the in-run backoff to ~75s, and on exhaustion re-enqueue the window with
a 15m delay for up to two rounds before cleaning up. The run is already
idempotent (it reads sentAt IS NULL and marks each recipient as it goes), so a
re-enqueue only sends what is still outstanding. Sentry now fires once the
rounds are spent rather than on every window of a transient outage.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y4tF84tzJW7Bo1DehsDX221 parent 9806fe8 commit dda4edc
2 files changed
Lines changed: 47 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
333 | 340 | | |
334 | 341 | | |
335 | 342 | | |
336 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
337 | 353 | | |
338 | 354 | | |
339 | | - | |
| 355 | + | |
340 | 356 | | |
341 | 357 | | |
342 | 358 | | |
| |||
348 | 364 | | |
349 | 365 | | |
350 | 366 | | |
351 | | - | |
352 | | - | |
| 367 | + | |
| 368 | + | |
353 | 369 | | |
354 | 370 | | |
| 371 | + | |
355 | 372 | | |
356 | 373 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
319 | 324 | | |
320 | 325 | | |
321 | 326 | | |
322 | | - | |
323 | | - | |
324 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
325 | 342 | | |
326 | 343 | | |
| 344 | + | |
327 | 345 | | |
328 | 346 | | |
329 | 347 | | |
| |||
341 | 359 | | |
342 | 360 | | |
343 | 361 | | |
344 | | - | |
| 362 | + | |
345 | 363 | | |
346 | 364 | | |
347 | 365 | | |
| |||
350 | 368 | | |
351 | 369 | | |
352 | 370 | | |
353 | | - | |
354 | | - | |
| 371 | + | |
| 372 | + | |
355 | 373 | | |
356 | 374 | | |
0 commit comments