From 5b5f94d7649f7075912c2343cd0d23e8bd011a82 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 18 Dec 2024 08:13:54 -0800 Subject: [PATCH] Set h2.maxCompactTime to 15 seconds By default h2.maxCompactTime is set to 200 milliseconds. This means that when h2 databases are shutdown Gerrit will only spend 200 milliseconds compacting the on disk file to reduce total disk consumption. Unfortunately, this is insufficient to keep these files in check (we had one grow to 222GB and another to 61GB). Hashar suggests that we set the h2.maxCompactTime java command line option to 15000 to give h2 up to 15 seconds to compact things which is what wikimedia has done. It sounds like this has led to good disk usage improvements in their Gerrit installation. Note that this will only compact things when we restart Gerrit so we may also consider doing semi regular gerrit restarts? More info can be found in this phabricator document [0] that captures hashar's investigation, debugging, and fixing process. [0] https://phabricator.wikimedia.org/phame/post/view/300/shrinking_h2_database_files/ Change-Id: Iffb8b37e0539f7d148c47a5aad79f03e3b9a8f79 --- playbooks/roles/gerrit/templates/docker-compose.yaml.j2 | 1 + playbooks/roles/gerrit/templates/gerrit.config.j2 | 1 + 2 files changed, 2 insertions(+) diff --git a/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 b/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 index 42325295e3..ca027bed1f 100644 --- a/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 +++ b/playbooks/roles/gerrit/templates/docker-compose.yaml.j2 @@ -34,6 +34,7 @@ services: environment: JAVA_OPTIONS: >- -Dlog4j2.formatMsgNoLookups=true + -Dh2.maxCompactTime=15000 {% if gerrit_heap_limit is defined %} -Xmx{{ gerrit_heap_limit }} {% endif %} diff --git a/playbooks/roles/gerrit/templates/gerrit.config.j2 b/playbooks/roles/gerrit/templates/gerrit.config.j2 index b989115a8d..71544f5297 100644 --- a/playbooks/roles/gerrit/templates/gerrit.config.j2 +++ b/playbooks/roles/gerrit/templates/gerrit.config.j2 @@ -42,6 +42,7 @@ javaHome = /usr/lib/jvm/java-17-openjdk-amd64 javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance" javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance" + javaOptions = -Dh2.maxCompactTime=15000 [log] rotate = true compress = true