Store NoteDb migration state inside Change
Since a ReviewDb write might succeed but its corresponding NoteDb write might fail, we would like to be able to detect and fix up such problems after the fact. The most reliable way to do so is to store, somewhere, the complete set of ref state across the change meta repo and All-Users for a given Change entity. This effectively needs to be in Change, or at least in ReviewDb, so that we can write it in the same transaction that stores the rest of the Change mutation. Split up NoteDbUpdateManager into two phases, "stage" and "execute". Stage the change before committing the ReviewDb transaction, and use the results of staging to update the noteDbState field in Change. The state is abstracted as an immutable data type NoteDbChangeState, and NoteDbUpdateManager computes a "Delta" over the type. This abstraction helps with compile-time safety and testability. However, for simplicity in the Change record, we just serialize the results into a simple, parsimonious string. Change-Id: I2cccda1ccb54062aa1e80ecc82994614ef6d9598
This commit is contained in:
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
/** A version of the database schema. */
|
||||
public abstract class SchemaVersion {
|
||||
/** The current schema version. */
|
||||
public static final Class<Schema_120> C = Schema_120.class;
|
||||
public static final Class<Schema_121> C = Schema_121.class;
|
||||
|
||||
public static int getBinaryVersion() {
|
||||
return guessVersion(C);
|
||||
|
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public class Schema_121 extends SchemaVersion {
|
||||
@Inject
|
||||
Schema_121(Provider<Schema_120> prior) {
|
||||
super(prior);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user