Self-managed: allow an online AR backup once garbage collection deletes bucket objects

Problem

A self-managed operator backs up the AR database and the AR bucket separately. AR has no read-only mode, so a backup taken while AR runs can have the two copies disagree. This was raised in !3493 (comment 4075909420).

The install guide now has the operator take the backup with AR and iam-data-access stopped (downtime), which stays consistent with or without garbage collection. This issue is about allowing an online backup.

Today an online backup would stay consistent if the database is dumped first and the bucket copied after:

  • At v2.149.0 and main, nothing in production deletes objects from the bucket. storage.PgBlobStore.DeleteBlob (internal/storage/pg_blobstore.go:392) is the only path to driver.Delete for stored blobs, and it has no non-test callers. The OCI blob DELETE goes through container_blob_unlinker.go, which deletes database rows only.
  • So a bucket copy taken after the dump holds every object the dump records. Pushes in between only add unreferenced objects.

That stops holding once garbage collection deletes unreferenced objects (ADR-011, ADR-008 "Garbage collection"). A blob that GC deletes after the dump but before the bucket copy leaves a restored row with no object, so the pull fails. The only consistent backup then is with AR stopped, which means downtime for clients.

Related: #1317 (whether the closed beta reclaims storage).

Proposal

Decide how a self-managed operator takes a consistent backup once GC ships, and document it. Options:

  1. A read-only or maintenance mode that rejects writes and pauses GC while the backup runs.
  2. Pause GC only, with a config flag or a job toggle. Writes then only add objects, so dumping the database first, then the bucket, stays consistent.
  3. A GC grace period longer than the backup window, so no object referenced at dump time is deleted before the bucket copy finishes.
  4. Rely on bucket object versioning or soft delete, and document restoring objects to the dump time.

Done when

  • One option is chosen and implemented, or documented as the supported procedure.
  • docs/dev/self-managed-install.md Backup and restore documents the online backup, if one is supported.
Edited by Suleimi Ahmed