Use NoteDb sequence seed for groups sequence initialization
Change-Id: I49afd0f6e02ccd498f31075961a2f69c9c53e71e
This commit is contained in:
committed by
Dave Borowitz
parent
ecdea9df55
commit
bd2844f3ac
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.reviewdb.server;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.Relation;
|
||||
@@ -91,11 +90,6 @@ public interface ReviewDb extends Schema {
|
||||
|
||||
int FIRST_GROUP_ID = 1;
|
||||
|
||||
/** Next unique id for a {@link AccountGroup}. */
|
||||
@Sequence(startWith = FIRST_GROUP_ID)
|
||||
@Deprecated
|
||||
int nextAccountGroupId() throws OrmException;
|
||||
|
||||
int FIRST_CHANGE_ID = 1;
|
||||
|
||||
/**
|
||||
|
||||
@@ -134,12 +134,6 @@ public class ReviewDbWrapper implements ReviewDb {
|
||||
return delegate.patchComments();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int nextAccountGroupId() throws OrmException {
|
||||
return delegate.nextAccountGroupId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int nextChangeId() throws OrmException {
|
||||
|
||||
@@ -93,11 +93,15 @@ public class Sequences {
|
||||
new RepoSequence(
|
||||
repoManager, gitRefUpdated, allProjects, NAME_CHANGES, changeSeed, changeBatchSize);
|
||||
|
||||
RepoSequence.Seed groupSeed = () -> nextGroupId(db.get());
|
||||
int groupBatchSize = 1;
|
||||
groupSeq =
|
||||
new RepoSequence(
|
||||
repoManager, gitRefUpdated, allUsers, NAME_GROUPS, groupSeed, groupBatchSize);
|
||||
repoManager,
|
||||
gitRefUpdated,
|
||||
allUsers,
|
||||
NAME_GROUPS,
|
||||
() -> ReviewDb.FIRST_GROUP_ID,
|
||||
groupBatchSize);
|
||||
|
||||
nextIdLatency =
|
||||
metrics.newTimer(
|
||||
@@ -158,9 +162,4 @@ public class Sequences {
|
||||
private static int nextChangeId(ReviewDb db) throws OrmException {
|
||||
return db.nextChangeId();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static int nextGroupId(ReviewDb db) throws OrmException {
|
||||
return db.nextAccountGroupId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,15 +40,13 @@ public class Schema_163 extends ReviewDbSchemaVersion {
|
||||
|
||||
@Override
|
||||
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
|
||||
@SuppressWarnings("deprecation")
|
||||
RepoSequence.Seed groupSeed = db::nextAccountGroupId;
|
||||
RepoSequence groupSeq =
|
||||
new RepoSequence(
|
||||
repoManager,
|
||||
GitReferenceUpdated.DISABLED,
|
||||
allUsersName,
|
||||
Sequences.NAME_GROUPS,
|
||||
groupSeed,
|
||||
() -> ReviewDb.FIRST_GROUP_ID,
|
||||
1);
|
||||
|
||||
// consume one account ID to ensure that the group sequence is initialized in NoteDb
|
||||
|
||||
@@ -94,11 +94,6 @@ public class DisabledReviewDb implements ReviewDb {
|
||||
throw new Disabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextAccountGroupId() {
|
||||
throw new Disabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextChangeId() {
|
||||
throw new Disabled();
|
||||
|
||||
Reference in New Issue
Block a user