Repository navigation
fix(catalog): sort backups with a consistent order - #344
Open
augustoribeiro wants to merge 1 commit into
Open
augustoribeiro wants to merge 1 commit into
augustoribeiro wants to merge 1 commit into
Conversation
Less compared one backup's begin time with the other's end time, treated every backup with no end time as smaller than any other, and a backup with no begin time as equal to all of them. That is not a strict weak ordering, so once the catalog holds a backup that failed before it began, sort.Sort can leave completed backups out of order. LatestBackupInfo and FirstRecoverabilityPoint then report the wrong backups, and FindBackupInfo can restore from an old base backup instead of the latest one. Order completed backups first, then the incomplete ones, each by begin time and then by ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Augusto Ribeiro <augusto.mcc@gmail.com>
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.
fix(catalog): sort backups with a consistent order
Catalog.Lessis not a strict weak ordering:i.BeginTimeagainstj.EndTime.Once the catalog holds a backup that failed before barman wrote its begin time (
begin_time=None,status=FAILED),sort.Sortcan leave completed backups out of order. We hit this in production on a catalog with 26 entries: 7 completed, one FAILED with no begin time, and the rest orphanedSTARTEDruns.GetLastSuccessfulBackupTimereturned the end of a backup from 8 days earlier, older thanFirstRecoverabilityPoint.last_available_backup_timestampmetric froze and alerted, even though a backup had completed every day since.FindBackupInfosees the same sorted list, so a restore to "latest" would have started from that old base backup.Removing the single entry with no begin time made the output correct again.
This change orders completed backups first, then the incomplete ones, each by begin time and then by ID. The order is total, and the result no longer depends on the order barman listed the backups in. Every caller already skips incomplete backups through
isBackupDone, so moving them to the end changes no result.The new test uses the shape of the production catalog. On the current code it fails on the latest backup, the first recoverability point and
FindBackupInfo, and with input in shuffled order; with this change it passes.🤖 Generated with Claude Code