Page MenuHomePhabricator

Validate Gerrit backup recoverability after the fileset exclusions
Open, HighPublic

Description

Context

@jcrespo asked for this in T411583#12074470. We excluded the caches and logs. The index and db decisions are still open. We need to confirm that a restore yields a working Gerrit. We also need to confirm that nothing essential was dropped or made slow to regenerate.

This also produces a number that T257744: Decide if Gerrit's indices should get backed up needs. That task, filed by @QChris, asks whether the Lucene index should be backed up at all. The answer depends on the reindex time.

Scope

  • Restore a snapshot taken after 2026-06-30 16:00. That is after the trailing-slash fix took effect.
  • Restore gerrit-repo-data on a test host.
  • Bring up Gerrit against the restored /srv/gerrit.
  • Confirm git repos and LFS are intact.
  • Confirm Gerrit starts.
  • Confirm caches and the Lucene index regenerate on their own in an acceptable time.
  • Confirm no data loss beyond regenerable caches and index.
  • Measure the offline-reindex time for 1.3M changes. Measure the cache-rebuild time.

Acceptance criteria

  • A documented, successful restore to a working Gerrit on a test host.
  • Reindex and cache-rebuild times measured and recorded. Feed them into T257744: Decide if Gerrit's indices should get backed up.
  • Confirmation that the excluded paths (cache, logs) are not required for recovery.

Related Objects

Event Timeline

My only input is that I would delay starting this until all other fixes are in place, to save time and just test it once.

Change #1306166 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] backup: exclude lucene index from Gerrit backups

https://gerrit.wikimedia.org/r/1306166

Change #1306166 abandoned by Arnaudb:

[operations/puppet@production] backup: exclude lucene index from Gerrit backups

Reason:

https://phabricator.wikimedia.org/T430775

https://gerrit.wikimedia.org/r/1306166

The backup is being conducted while the service is actively writing to LFS object files (rarely happens), git packfiles and objects. We also have git garbage collection triggering on a weekly basis.

Thus potentially the backup could end up saving files that are being written to / are empty. Unless there is some locking mechanism by Gerrit jGit and bacula waits for the lock to be released somehow.

Maybe we would need a cold backup (aka with the service offline?)

We do have copies of git and LFS objects replicated to Gerrit replicas though and they should be identical (the files themselves are not, but the data should). Maybe the replicated data can be used as a source for offline backing up?

@hashar Thanks, but I think the hot-write concern is mostly covered.

Git never writes in place: loose objects, packfiles, refs and LFS objects are all written to a temp name and rename()d atomically. A hot backup can't capture a half-written file under its final name. Worst case is an orphan tmp_pack_*, or a .pack without its .idx, both of which git ignores. There is no lock to wait on and none needed. The GC collision also doesn't happen for the full backup. We run [gc] interval = 1 week, startTime = Sat 02:00 with [receive] autogc = false, while gerrit-repo-data uses Hourly-Tue-ReposEqiad, i.e. full on Tue 02:05 plus hourly incrementals. GC only ever overlaps incrementals.

What is real is the other thing: a multi-hour backup is crash-consistent, not point-in-time, and our jobdefaults leave accurate = no, so a restore replays the union of files in the cycle rather than the deletions. For git that is almost always harmless (duplicate loose objects plus a new packfile, which git does not care about). The one plausible loss: a loose ref captured at X, updated to Y and packed into packed-refs within the same hour. On the remedies: a cold backup means hours of downtime for our volume, so the answer there is an FS/LVM snapshot backed up out of band. Backing up from a replica doesn't fix consistency by itself (a replica writes continuously too) and replication is async and best-effort, so we'd be backing up a copy whose completeness we don't verify. It only helps if we can quiesce a dedicated replica, which is its own project.

Concretely: this is orthogonal to the fileset exclusions, since the same exposure existed before them, so I'd rather not widen the scope here. But the restore test is the cheapest way to get data on it, so I can add git fsck --full (or the jgit equivalent) on a sample of restored repos (All-Users plus a large one such as mediawiki/core) to the acceptance criteria.

I would agree with the snapshotting option- this can be implemented in pre-backup and post-backup bacula hooks to create and free the snapshots. Given incremental backups take minutes to run now, it shouldn't add a huge amount of disk resources and would ensure consistency, assuming lvm is already setup.

LVM is indeed setup, I'll file a task to track this effort so this one stays focused on the restore validation itself

Thanks for the answer!

LSobanski moved this task from Incoming to Up Next on the Collaboration-Services board.