fix(archive): retry dropIfEmpty deadlock (BIT-32041) #173

Merged
spark merged 1 commits from fix/BIT-32041-drop-if-empty-deadlock into main 2026-11-03 23:19:50 +00:00
Owner

Summary

  • ArchiveService.dropIfEmpty could hit Postgres write-conflict/deadlock (P2034) when two folders settle on the same old event concurrently.
  • The conditional deleteMany is idempotent (gated by its own WHERE), so retrying immediately on P2034 (up to 2 retries) finishes the cleanup instead of leaving an orphaned empty event behind.

Test plan

  • Added apps/api/src/archive/service.test.ts covering retry-then-succeed, exhausted-retries rethrow, and non-P2034 errors not retried.
  • npx vitest run src/archive/ — 27 passed, 3 skipped.
  • npx tsc --noEmit clean.

Fixes BIT-32041.

## Summary - `ArchiveService.dropIfEmpty` could hit Postgres write-conflict/deadlock (P2034) when two folders settle on the same old event concurrently. - The conditional `deleteMany` is idempotent (gated by its own WHERE), so retrying immediately on P2034 (up to 2 retries) finishes the cleanup instead of leaving an orphaned empty event behind. ## Test plan - Added `apps/api/src/archive/service.test.ts` covering retry-then-succeed, exhausted-retries rethrow, and non-P2034 errors not retried. - `npx vitest run src/archive/` — 27 passed, 3 skipped. - `npx tsc --noEmit` clean. Fixes BIT-32041.
spark added 1 commit 2026-11-03 23:05:20 +00:00
fix(archive): retry dropIfEmpty's delete on a Postgres write-conflict deadlock (BIT-32041)
ci / rust (pull_request) Successful in 4m11s
ci / typescript (pull_request) Successful in 7m52s
34aa567741
Two folders settling on the same old event at once could deadlock the
conditional deleteMany in ArchiveService.dropIfEmpty. The delete is
idempotent (gated by its own WHERE), so retrying immediately on P2034
finishes the cleanup instead of leaving an orphaned empty event behind.
spark merged commit e992f28259 into main 2026-11-03 23:19:50 +00:00
Sign in to join this conversation.