Support treating NoteDb as the source of truth
Handle the new enum value PrimaryStorage.NOTE_DB. When updating a change, if its state indicates NoteDb is the source of truth, we don't have to bother writing to ReviewDb, including to update the NoteDbChangeState. This means that NoteDb and ReviewDb will get out of sync, and we would need a separate migration process to copy data from NoteDb back to ReviewDb, not yet implemented. Many code changes here come from the fact that various handlers manually delete entities from ReviewDb, where the keys may now have originally been read from NoteDb. Since we now don't write new entities to ReviewDb, trying to delete non-existent keys will fail with OrmConcurrencyException. In fact the transaction would have been rolled back later in BatchUpdate, so the delete would never really take effect, but unfortunately gwtorm actually throws at the call site of delete, prior to committing the transaction. This change supports changes in in the database with PrimaryStorage == NOTE_DB, but does not yet implement a migration path. In the new acceptance tests, we just set the state manually. Change-Id: If177aa0b9666f9d14869552c661d5aa8b86ead3b
This commit is contained in:
@@ -31,6 +31,7 @@ import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.reviewdb.client.RevId;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.git.RepoRefCache;
|
||||
import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage;
|
||||
import com.google.gerrit.server.notedb.NoteDbUpdateManager.StagedResult;
|
||||
import com.google.gerrit.server.notedb.rebuild.ChangeRebuilder;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
@@ -85,7 +86,9 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
||||
Args args,
|
||||
@Assisted Change.Id changeId,
|
||||
@Assisted Account.Id author) {
|
||||
super(args, changeId, true);
|
||||
// PrimaryStorage is unknown; this should only called by
|
||||
// PatchLineCommentsUtil#draftByAuthor, which can live with this.
|
||||
super(args, changeId, null, false);
|
||||
this.change = null;
|
||||
this.author = author;
|
||||
this.rebuildResult = null;
|
||||
@@ -97,7 +100,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
||||
Account.Id author,
|
||||
boolean autoRebuild,
|
||||
NoteDbUpdateManager.Result rebuildResult) {
|
||||
super(args, change.getId(), autoRebuild);
|
||||
super(args, change.getId(), PrimaryStorage.of(change), autoRebuild);
|
||||
this.change = change;
|
||||
this.author = author;
|
||||
this.rebuildResult = rebuildResult;
|
||||
|
Reference in New Issue
Block a user