system-config/playbooks/roles/gerrit/templates/docker-compose.yaml.j2
Clark Boylan 5b5f94d764 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
2024-12-18 10:04:50 -08:00

57 lines
1.6 KiB
Django/Jinja

version: '2'
services:
mariadb:
image: docker.io/library/mariadb:10.11
network_mode: host
environment:
MYSQL_ROOT_PASSWORD: "{{ gerrit_reviewdb_mariadb_password }}"
MYSQL_DATABASE: "{{ gerrit_reviewdb_mariadb_dbname }}"
MYSQL_USER: "{{ gerrit_reviewdb_mariadb_username }}"
MYSQL_PASSWORD: "{{ gerrit_reviewdb_mariadb_password }}"
MARIADB_AUTO_UPGRADE: 1
volumes:
# NOTE(ianw) : mounted under /home/gerrit2 (rather than more
# usual /var/ in our configs) to keep everything together on the
# storage attached at /home/gerrit2 on the server.
- /home/gerrit2/reviewdb:/var/lib/mysql
logging:
driver: journald
options:
tag: "docker-mariadb"
gerrit:
image: {{ gerrit_container_image }}
depends_on:
- mariadb
command: ["/wait-for-it.sh", "127.0.0.1:3306", "--", "/run-gerrit.sh"]
network_mode: host
user: gerrit
stop_signal: SIGHUP
stop_grace_period: 5m
volumes:
{% for volume in gerrit_container_volumes %}
- {{ volume }}
{% endfor %}
environment:
JAVA_OPTIONS: >-
-Dlog4j2.formatMsgNoLookups=true
-Dh2.maxCompactTime=15000
{% if gerrit_heap_limit is defined %}
-Xmx{{ gerrit_heap_limit }}
{% endif %}
ulimits:
core: 0
nofile: {{ gerrit_packed_git_open_files * 2 }}
cap_add:
- SYS_PTRACE
# Utility "service" to allow us to run ad-hoc commands
shell:
image: {{ gerrit_container_image }}
restart: 'no'
command: /bin/true
network_mode: host
user: gerrit
volumes:
{% for volume in gerrit_container_volumes %}
- {{ volume }}
{% endfor %}