Page MenuHomePhabricator

Fix maintain-dbusers to handle clashes with old existing accounts
Closed, ResolvedPublic

Description

When maintain-dbusers attempts to make new accounts for folks who have had accounts created in the past on labsdb1005, it doesn't handle it and fails, blocking account creation for new tools and users. We thought this would go away when 1001 and 1003 where decommissioned, but it looks like this problem persists in labsdb1005.

Event Timeline

Is the fix as simple as adding DROP USER IF EXISTS {username}; to the start of ACCOUNT_CREATION_SQL['legacy']?

That seems like it would work yes :)

Change 418709 had a related patch set uploaded (by BryanDavis; owner: Bryan Davis):
[operations/puppet@production] toolsdb: Remove stale accounts if present in maintain-dbusers

https://gerrit.wikimedia.org/r/418709

Change 418709 merged by Bstorm:
[operations/puppet@production] toolsdb: Remove stale accounts if present in maintain-dbusers

https://gerrit.wikimedia.org/r/418709

Is the fix as simple as adding DROP USER IF EXISTS {username}; to the start of ACCOUNT_CREATION_SQL['legacy']?

Turns out that the MariaDB this is needed on is too old. IF EXISTS only works starting from 10.1.3.

Change 419630 had a related patch set uploaded (by Bstorm; owner: Bstorm):
[operations/puppet@production] toolsdb: Remove stale accounts if present in maintain-dbusers

https://gerrit.wikimedia.org/r/419630

That catches the exception thrown in this case (rather specifically), drops the user and then adds them as usual.

Change 419630 merged by Bstorm:
[operations/puppet@production] toolsdb: Remove stale accounts if present in maintain-dbusers

https://gerrit.wikimedia.org/r/419630

Change 420114 had a related patch set uploaded (by Bstorm; owner: Bstorm):
[operations/puppet@production] toolsdb: include failsafe against removing admin accounts

https://gerrit.wikimedia.org/r/420114

Change 420114 merged by Bstorm:
[operations/puppet@production] toolsdb: include failsafe against removing admin accounts

https://gerrit.wikimedia.org/r/420114

At this point, this should all work fine. We'll have to wait for this edge case to occur before a true test happens. I think its safe to close this for now, though.