Page MenuHomePhabricator

Compact Gerrit H2 databases to reclaim disk
Closed, ResolvedPublic

Description

Context

@hashar explained the bloat in T411583#12074313. H2 does not auto-vacuum freed blocks. So the persistent-cache .h2.db files grow a lot. An 11G git_file_diff.h2.db compacts to about 40M. -Dh2.maxCompactTime=15000 only compacts on Gerrit shutdown, up to 15s. Gerrit 3.10.6 never compacts while running. This is the same on-disk H2 bloat that first filled the root partition, per T333143: Move Gerrit data out of root partition.

Scope note. The persistent caches are now excluded from Bacula, per T411583: Gerrit backups are growing. So compaction no longer changes the caches' backup size. Its benefit is host disk usage now. That is why T425667: Investigate Gerrit root disk usage and logging is a parent. It still helps the one H2 db that is still backed up, db/account_patch_reviews.h2.db.

Options

  1. Immediate. Works on 3.10.6. Force a longer compaction with a stop/start dance, as @hashar described in T411583#12074321:
    • raise -Dh2.maxCompactTime (for example to 180000) via Puppet or the unit
    • stop Gerrit. It compacts up to the old 15s value.
    • start Gerrit. It now has the new value.
    • stop Gerrit. It compacts up to 180s.
    • restore the value via Puppet.
    • start Gerrit.
  2. Permanent. The H2 v2 backend in Gerrit 3.12 vacuums routinely. This is blocked on the Gerrit 3.12 upgrade. The upgrade task is TBD. It was not found on Phabricator yet. Link it once filed.

Acceptance criteria

  • The .h2.db files are measurably smaller on disk after compaction.
  • Long-term, auto-vacuum is tracked via the Gerrit 3.12 upgrade.

Related

Event Timeline

ABran-WMF triaged this task as Medium priority.
ABran-WMF moved this task from Incoming to Backlog on the Collaboration-Services board.
hashar claimed this task.

This happens automatically when Gerrit is being stopped (more exactly when the H2 DB Driver is about to disconnect from the db). We had multiple controlled restart of Gerrit over the last few days and the files got shrunk:

-rw-r--r-- 1 gerrit gerrit 762M Jul  9 14:50 git_file_diff.h2.db
-rw-r--r-- 1 gerrit gerrit 767M Jul  9 14:50 gerrit_file_diff.h2.db
-rw-r--r-- 1 gerrit gerrit 774M Jul  9 14:50 conflicts.h2.db
-rw-r--r-- 1 gerrit gerrit 785M Jul  9 14:48 diff_intraline.h2.db
-rw-r--r-- 1 gerrit gerrit 832M Jul  9 14:49 change_kind.h2.db
-rw-r--r-- 1 gerrit gerrit 845M Jul  9 14:50 mergeability.h2.db
-rw-r--r-- 1 gerrit gerrit 1.9G Jul  9 14:49 diff_summary.h2.db
-rw-r--r-- 1 gerrit gerrit 2.2G Jul  9 14:49 comment_context.h2.db

This task was forked from T411583#12074321 which is that those files were too large for the backup system due to changing frequently. They are no more backed up after the paths to backup have been corrected.