unable to log in to Gerrit - "name already in use"

397 views
Skip to first unread message

Paul Mena

unread,
May 6, 2022, 11:37:57 AM5/6/22
to repo-d...@googlegroups.com

A user who hasn't logged in to our Gerrit 2.10 instance for a few months tried to log in yesterday and got a "Forbidden" error. In the logs I see this:

 

[2022-05-05 11:09:47,829] ERROR com.google.gerrit.server.account.AccountManager : Cannot assign user name "redacted" to account 1000064; name already in use.

[2022-05-05 11:09:47,836] ERROR com.google.gerrit.httpd.auth.container.HttpLoginServlet : Unable to authenticate user "redacted"

com.google.gerrit.server.account.AccountUserNameException: Cannot assign user name "redacted" to account 1000064; name already in use.

It appears that he tried to re-register (more than once, in fact), which created a new user ID that no longer matches his user name. As a Gerrit admin, is there some way that I can view the user IDs and remove the ones that are bogus?

I just tried running this command, but it failed:

user@desktop=> ssh -p 29418 ad...@gerrit.whoi.edu gerrit set-account --delete-external-id 1000060 redacted
fatal: "--delete-external-id" is not a valid option

Is there some way for me to 1) determine how many external-ids are associated with the account, and 2) remove the ones that are redundant?

Short of that, would it be possible to just delete the account entirely and start out from scratch?

Paul

 

 

Paul Mena

Senior Application Administrator

WHOI - Information Services

508-289-3539

 

PAUL MENA

unread,
May 6, 2022, 11:37:57 AM5/6/22
to Repo and Gerrit Discussion
I thought I had posted this yesterday, but it didn't show up in the list of discussions. Apologies in advance if it ends up being a duplicate.

A user who hasn't logged in to our Gerrit 2.10 instance for a few months tried to log in yesterday and got a "Forbidden" error. In the logs I see this:

[2022-05-05 11:09:47,829] ERROR com.google.gerrit.server.account.AccountManager : Cannot assign user name "redacted" to account 1000064; name already in use. [2022-05-05 11:09:47,836] ERROR com.google.gerrit.httpd.auth.container.HttpLoginServlet : Unable to authenticate user "redacted" com.google.gerrit.server.account.AccountUserNameException: Cannot assign user name "redacted" to account 1000064; name already in use.

It appears that he tried to re-register, which created a new user ID that no longer matches his user name. He tried to do that several times, each time creating a new ID. As a Gerrit admin, is there some way that I can view the user IDs and remove the ones that are bogus?

Matthias Sohn

unread,
May 6, 2022, 4:52:29 PM5/6/22
to Paul Mena, repo-d...@googlegroups.com
On Fri, May 6, 2022 at 5:37 PM Paul Mena <pm...@whoi.edu> wrote:

A user who hasn't logged in to our Gerrit 2.10 instance for a few months tried to log in yesterday and got a "Forbidden" error. In the logs I see this:


Gerrit 2.10 reached EOL many years ago [1]. You should consider upgrading to a supported release asap.
  

[2022-05-05 11:09:47,829] ERROR com.google.gerrit.server.account.AccountManager : Cannot assign user name "redacted" to account 1000064; name already in use.

[2022-05-05 11:09:47,836] ERROR com.google.gerrit.httpd.auth.container.HttpLoginServlet : Unable to authenticate user "redacted"

com.google.gerrit.server.account.AccountUserNameException: Cannot assign user name "redacted" to account 1000064; name already in use.

It appears that he tried to re-register (more than once, in fact), which created a new user ID that no longer matches his user name. As a Gerrit admin, is there some way that I can view the user IDs and remove the ones that are bogus?

I just tried running this command, but it failed:

user@desktop=> ssh -p 29418 ad...@gerrit.whoi.edu gerrit set-account --delete-external-id 1000060 redacted
fatal: "--delete-external-id" is not a valid option
this command option doesn't exist in 2.10 [2]. 

Is there some way for me to 1) determine how many external-ids are associated with the account, and 2) remove the ones that are redundant?

Short of that, would it be possible to just delete the account entirely and start out from scratch?

In Gerrit 2.10 account metadata is stored in the database. You can try to use the gsql command [3]
to query and fix this data. Try that on a copy first to ensure you don't corrupt the database.
 

