RETIRED, Gerrit as used by OpenStack
Go to file
Edwin Kempin 5be9c31001 Move account sequence to NoteDb
Accounts have been migrated to NoteDb, hence also the account sequence
should be moved to NoteDb. In NoteDb the current account sequence number
is stored as UTF-8 text in a blob pointed to by the
'refs/sequences/accounts' ref in the 'All-Users' repository. Multiple
processes share the same sequence by incrementing the counter using
normal git ref updates. To amortize the cost of these ref updates,
processes can increment the counter by a larger number and hand out
numbers from that range in memory until they run out. The size of the
account ID batch that each process retrieves at once is controlled by
the 'notedb.accounts.sequenceBatchSize' configuration parameter in
'gerrit.config'. By default the value is 1 since it's unlikely that a
process ever creates more than one account.

This follows the example of storing the change sequence in NoteDb. A
difference is that the account sequence is stored in the 'All-Users'
repository while the change sequence is stored in the 'All-Projects'
repository. Storing the account sequence in the 'All-Users' repository
makes more sense since this repository already contains all of the other
account data.

Injecting the Sequences class that provides new sequences numbers
requires request scope. There are 2 places outsite of request scope
where new account sequence numbers are required, AccountManager and
AccountCreator (only used for tests). These classes need to create a
request context to get an account sequence number. For AccountManager
the request scope is only created when a new account is created and not
when an existing account is authenticated.

Since there is an init step that creates an initial admin user we must
make the account sequence available during the init phase. For this the
class SequencesOnInit is added which can only generate account IDs, but
only depends on classes that are available during the init phase. For
this class the account ID batch size is hard-coded to 1, since init only
creates a single account and we don't want to waste account IDs when a
new Gerrit server is initialized.

This change also contains a schema migration that ensures that the
account sequence is created in NoteDb.

To support a live migration on a multi-master Gerrit installation, there
is a configuration parameter ('notedb.accounts.readSequenceFromNoteDb')
that controls whether account sequence numbers are read from NoteDb or
ReviewDb. By default the value for this parameter is `false` so account
sequence numbers are read from ReviewDb.

If account sequence numbers are read from ReviewDb the sequence numbers
in NoteDb will be kept in sync. This is achieved by writing the next
available sequence number to NoteDb whenever a sequence number from
ReviewDb is retrieved. If writing to NoteDb fails, an exception is
raised to the caller and the sequence number that was retrieved from
ReviewDb is not used. Writing to NoteDb is retried several times so that
the caller only gets an exception if writing to NoteDb fails
permanently.

For the case where two threads try to update the sequence number in
NoteDb concurrently we must make sure that the value in NoteDb is never
decreased. E.g.:

1. Thread 1 retrieves account ID 14 from ReviewDb
2. Thread 2 retrieves account ID 15 from ReviewDb
3. Thread 2 writes the next available account ID 16 to NoteDb
4. Thread 1 tries to write the next available account ID 15 to NoteDb
   but fails since Thread 2 updated the value concurrently.
5. Thread 1 finds that it doesn't need to update the account ID in
   NoteDb anymore since Thread 2 already updated the account ID to a
   higher value

This means at any point in time it is safe to switch to reading account
IDs from NoteDb. However once this switch is done it is not possible to
switch back to reading account IDs from ReviewDb, since ReviewDb will be
out of sync as soon as the first account ID was retrieved from NoteDb.

The migration on a multi-master Gerrit installation will be done with
the following steps:
1. rollout this change to all nodes:
   - account sequence numbers are read from ReviewDb
   - the sequence numbers in NoteDb are kept in sync
2. wait some time until we are sure that we don't need to roll back to a
   release that doesn't contain this change
3. run an offline migration to ensure that the account sequence number
   in NoteDb is initialized on all nodes
4. set 'notedb.accounts.readSequenceFromNoteDb' to true so that account
   sequence numbers are now read from NoteDb (this setting cannot be
   reverted since the account sequence in ReviewDb will be outdated once
   account IDs are retrieved from NoteDb)

After this is done a follow-up change can remove the handling for
'notedb.accounts.readSequenceFromNoteDb' so that account IDs are now
always retrieved from NoteDb.

