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;
|
package com.google.gerrit.reviewdb.server;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.Relation;
|
import com.google.gwtorm.server.Relation;
|
||||||
@@ -91,11 +90,6 @@ public interface ReviewDb extends Schema {
|
|||||||
|
|
||||||
int FIRST_GROUP_ID = 1;
|
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;
|
int FIRST_CHANGE_ID = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -134,12 +134,6 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
return delegate.patchComments();
|
return delegate.patchComments();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public int nextAccountGroupId() throws OrmException {
|
|
||||||
return delegate.nextAccountGroupId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public int nextChangeId() throws OrmException {
|
public int nextChangeId() throws OrmException {
|
||||||
|
|||||||
@@ -93,11 +93,15 @@ public class Sequences {
|
|||||||
new RepoSequence(
|
new RepoSequence(
|
||||||
repoManager, gitRefUpdated, allProjects, NAME_CHANGES, changeSeed, changeBatchSize);
|
repoManager, gitRefUpdated, allProjects, NAME_CHANGES, changeSeed, changeBatchSize);
|
||||||
|
|
||||||
RepoSequence.Seed groupSeed = () -> nextGroupId(db.get());
|
|
||||||
int groupBatchSize = 1;
|
int groupBatchSize = 1;
|
||||||
groupSeq =
|
groupSeq =
|
||||||
new RepoSequence(
|
new RepoSequence(
|
||||||
repoManager, gitRefUpdated, allUsers, NAME_GROUPS, groupSeed, groupBatchSize);
|
repoManager,
|
||||||
|
gitRefUpdated,
|
||||||
|
allUsers,
|
||||||
|
NAME_GROUPS,
|
||||||
|
() -> ReviewDb.FIRST_GROUP_ID,
|
||||||
|
groupBatchSize);
|
||||||
|
|
||||||
nextIdLatency =
|
nextIdLatency =
|
||||||
metrics.newTimer(
|
metrics.newTimer(
|
||||||
@@ -158,9 +162,4 @@ public class Sequences {
|
|||||||
private static int nextChangeId(ReviewDb db) throws OrmException {
|
private static int nextChangeId(ReviewDb db) throws OrmException {
|
||||||
return db.nextChangeId();
|
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
|
@Override
|
||||||
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
|
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
RepoSequence.Seed groupSeed = db::nextAccountGroupId;
|
|
||||||
RepoSequence groupSeq =
|
RepoSequence groupSeq =
|
||||||
new RepoSequence(
|
new RepoSequence(
|
||||||
repoManager,
|
repoManager,
|
||||||
GitReferenceUpdated.DISABLED,
|
GitReferenceUpdated.DISABLED,
|
||||||
allUsersName,
|
allUsersName,
|
||||||
Sequences.NAME_GROUPS,
|
Sequences.NAME_GROUPS,
|
||||||
groupSeed,
|
() -> ReviewDb.FIRST_GROUP_ID,
|
||||||
1);
|
1);
|
||||||
|
|
||||||
// consume one account ID to ensure that the group sequence is initialized in NoteDb
|
// 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();
|
throw new Disabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int nextAccountGroupId() {
|
|
||||||
throw new Disabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int nextChangeId() {
|
public int nextChangeId() {
|
||||||
throw new Disabled();
|
throw new Disabled();
|
||||||
|
|||||||
Reference in New Issue
Block a user