-Matthias

Paul

 

 

Paul Mena

Senior Application Administrator

WHOI - Information Services

508-289-3539

 

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/MW5PR16MB45947F6951160BB945234AA0CEC59%40MW5PR16MB4594.namprd16.prod.outlook.com.

Paul Mena

unread,
May 9, 2022, 9:49:29 AM5/9/22
to Matthias Sohn, repo-d...@googlegroups.com

Mattias,

 

Thank you for the reply! We would love to upgrade our Gerrit 2.10 instance to something newer and are trying to get that into our next budget.

 

In the meantime, I’ve been able to query the Gerrit database (after taking a backup) and have noticed 1) there are no account_ids beyond 1000059, making it more baffling that the error below references the account_id 1000065, 2) the troubled account is lacking a row in the database.

 

To illustrate, here is a query from a working account (mine):

 

gerrit> select * from account_external_ids where external_id like '%pmena%';

account_id | email_address       | password | external_id

-----------+---------------------+----------+----------------------

1000058    | 'pm...@default.com' | NULL     | gerrit:pmena

1000058    | NULL                | NULL     | username:pmena

1000058    | pm...@whoi.edu      | NULL     | mailto:pm...@whoi.edu

(3 rows; 1 ms)

 

Next, a query of the affected account:

 

gerrit> select * from account_external_ids where external_id like '%redacted%';

account_id | email_address     | password | external_id

-----------+-------------------+----------+-------------------------

1000059    | NULL              | NULL     | username:redacted

1000059    | reda...@whoi.edu | NULL     | mailto:reda...@whoi.edu

(2 rows; 1 ms)

 

As you can see, the row that should contain the external_id “gerrit:redacted” is missing. Is there a way to remedy this?

 

Thank you so much for the help!

 

Paul

 

Paul Mena

Senior Application Administrator

Woods Hole Oceanographic Institution

Antoine Musso

unread,
May 9, 2022, 3:44:32 PM5/9/22
to Paul Mena, repo-d...@googlegroups.com
Le 09/05/2022 à 15:49, Paul Mena a écrit :

Mattias,

 

Thank you for the reply! We would love to upgrade our Gerrit 2.10 instance to something newer and are trying to get that into our next budget.

 

In the meantime, I’ve been able to query the Gerrit database (after taking a backup) and have noticed 1) there are no account_ids beyond 1000059, making it more baffling that the error below references the account_id 1000065, 2) the troubled account is lacking a row in the database.

 

To illustrate, here is a query from a working account (mine):

 

gerrit> select * from account_external_ids where external_id like '%pmena%';

account_id | email_address       | password | external_id

-----------+---------------------+----------+----------------------

1000058    | 'pm...@default.com' | NULL     | gerrit:pmena

1000058    | NULL                | NULL     | username:pmena

1000058    | pm...@whoi.edu      | NULL     | mailto:pm...@whoi.edu

(3 rows; 1 ms)

 

Next, a query of the affected account:

 

gerrit> select * from account_external_ids where external_id like '%redacted%';

account_id | email_address     | password | external_id

-----------+-------------------+----------+-------------------------

1000059    | NULL              | NULL     | username:redacted

1000059    | reda...@whoi.edu | NULL     | mailto:reda...@whoi.edu

(2 rows; 1 ms)

 

As you can see, the row that should contain the external_id “gerrit:redacted” is missing. Is there a way to remedy this?

Hello Paul,

