perf: skip the WAL archive destination check while archiving succeeds - #160
Open
melancholictheory wants to merge 1 commit into
Open
melancholictheory wants to merge 1 commit into
melancholictheory wants to merge 1 commit into
Conversation
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>
Contributor
Author
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.