Repository navigation
perf: skip the WAL archive destination check while archiving succeeds - #160
Conversation
|
CI is red only on the e2e suite, for a reason unrelated to this change: #154 includes the switch to the Chainguard MinIO images from #155 and makes the restore specs pass on CloudNativePG main. Merged on top of #154, this branch passes the whole e2e suite against CloudNativePG main on our fork, 8 of 8 (#154 adds one spec): run. We will rebase once #154 is merged. |
Archive ran CheckWalArchiveDestination, and with it "pgbackrest info" against the repository, before every WAL batch not already in the spool. PostgreSQL archives one segment at a time, so with the default maxParallel of 1 every segment paid for the six S3 requests of "info" on top of the three that archive-push needs. The instance sidecar now remembers the destination of the last batch that was archived successfully (Archive UID and generation, and the stanza) and skips the check while batches keep succeeding against it. A failed batch or a change to the Archive spec brings the check back, so the stanza is still created on the first archive after the sidecar starts. The restore job keeps checking before every batch. Signed-off-by: Vasiliy Fakunin <61789920+melancholictheory@users.noreply.github.com>
6bcf146 to
13d4774
Compare
|
Rebased onto |
Agalin
left a comment
There was a problem hiding this comment.
Yeah, that was one of the concerns that made the original implementation use explicit stanza creation on backup. Fix looks reasonable.
Fixes #156.
What
The instance sidecar remembers the destination of the last WAL batch it archived successfully (the Archive UID and generation, plus the stanza) and skips
CheckWalArchiveDestinationwhile batches keep succeeding against it. That check runspgbackrest infoagainst the repository, which on S3 is six requests per batch on top of the threearchive-pushneeds.A failed batch or any change to the Archive spec brings the check back. The first batch after the sidecar starts still runs it, so the stanza creation from #121 works as before. The restore job leaves
DestinationChecknil and keeps checking before every batch.How
internal/cnpgi/common/destination.goaddsDestinationCheck, which keeps the key of the last verified destination behind a mutex. A nil*DestinationCheckremembers nothing.Archiveinwal.gomoves the existing check, unchanged, intocheckDestinationand runs it only when the key is not verified. A failed batch resets the key and a successful one records it.instance/start.gogives the instance WAL service itsDestinationCheck.There is one difference in behaviour. If the stanza is deleted from the repository while archiving runs, the next
archive-pushfails once (exit 103) before the check runs again and recreates the stanza. PostgreSQL retries that segment.Testing
DestinationCheck, andgo test -race ./internal/cnpgi/...passes.bootstrap-instanceinit container. That is unrelated to this change, but CI here will show it.pgbackrest infobefore every batch #156.