Class NotesMigration

  • Direct Known Subclasses:
    MutableNotesMigration

    public abstract class NotesMigration
    extends Object
    Current low-level settings of the NoteDb migration for changes.

    This class only describes the migration state of the Change entity group, since it is possible for a given site to be in different states of the Change NoteDb migration process while staying at the same ReviewDb schema version. It does not describe the migration state of non-Change tables; those are automatically migrated using the ReviewDb schema migration process, so the NoteDb migration state at a given ReviewDb schema cannot vary.

    In many places, core Gerrit code should not directly care about the NoteDb migration state, and should prefer high-level APIs like ApprovalsUtil that don't require callers to inspect the migration state. The implementation of those utilities does care about the state, and should query the NotesMigration for the properties of the migration, for example, where new changes should be stored.

    Core Gerrit code is mostly interested in one facet of the migration at a time (reading or writing, say), but not all combinations of return values are supported or even make sense.

    This class controls the state of the migration according to options in gerrit.config. In general, any changes to these options should only be made by adventurous administrators, who know what they're doing, on non-production data, for the purposes of testing the NoteDb implementation. Changing options quite likely requires re-running MigrateToNoteDb. For these reasons, the options remain undocumented.

    Note: Callers should not assume the values returned by NotesMigration's methods will not change in a running server.

    • Constructor Detail

      • NotesMigration

        protected NotesMigration​(com.google.gerrit.server.notedb.NotesMigration.Snapshot snapshot)
    • Method Detail

      • readChanges

        public final boolean readChanges()
        Read changes from NoteDb.

        Change data is read from NoteDb refs, but ReviewDb is still the source of truth. If the loader determines NoteDb is out of date, the change data in NoteDb will be transparently rebuilt. This means that some code paths that look read-only may in fact attempt to write.

        If true and writeChanges() = false, changes can still be read from NoteDb, but any attempts to write will generate an error.

      • rawWriteChangesSetting

        public final boolean rawWriteChangesSetting()
        Write changes to NoteDb.

        This method is awkwardly named because you should be using either commitChangeWrites() or failChangeWrites() instead.

        Updates to change data are written to NoteDb refs, but ReviewDb is still the source of truth. Change data will not be written unless the NoteDb refs are already up to date, and the write path will attempt to rebuild the change if not.

        If false, the behavior when attempting to write depends on readChanges(). If readChanges() = false, writes to NoteDb are simply ignored; if true, any attempts to write will generate an error.

      • readChangeSequence

        public final boolean readChangeSequence()
        Read sequential change ID numbers from NoteDb.

        If true, change IDs are read from refs/sequences/changes in All-Projects. If false, change IDs are read from ReviewDb's native sequences.

      • disableChangeReviewDb

        public final boolean disableChangeReviewDb()
        Disable ReviewDb access for changes.

        When set, ReviewDb operations involving the Changes table become no-ops. Lookups return no results; updates do nothing, as does opening, committing, or rolling back a transaction on the Changes table.

      • failOnLoadForTest

        public boolean failOnLoadForTest()
        Whether to fail when reading any data from NoteDb.

        Used in conjunction with readChanges() for tests.

      • commitChangeWrites

        public final boolean commitChangeWrites()
      • failChangeWrites

        public final boolean failChangeWrites()
      • setConfigValues

        public final void setConfigValues​(org.eclipse.jgit.lib.Config cfg)
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object