fix: archive WAL file once, not twice#77
Merged
mnencia merged 2 commits intocloudnative-pg:mainfrom Feb 26, 2025
Merged
Conversation
131962f to
67e6221
Compare
bc59cbb to
6a2fc48
Compare
This commit fixes an issue in the `shouldSkipWal` method of the
`GatherReadyWALFilesConfig` struct, where the current WAL file to upload
is not skipped from the gathered "ready" WAL list.
We noticed the issue because the WAL archive GCP service account doesn't
have permission to delete objects in our object storage.
You can see in the logs that the WAL archive attempts to upload the same
WAL file twice, but with different paths:
```
{"level":"info","ts":"2025-02-13T20:40:32.321415133Z","logger":"wal-archive","msg":"Executing barman-cloud-wal-archive","logging_pod":"backup-test-1","walName":"/var/lib/postgresql/data/pgdata/pg_wal/00000001000000040000001D","options":["--snappy","--cloud-provider","google-cloud-storage","gs://my-backup-storage","backup-test","/var/lib/postgresql/data/pgdata/pg_wal/00000001000000040000001D"]}
{"level":"info","ts":"2025-02-13T20:40:32.321448373Z","logger":"wal-archive","msg":"Executing barman-cloud-wal-archive","logging_pod":"backup-test-1","walName":"pg_wal/00000001000000040000001D","options":["--snappy","--cloud-provider","google-cloud-storage","gs://my-backup-storage","backup-test","pg_wal/00000001000000040000001D"]}
{"level":"info","ts":"2025-02-13T20:40:33.046761842Z","logger":"wal-archive","msg":"Archived WAL file","logging_pod":"backup-test-1","walName":"pg_wal/00000001000000040000001D","startTime":"2025-02-13T20:40:32.321422342Z","endTime":"2025-02-13T20:40:33.046732582Z","elapsedWalTime":0.725310229}
{"level":"error","ts":"2025-02-13T20:40:33.052585332Z","logger":"wal-archive","msg":"Error invoking barman-cloud-wal-archive","logging_pod":"backup-test-1","walName":"/var/lib/postgresql/data/pgdata/pg_wal/00000001000000040000001D","options":["--snappy","--cloud-provider","google-cloud-storage","gs://my-backup-storage","backup-test","/var/lib/postgresql/data/pgdata/pg_wal/00000001000000040000001D"],"exitCode":-1,"error":"exit status 4","stacktrace":"github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\tpkg/mod/github.com/cloudnative-pg/machinery@v0.0.0-20241219102532-2807bc88310d/pkg/log/log.go:125\ngithub.com/cloudnative-pg/barman-cloud/pkg/walarchive.(*BarmanArchiver).Archive\n\tpkg/mod/github.com/cloudnative-pg/barman-cloud@v0.0.0-20241218093921-134c7de4954a/pkg/walarchive/cmd.go:83\ngithub.com/cloudnative-pg/barman-cloud/pkg/walarchive.(*BarmanArchiver).ArchiveList.func1\n\tpkg/mod/github.com/cloudnative-pg/barman-cloud@v0.0.0-20241218093921-134c7de4954a/pkg/walarchive/cmd.go:115"}
{"level":"info","ts":"2025-02-13T20:40:33.052700252Z","logger":"wal-archive","msg":"Failed archiving WAL: PostgreSQL will retry","logging_pod":"backup-test-1","walName":"/var/lib/postgresql/data/pgdata/pg_wal/00000001000000040000001D","startTime":"2025-02-13T20:40:32.321394422Z","endTime":"2025-02-13T20:40:33.052693952Z","elapsedWalTime":0.7312995,"error":"unexpected failure invoking barman-cloud-wal-archive: exit status 4"}
{"level":"info","ts":"2025-02-13T20:40:33.052745862Z","logger":"wal-archive","msg":"Completed archive command (parallel)","logging_pod":"backup-test-1","walsCount":2,"startTime":"2025-02-13T20:40:32.230839745Z","uploadStartTime":"2025-02-13T20:40:32.321364142Z","uploadTotalTime":0.73136885,"totalTime":0.821893557}
```
Feel free to update the code if you think the ".ready" concatenation
should be placed elsewhere.
Signed-off-by: Antoine Rouaze <arouaze@mirakl.com>
Signed-off-by: Antoine Rouaze <antoine.rouaze@gmail.com>
6a2fc48 to
b317e78
Compare
gbartolini
approved these changes
Feb 26, 2025
mnencia
approved these changes
Feb 26, 2025
armru
approved these changes
Feb 26, 2025
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.
This commit fixes an issue in the
shouldSkipWalmethod of theGatherReadyWALFilesConfigstruct, where the current WAL file to upload is not skipped from the gathered "ready" WAL list.We noticed the issue because the WAL archive GCP service account doesn't have permission to delete objects in our object storage.
You can see in the logs that the WAL archive attempts to upload the same WAL file twice, but with different paths:
Feel free to update the code if you think the ".ready" concatenation should be placed elsewhere.