Initial implementation of global-refdb for Spanner

It builds in-tree and uses the Spanner Java client to connect with a
Cloud Spanner emulator instance. If a refs table does not exist in
the given Spanner instance, the plugin creates one.

Change-Id: I6c9cd6dd0d6afad4e77bde99dd20b22b638263b9
10 files changed
tree: b89251e626891f1f35d6b2082f3b9d2cf096da8c
  1. src/
  2. BUILD
  3. external_plugin_deps.bzl
  4. LICENSE
  5. README.md
README.md

Gerrit Cloud Spanner refdb

This plugin provides an implementation of the Gerrit global refdb backed by Cloud Spanner.

Requirements for using this plugin are:

  • Gerrit v3.6 or later
  • Cloud spanner as a provisioned instance
  • Optional, for testing: a locally hosted emulator

Typical use case

A global refdb implementation is a requirement for a Gerrit multi-master scenario in a multi-site setup to ensure refs are updated consistently across multiple Gerrit primary sites.

Refer to the Gerrit multi-site plugin for more details on the high level architecture.

Use with Cloud Spanner emulator

The in-memory Cloud Spanner emulator can be used during development. There are several limitations of the emulator that differ from the production service.

An easy way to run the emulator is to use gcloud CLI and Docker. Following the install instructions here will provide a local instance that the plugin can access. The gcloud CLI commands will be sent to the emulator instead of the production service. A test spanner instance and database will need to be created.

gcloud spanner instances create test-instance --config=emulator-config --description="Test Instance" --nodes=1

gcloud spanner databases create global-refdb --instance=test-instance

There are several limitations of the emulator which differ from the production service.

Use with simulated multi-site setup

In order to easily set up and begin testing the spanner-refdb plugin, the multi-site plugin's local environment setup can be used.

This simulates a multi-site setup using two local gerrit instances. Build the release.war to include spanner-refdb and follow the linked example setup.

Configuration options

Configuration details can be found in the spanner-refdb config documentation.