Our instance at Wikimedia often had the issue or very similar and we have multiple tasks matching that error logging in our Bug tracker ( https://phabricator.wikimedia.org/search/query/sehZkGQkCCmF/#R ).

One of the oldest task has a detailed problem statement https://phabricator.wikimedia.org/T49385#489415 , albeit it lacks a described solution it exposes two potential causes:

  1. lack of a local account (the ones prefixed with "gerrit:")
  2. case mismatch between the entered login and what the database knows about

The task hints at manually inserting a missing row in account_external_ids.

Eventually that got solved by moving everything to be lower cased (the database connections, all gerrit: entries and the LDAP connection made all lower case) which was https://phabricator.wikimedia.org/T152640 .


The id 1000065 is an auto increment in the database, I think the database assign the id, keep track of the last assigned value then attempts to do the insert in a transaction which ends up rejected by the increment counter is kept. Something like that and on the task at https://phabricator.wikimedia.org/T152640#2856932 the user "addshore" with id 106 when logging it with mixed case like AddShore or Addshore ended up being rejected and generating on the backend:

Cannot assign user name "addshore" to account 4238; name already in use.
Cannot assign user name "addshore" to account 4239; name already in use.

Which sounds very similar. Then we were running Gerrit 2.12 at the time so it might be an entirely different problem.

Maybe that account 1000059 got half created due to another existing account having the same email address? Or it is half created because another account has the same username albeit with a different case (like Pmena versus pmena). It might well be the issue, we had been crippled by the mixed case until we normalized everything to lower case (db, ldap, gerrit).

Maybe you need to insert (BUT PLEASE MAKE A BACKUP FIRST):

account_id | email_address     | password | external_id

-----------+-------------------+----------+-------------------------

1000059    | reda...@whoi.edu | NULL     | gerrit:redacted


A long time ago we also had issue with usernames containing unicode https://phabricator.wikimedia.org/T37626 and went to use:

[database]

 type = mysql

 url = jdbc:mysql://<db host>/<db name>/?characterSetResults=utf8&characterEncoding=utf8&connectionCollation=utf8_unicode_ci

Which can well break a lot more things and would vary depending on your database support for unicode (old MySQL did not have support for the full unicode space).

-- 
Antoine "hashar" Musso
Release Engineering

Paul Mena

unread,
May 10, 2022, 1:15:13 PM5/10/22
to Antoine Musso, repo-d...@googlegroups.com

Antoine,

 

Thank you for the response! I tested out an insert command on a copy of the account_external_ids table and it did what I expected it to do.

 

gerrit> create table test_account_external_ids as table account_external_ids;

UPDATE 0; 166 ms

 

gerrit> insert into test_account_external_ids(account_id, email_address, external_id) values (1000059, 'reda...@default.com', 'gerrit:redacted);

UPDATE 1; 3 ms

 

gerrit> select * from test_account_external_ids where external_id like '%redacted%';

 account_id | email_address        | password | external_id

 -----------+----------------------+----------+-------------------------

 1000059    | NULL                 | NULL     | username:redacted

 1000059    | reda...@whoi.edu    | NULL     | mailto:reda...@whoi.edu

 1000059    | reda...@default.com | NULL     | gerrit:redacted

(3 rows; 1 ms)

 

I applied this change to the real table and the user was able to log in to Gerrit without errors. Thank you again!

 

Paul Mena

Senior Application Administrator

WHOI - Information Services

508-289-3539

 

From: Antoine Musso <amu...@wikimedia.org>
Sent: Monday, May 9, 2022 3:44 PM
To: Paul Mena <pm...@whoi.edu>
Cc: repo-d...@googlegroups.com
Subject: Re: unable to log in to Gerrit - "name already in use"

 

Le 09/05/2022 à 15:49, Paul Mena a écrit :

Antoine Musso

unread,
May 11, 2022, 5:38:21 AM5/11/22
to Paul Mena, repo-d...@googlegroups.com
Le 10/05/2022 à 19:15, Paul Mena a écrit :

Antoine,

Thank you for the response! I tested out an insert command on a copy of the account_external_ids table and it did what I expected it to do.

 

gerrit> create table test_account_external_ids as table account_external_ids;

UPDATE 0; 166 ms

 

gerrit> insert into test_account_external_ids(account_id, email_address, external_id) values (1000059, 'reda...@default.com', 'gerrit:redacted);

UPDATE 1; 3 ms

 

gerrit> select * from test_account_external_ids where external_id like '%redacted%';

 account_id | email_address        | password | external_id

 -----------+----------------------+----------+-------------------------

 1000059    | NULL                 | NULL     | username:redacted

 1000059    | reda...@whoi.edu    | NULL     | mailto:reda...@whoi.edu

 1000059    | reda...@default.com | NULL     | gerrit:redacted

(3 rows; 1 ms) 

I applied this change to the real table and the user was able to log in to Gerrit without errors. Thank you again!

Hello Paul,

I am very happy to see you have managed to fix that login issue!

Reply all
Reply to author
Forward
0 new messages