Skip to content

Commit

Permalink
Fix 6481 - unbounded growth in BackupList from failure retries.
Browse files Browse the repository at this point in the history
Signed-off-by: James Munson <[email protected]>
  • Loading branch information
james-munson authored and PhanLe1010 committed Aug 28, 2023
1 parent 22c5190 commit 8b4c80a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/sync/rpc/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,23 @@ func (*BackupList) remove(b []*BackupInfo, index int) ([]*BackupInfo, error) {
}

// Refresh deletes all the old completed backups from the front. Old backups are the completed backups
// that are created before the number we choose to retain.
// (finished or error) that were created before the number we choose to retain.
func (b *BackupList) refresh() error {
b.Lock()
defer b.Unlock()

for state, limit := range retainBackupStateCounts {
var index, completed int
var index, count int

for index = len(b.infos) - 1; index >= 0; index-- {
if b.infos[index].backupStatus.State == state {
if completed == limit {
if count == limit {
break
}
completed++
count++
}
}
if completed == limit {
if count == limit {
// Remove all the older completed backups in the range backupList[0:index]
for ; index >= 0; index-- {
if b.infos[index].backupStatus.State == state {
Expand Down

0 comments on commit 8b4c80a

Please sign in to comment.