Skip to content

Commit

Permalink
Less scary logging of absent metadata (e.g. for WAL-E backups)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey M. Borodin committed Jun 11, 2022
1 parent b8c17b1 commit 0deb01d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions docker/pg_tests/scripts/tests/wale_compatibility_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ PGDATABASE=postgres \
PGHOST=/var/run/postgresql \
WALE_FILE_PREFIX=file://localhost/tmp \
wal-e backup-push ${PGDATA}
wal-e backup-push ${PGDATA}

pkill -9 postgres

Expand Down Expand Up @@ -98,4 +99,6 @@ diff /tmp/dump1 /tmp/dump2
rm -rf /tmp/conf_files
/tmp/scripts/drop_pg.sh

wal-g delete RETAIN 1 --confirm

echo "WAL-E compatible backup-fetch success!!!!!!"
3 changes: 1 addition & 2 deletions internal/backup_mark.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ func GetPermanentBackups(folder storage.Folder, metaFetcher GenericMetaFetcher)
for _, backupTime := range backupTimes {
meta, err := metaFetcher.Fetch(backupTime.BackupName, folder)
if err != nil {
tracelog.ErrorLogger.Printf("failed to fetch backup meta for backup %s with error %s, ignoring...",
backupTime.BackupName, err.Error())
PrintMetadataError(backupTime, err)
continue
}
if meta.IsPermanent {
Expand Down
3 changes: 1 addition & 2 deletions internal/databases/postgres/delete_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ func GetPermanentBackupsAndWals(folder storage.Folder) (map[string]bool, map[str
backup := NewBackup(folder.GetSubFolder(utility.BaseBackupPath), backupTime.BackupName)
meta, err := backup.FetchMeta()
if err != nil {
tracelog.ErrorLogger.Printf("failed to fetch backup meta for backup %s with error %s, ignoring...",
backupTime.BackupName, err.Error())
internal.PrintMetadataNotFoundError(backupTime, err)
continue
}
if meta.IsPermanent {
Expand Down
13 changes: 11 additions & 2 deletions internal/delete_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ func FindPermanentBackups(folder storage.Folder, metaFetcher GenericMetaFetcher)
meta, err := metaFetcher.Fetch(
backupTime.BackupName, folder.GetSubFolder(utility.BaseBackupPath))
if err != nil {
tracelog.ErrorLogger.Printf("failed to fetch backup meta for backup %s with error %s, ignoring...",
backupTime.BackupName, err.Error())
PrintMetadataNotFoundError(backupTime, err)
continue
}
if meta.IsPermanent {
Expand All @@ -33,6 +32,16 @@ func FindPermanentBackups(folder storage.Folder, metaFetcher GenericMetaFetcher)
return permanentBackups
}

func PrintMetadataNotFoundError(backupTime BackupTime, err error) {
if _, ok := err.(storage.ObjectNotFoundError); ok {
tracelog.InfoLogger.Printf("Backup %s lacks metadata to check if it's permanent, ignoring...",
backupTime.BackupName)
} else {
tracelog.ErrorLogger.Printf("failed to fetch backup meta for backup %s with error %s, ignoring...",
backupTime.BackupName, err.Error())
}
}

// IsPermanent is a generic function to determine if the storage object is permanent.
// It does not support permanent WALs or binlogs.
func IsPermanent(objectName string, permanentBackups map[string]bool, backupNameLength int) bool {
Expand Down

0 comments on commit 0deb01d

Please sign in to comment.