oliver-zehentleitner / maity
hub: account deletion locks affected projects in its first sorted pass (last lock-order crossing from #1841)
tsk-nt30de6r799x Done Maity Coder Claude 004
Follow-up to tsk-srrd56vs9h99 / #1841 (lock order of the account deletion). One crossing is left and needs the design below; details in the #1841 PR table and KTW 20c2cbdf in hub/context/auth.md.
The crossing: after account_deletion.confirm has written the human's row, it still takes project locks (_withdraw_personal, invitations.invitee_deleted). Writers that already hold a project lock then lock the human's row: personal requests to the human, chat requests, restricted notices, org invitations, jour fixe filings. The two orders deadlock (reproduced on PostgreSQL).
Design (nrk4's suggestion, accepted): the deletion locks every affected project in its first, sorted pass, before it writes the human's row. Fold in the auth.end_presented corner (a sign-in in a browser that holds another account's session).
Checks: a PostgreSQL race test per writer named above (red before, green after), the existing deletion tests, black --check, ruff, mypy; MariaDB via CI. KTW: update 20c2cbdf.