Last-admin guard and delete run in separate transactions #88

Closed
opened 2026-11-08 18:11:10 +00:00 by chris-kreidl · 1 comment
chris-kreidl commented 2026-11-08 18:11:10 +00:00 (Migrated from github.com)

(session 39) Deleting a user checks the last-admin guard, then deletes in a second transaction (deleteAccountAndLinks); only two last admins deleting each other at once could slip through.

Moved from docs/PROGRESS.md → Follow-ups → Later on 2026-11-08.

(session 39) Deleting a user checks the last-admin guard, then deletes in a second transaction (`deleteAccountAndLinks`); only two last admins deleting each other at once could slip through. _Moved from docs/PROGRESS.md → Follow-ups → Later on 2026-11-08._
chris-kreidl commented 2026-11-08 20:16:57 +00:00 (Migrated from github.com)

What this is about. Deleting a user refuses to delete the last admin. The check (assertDeletable in src/server/admin-store.ts) and the delete (deleteAccountAndLinks) run in separate transactions. Only one race slips through: two admins deleting each other at the same moment could both succeed, leaving no admin. Role changes and bans already do the check and the write in one serializable transaction.

Status (checked 2026-11-08): unchanged.

Fix: move the check into the delete's transaction. Small, but only matters with two admins, and today you're the only one.

**What this is about.** Deleting a user refuses to delete the last admin. The check (`assertDeletable` in `src/server/admin-store.ts`) and the delete (`deleteAccountAndLinks`) run in separate transactions. Only one race slips through: two admins deleting each other at the same moment could both succeed, leaving no admin. Role changes and bans already do the check and the write in one serializable transaction. **Status (checked 2026-11-08):** unchanged. **Fix:** move the check into the delete's transaction. Small, but only matters with two admins, and today you're the only one.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ckreidl/trainer#88
No description provided.