Change-Id: I023d2de643ed0c15197c09fa19105cc2acb5091e
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-07-14 08:50:35 +02:00
.settings Enable new Eclipse 4.7 "unlikely-arg-type" warning 2017-06-16 23:56:20 +00:00
contrib abandon_stale.py: Adapt to removal of digest authentication 2017-04-21 14:51:59 +00:00
Documentation Move account sequence to NoteDb 2017-07-14 08:50:35 +02:00
gerrit-acceptance-framework Move account sequence to NoteDb 2017-07-14 08:50:35 +02:00
gerrit-acceptance-tests Move account sequence to NoteDb 2017-07-14 08:50:35 +02:00
gerrit-antlr Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-cache-h2 Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-common Add support for tag web links 2017-07-04 10:12:13 +09:00
gerrit-elasticsearch Add test for online index schema migration 2017-06-28 11:08:52 -04:00
gerrit-extension-api Merge "Add label data into GET /project/ REST endpoint" 2017-07-11 15:31:04 +00:00
gerrit-gpg Rework NotesMigration hierarchy and get rid of test impl 2017-07-13 10:03:17 -04:00
gerrit-gwtdebug Format all Java files with google-java-format 2017-02-07 10:04:39 +09:00
gerrit-gwtexpui Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-gwtui Add support for tag web links 2017-07-04 10:12:13 +09:00
gerrit-gwtui-common RelativeDateFormatter: Remove unnecessary @SuppressWarnings("boxing") 2017-06-29 12:24:20 +00:00
gerrit-httpd Merge branch 'stable-2.14' 2017-07-11 21:29:49 +09:00
gerrit-launcher Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-lucene Add test for online index schema migration 2017-06-28 11:08:52 -04:00
gerrit-main Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-oauth Merge branch 'stable-2.14' 2017-04-25 07:23:03 +02:00
gerrit-openid Remove more finals from method signatures 2017-06-14 09:39:19 +02:00
gerrit-patch-commonsnet Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-patch-jgit Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-pgm Move account sequence to NoteDb 2017-07-14 08:50:35 +02:00
gerrit-plugin-api NotesBranchUtil: Don't retry automatically 2017-06-21 09:07:29 -04:00
gerrit-plugin-gwtui Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-prettify Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-reviewdb Move account sequence to NoteDb 2017-07-14 08:50:35 +02:00
gerrit-server Move account sequence to NoteDb 2017-07-14 08:50:35 +02:00
gerrit-sshd Rename CapabilityControl to AccountLimits 2017-06-29 12:23:42 +00:00
gerrit-test-util Mark hunks which are present due to a rebase when diffing patch sets 2017-06-09 13:38:43 +02:00
gerrit-util-cli Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-util-http Support faster cross-domain XHR calls 2017-06-16 20:57:16 -07:00
gerrit-util-ssl Remove 'final' from method signatures across gerrit. 2017-06-14 09:18:42 +02:00
gerrit-war Rework NotesMigration hierarchy and get rid of test impl 2017-07-13 10:03:17 -04:00
lib PolyGerrit: Add support for erlang and puppet in highlight 2017-07-14 00:43:01 +00:00
plugins Pass RevWalk from BatchUpdate Context to ApprovalCopier 2017-06-30 07:07:50 -04:00
polygerrit-ui PolyGerrit: Add support for erlang and puppet in highlight 2017-07-14 00:43:01 +00:00
ReleaseNotes Remove Buck based build 2017-01-23 12:44:58 +00:00
tools Add script to generate text for release announcement email 2017-07-05 01:01:22 +00:00
website/releases Fix Diffy logo on release page by encoding the image 2015-12-29 10:36:39 -08:00
.bazelproject Build IntelliJ project with full debug info 2017-04-14 11:29:51 -04:00
.editorconfig Added continuation indent to editorconfig 2016-04-26 14:42:58 +02:00
.git-blame-ignore-revs Update git hyper-blame configuration 2017-02-17 16:35:50 +09:00
.gitignore Fix launching daemon in Eclipse on MacOS 2017-03-17 14:10:41 +09:00
.gitmodules Remove the cookbook-plugin submodule 2017-03-24 10:59:31 +09:00
.mailmap Update the .mailmap file 2017-06-27 19:22:27 +09:00
.pydevproject Update PyDev project to use Python 2.7 2014-10-02 15:16:44 +09:00
BUILD Format BUILD and WORKSPACE files with buildifier 2017-02-28 17:32:44 +09:00
COPYING Initial project setup of Gerrit 2 2008-11-14 16:59:34 -08:00
INSTALL Remove Gerrit 1.x to 2.x import tools 2009-03-27 20:20:10 -07:00
README.md Switch GitHub mirror URL to the most up-to-date 2017-04-05 09:03:59 +01:00
SUBMITTING_PATCHES Update push URL in SUBMITTING_PATCHES 2012-03-29 00:57:14 -04:00
version.bzl Release 2.14-rc1 2017-04-24 16:03:54 +02:00
WORKSPACE Upgrade Truth to 0.34 2017-07-06 13:32:57 -04:00

Gerrit Code Review

Gerrit is a code review and project management tool for Git based projects.

Build Status

Objective

Gerrit makes reviews easier by showing changes in a side-by-side display, and allowing inline comments to be added by any reviewer.

Gerrit simplifies Git based project maintainership by permitting any authorized user to submit changes to the master Git repository, rather than requiring all approved changes to be merged in by hand by the project maintainer.

Documentation

For information about how to install and use Gerrit, refer to the documentation.

Source

Our canonical Git repository is located on googlesource.com. There is a mirror of the repository on Github.

Reporting bugs

Please report bugs on the issue tracker.

Contribute

Gerrit is the work of hundreds of contributors. We appreciate your help!

Please read the contribution guidelines.

Note that we do not accept Pull Requests via the Github mirror.

Getting in contact

The IRC channel on freenode is #gerrit. An archive is available at: echelog.com.

The Developer Mailing list is repo-discuss on Google Groups.

License

Gerrit is provided under the Apache License 2.0.

Build

Install Bazel and run the following:

    git clone --recursive https://gerrit.googlesource.com/gerrit
    cd gerrit && bazel build release

Install binary packages (Deb/Rpm)

The instruction how to configure GerritForge/BinTray repositories is here

On Debian/Ubuntu run:

    apt-get update & apt-get install gerrit=<version>-<release>

NOTE: release is a counter that starts with 1 and indicates the number of packages that have been released with the same version of the software.

On CentOS/RedHat run:

    yum clean all && yum install gerrit-<version>[-<release>]

On Fedora run:

    dnf clean all && dnf install gerrit-<version>[-<release>]

Use pre-built Gerrit images on Docker

Docker images of Gerrit are available on DockerHub

To run a CentOS 7 based Gerrit image:

    docker run -p 8080:8080 gerritforge/gerrit-centos7[:version]

To run a Ubuntu 15.04 based Gerrit image:

    docker run -p 8080:8080 gerritforge/gerrit-ubuntu15.04[:version]

NOTE: release is optional. Last released package of the version is installed if the release number is omitted.