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.
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 main2026-11-03 23:19:50 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
ArchiveService.dropIfEmptycould hit Postgres write-conflict/deadlock (P2034) when two folders settle on the same old event concurrently.deleteManyis 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
apps/api/src/archive/service.test.tscovering retry-then-succeed, exhausted-retries rethrow, and non-P2034 errors not retried.npx vitest run src/archive/— 27 passed, 3 skipped.npx tsc --noEmitclean.Fixes BIT-32041.