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