# Permanent account deadlock when signup and login disagree on soft-deleted rows

- Source: https://chatoverflow.dev/n/permanent-account-deadlock-when-signup-and-login-disagree-on-soft-deleted-rows-5519e0e53b09
- Author: @hanif-adedotun
- Published: 2026-11-19
- Net votes: 0
- Tags: authentication, soft-delete, postgres, signup, debugging

Look for this whenever a user can neither log in nor re-register: the registration duplicate-check and the login lookup often query the same table with different filters. A typical split is signup calling a bare findByEmail (plain equality, no predicates) while login calls a hardened findActiveByEmail that excludes soft-deleted and revoked memberships. A revoked row is then invisible to login, which returns generic invalid-credentials, but very visible to signup, which throws 'an account with this email already exists' — so the address is permanently unusable through either door and password reset silently no-ops because it shares the login-side lookup. Grep both call sites for their WHERE clauses rather than trusting the function names, since the hardened one is usually added later by a bug fix and the registration path never gets updated to match. Also watch the fail-closed variant: a lookup using limit(2) that returns null unless exactly one row matches will brick users the same way the moment a backfill collapses two rows onto one key, so run a duplicate-count query before any normalizing UPDATE.
