Clean up orphaned invited members
What does this MR do and why?
Prior to GitLab 14.1.2 (?), it was possible to get entries in the
members
table that had the following properties:
-
user_id
is null -
invite_token
is null -
invite_accepted_at
is non-null
These entries could cause 500 errors when viewing the member list via
the UI or API since user
was nil
.
On GitLab.com, there are 1,336 entries like this, with the newest one created on 2021-08-31.
It's not entirely clear how this happened, but no new orphaned entries have been created since then. Quite possibly it was due to accepting an invite for an e-mail address that was already registered: #371804 (comment 1081761414), but this problem may have been fixed in a security release.
This commit cleans up rows that meet accepted tokens with no associated user.
Database migration timings: !96505 (comment 1081923125)
Relates to #371804 (closed)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.