Skip to content

Commit 850a6fb

Browse files
committed
ensure chunks are excluded before ts in cleanup
1 parent b62decc commit 850a6fb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pbm/backup/delete.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,14 @@ func MakeCleanupInfo(ctx context.Context, conn connect.Client, ts primitive.Time
396396
return CleanupInfo{}, errors.Wrap(err, "extract last incremental chain")
397397
}
398398

399+
beforeChunks := make([]oplog.OplogChunk, 0, len(chunks))
400+
for _, chunk := range chunks {
401+
if chunk.EndTS.Before(r.LastWriteTS) {
402+
beforeChunks = append(beforeChunks, chunk)
403+
}
404+
}
405+
chunks = beforeChunks
406+
399407
return CleanupInfo{Backups: backups, Chunks: chunks}, nil
400408
}
401409
}
@@ -408,6 +416,15 @@ func MakeCleanupInfo(ctx context.Context, conn connect.Client, ts primitive.Time
408416
}
409417
if baseIndex == -1 {
410418
// no valid base snapshot to exclude
419+
420+
beforeChunks := make([]oplog.OplogChunk, 0, len(chunks))
421+
for _, chunk := range chunks {
422+
if chunk.EndTS.Before(ts) {
423+
beforeChunks = append(beforeChunks, chunk)
424+
}
425+
}
426+
chunks = beforeChunks
427+
411428
return CleanupInfo{Backups: backups, Chunks: chunks}, nil
412429
}
413430

0 commit comments

Comments
 (0)