Page MenuHomePhabricator

Attaching Phabricator account to a second Developer account via Striker results in a fatal error
Closed, ResolvedPublicBUG REPORT

Description

User facing crash reported by @Anoop in https://toolsadmin.wikimedia.org/tools/membership/status/1327.

Related error log message from the ELK cluster:

message: user.save failed
stack_trace: Traceback (most recent call last):
  File "/opt/lib/python/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/lib/python/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/opt/lib/python/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/opt/lib/python/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/opt/lib/python/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry 'Anoop' for key 'phabname'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/srv/app/striker/profile/views.py", line 70, in phab_attach
    req.user.save()
  File "/opt/lib/python/site-packages/django/contrib/auth/base_user.py", line 66, in save
    super().save(*args, **kwargs)
  File "/opt/lib/python/site-packages/django/db/models/base.py", line 744, in save
    force_update=force_update, update_fields=update_fields)
  File "/opt/lib/python/site-packages/django/db/models/base.py", line 782, in save_base
    force_update, using, update_fields,
  File "/opt/lib/python/site-packages/django/db/models/base.py", line 854, in _save_table
    forced_update)
  File "/opt/lib/python/site-packages/django/db/models/base.py", line 903, in _do_update
    return filtered._update(values) > 0
  File "/opt/lib/python/site-packages/django/db/models/query.py", line 760, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
  File "/opt/lib/python/site-packages/django/db/models/sql/compiler.py", line 1471, in execute_sql
    cursor = super().execute_sql(result_type)
  File "/opt/lib/python/site-packages/django/db/models/sql/compiler.py", line 1142, in execute_sql
    cursor.execute(sql, params)
  File "/opt/lib/python/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/opt/lib/python/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/opt/lib/python/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/lib/python/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/lib/python/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/lib/python/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/opt/lib/python/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/opt/lib/python/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/opt/lib/python/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
django.db.utils.IntegrityError: (1062, "Duplicate entry 'Anoop' for key 'phabname'")

Event Timeline

Striker still seems to struggle with getting its larger error messages to end up in the ELK cluster. I looked directly at the journalctl managed logs for the service on cloudweb1003 and found:

django.db.utils.IntegrityError: (1062, "Duplicate entry 'Anoop' for key 'phabname'")

@Anoop's Phabricator account is already associated with the Minato826 Developer account.

striker_admin@m5-master.eqiad.wmnet(striker)> select * from labsauth_labsuser where phabname='Anoop'\G
*************************** 1. row ***************************
          id: 407
    password:
  last_login: 2022-10-02 19:17:52
is_superuser: 0
    ldapname: Minato826
   ldapemail: <REDACTED>
   shellname: anoopgkrao
     sulname: AnoopBot
    sulemail: <REDACTED>
    realname:
  oauthtoken: <REDACTED>
 oauthsecret: <REDACTED>
    is_staff: 0
   is_active: 1
  created_at: 2017-09-24 07:16:37
  updated_at: 2022-10-02 19:17:52
   phabimage: https://phab.wmfusercontent.org/file/data/uivnpgmtmoxrm2tq4bsm/PHID-FILE-mclglpiqthuxiyggqm7p/profile
    phabname: Anoop
phabrealname:
     phaburl: https://phabricator.wikimedia.org/p/Anoop/
        phid: PHID-USER-pclwun2b24gtsuu5xxeh
1 row in set (0.001 sec)
bd808 renamed this task from toolforge phabricator link giving exception to Attaching Phabricator account to a second Developer account via Striker results in a fatal error.Oct 6 2022, 9:31 PM
bd808 updated the task description. (Show Details)
bd808 changed the subtype of this task from "Task" to "Bug Report".Oct 6 2022, 9:33 PM

Striker still seems to struggle with getting its larger error messages to end up in the ELK cluster.

It turns out the message was in the ELK cluster. I was not finding it because the messages there do not carry the req_id value from the crash report as I expected. That is another bug to investigate.

I'm not exactly sure if the core bug here is that we expect Phabricator accounts to have a one-to-one mapping to Developer accounts in the same way we expect that for SUL accounts, or if the bug is lack of error handling and clear messaging to the user, or some combination of both. Since both Developer and SUL accounts can be used to create Phabricator accounts, I think I would lean towards the real bug here being the lack of proper error handling to convert this into an understandable error message for the user.

Possibly related, though error doesn't seem to quite match
https://toolsadmin.wikimedia.org/tools/membership/status/1349

https://logstash.wikimedia.org/app/discover#/doc/logstash-*/logstash-default-1-7.0.0-1-2022.11.18?id=RguWiIQBRsHAyp5JrE7S

Traceback (most recent call last):
  File "/opt/lib/python/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/lib/python/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/opt/lib/python/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/opt/lib/python/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/opt/lib/python/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb.IntegrityError: (1062, "Duplicate entry 'nah_omy' for key 'phabname'")

Change #1186629 had a related patch set uploaded (by BryanDavis; author: Bryan Davis):

[labs/striker@master] phab_attach: Give notice when Phabricator account is already in use

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

bd808 changed the task status from Open to In Progress.Sep 9 2025, 10:41 PM
bd808 claimed this task.
bd808 triaged this task as Medium priority.
bd808 moved this task from Backlog to Doing on the Striker board.

@bd808 would it be possible to unlink Minato826 developer account from this phabricator account similar to T403918#11155681

Change #1186629 merged by jenkins-bot:

[labs/striker@master] phab_attach: Give notice when Phabricator account is already in use

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

@bd808 would it be possible to unlink Minato826 developer account from this phabricator account similar to T403918#11155681

It is possible, yes. Please file a separate task for that so we can keep better track of things.

@bd808 would it be possible to unlink Minato826 developer account from this phabricator account similar to T403918#11155681

It is possible, yes. Please file a separate task for that so we can keep better track of things.

@bd808 , done T404239

Change #1213546 had a related patch set uploaded (by BryanDavis; author: Bryan Davis):

[operations/puppet@production] striker: Bump container version

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

Change #1213546 merged by Andrew Bogott:

[operations/puppet@production] striker: Bump container version

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