Remove accounts_byname cache

Instead of caching accounts by username let AccountCache#getByUsername
do:

1. Load the external ID for the username from NoteDb.
2. Lookup the account from the byId cache using the account ID of the
   external ID

By removing this cache we no longer need to do cache evictions when the
username changes.

Change-Id: I5285dbdf110e71dc7912e53eaff44be9ec9c08b0
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-08-25 13:37:28 +02:00
parent 93b74fbeaf
commit 0115124853
8 changed files with 23 additions and 67 deletions

View File

@@ -23,7 +23,6 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.Sequences;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.account.VersionedAuthorizedKeys;
import com.google.gerrit.server.account.externalids.ExternalId;
@@ -58,7 +57,6 @@ public class AccountCreator {
private final Groups groups;
private final Provider<GroupsUpdate> groupsUpdateProvider;
private final SshKeyCache sshKeyCache;
private final AccountCache accountCache;
private final ExternalIdsUpdate.Server externalIdsUpdate;
private final boolean sshEnabled;
@@ -71,7 +69,6 @@ public class AccountCreator {
Groups groups,
@ServerInitiated Provider<GroupsUpdate> groupsUpdateProvider,
SshKeyCache sshKeyCache,
AccountCache accountCache,
ExternalIdsUpdate.Server externalIdsUpdate,
@SshEnabled boolean sshEnabled) {
accounts = new HashMap<>();
@@ -82,7 +79,6 @@ public class AccountCreator {
this.groups = groups;
this.groupsUpdateProvider = groupsUpdateProvider;
this.sshKeyCache = sshKeyCache;
this.accountCache = accountCache;
this.externalIdsUpdate = externalIdsUpdate;
this.sshEnabled = sshEnabled;
}
@@ -141,10 +137,6 @@ public class AccountCreator {
sshKeyCache.evict(username);
}
if (username != null) {
accountCache.evictByUsername(username);
}
account = new TestAccount(id, username, email, fullName, sshKey, httpPass);
if (username != null) {
accounts.put(username, account);