Remove metrics when cache gets closed

When plugin with persistent caches gets reloaded it fails to load with
the following exception:

  java.lang.IllegalArgumentException: A metric named cache/chroniclemap/percentage_free_space_test-cache-plugin_test_cache already exists
  ...

The problem is caused by cache related metrics that are created when
cache-chroniclemap instantiates the persistent cache implementation for
plugin that is being reloaded.

This change ensures that all cache related metrics are removed when cache is
closed.

Notes:
* This is the necessary but not sufficient step to solve #15587.
  It is enough to solve the happy path when 'Gerrit-ReloadMode: restart'.
  IOW when the old version of plugin with persistent caches gets unloaded
  before the new version is loaded.
* Description on how to reload plugin with persistent caches when
  cache-chroniclemap lib-module is installed was added to migration.md

Bug: Issue 15587
Depends-On: I06d48535702a8acd0bcb4e1315a35b3c1d1768cb
Change-Id: I03e34dd3463fad00ba8fbc174597c896a93db547
6 files changed
tree: e16ff020564eae788f69dfc1cf4c630e8445bc34
  1. src/
  2. .gitignore
  3. BUILD
  4. external_plugin_deps.bzl
  5. Jenkinsfile
  6. LICENSE
  7. README.md
README.md

Persistent cache for Gerrit, based on ChronicleMap

Non-blocking and super-fast on-disk cache libModule for Gerrit Code Review based on ChronicleMap on-disk implementation.

How to build

This libModule is built like a Gerrit in-tree plugin, using Bazelisk. See the build instructions for more details.

Setup

  • Install cache-chronicalmap module

Install the chronicle-map module into the $GERRIT_SITE/lib directory.

Add the cache-chroniclemap module to $GERRIT_SITE/etc/gerrit.config as follows:

[gerrit]
  installModule = com.googlesource.gerrit.modules.cache.chroniclemap.ChronicleMapCacheModule

For further information and supported options, refer to config documentation.

Migration from H2 caches

You can check how to migrate from H2 to chronicle-map here.