Skip to content

Commit 7b7c7b1

Browse files
committed
Fix duplicated copy bug
Signed-off-by: wayblink <[email protected]>
1 parent 8c34a47 commit 7b7c7b1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

core/backup_impl_create_backup.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ type collectionStruct struct {
130130

131131
// parse collections to backup
132132
// For backward compatibility:
133-
// 1,parse dbCollections first,
134-
// 2,if dbCollections not set, use collectionNames
133+
//
134+
// 1,parse dbCollections first,
135+
// 2,if dbCollections not set, use collectionNames
135136
func (b *BackupContext) parseBackupCollections(request *backuppb.CreateBackupRequest) ([]collectionStruct, error) {
136137
log.Debug("Request collection names",
137138
zap.Strings("request_collection_names", request.GetCollectionNames()),
@@ -493,7 +494,9 @@ func (b *BackupContext) backupCollectionExecute(ctx context.Context, levelInfo *
493494
log.Info("backupCollectionExecute", zap.Any("collectionMeta", collectionBackup.String()))
494495
var segmentBackupInfos []*backuppb.SegmentBackupInfo
495496
for _, seg := range levelInfo.segmentLevel.Infos {
496-
segmentBackupInfos = append(segmentBackupInfos, seg)
497+
if seg.CollectionId == collectionBackup.GetCollectionId() {
498+
segmentBackupInfos = append(segmentBackupInfos, seg)
499+
}
497500
}
498501
log.Info("Begin copy data",
499502
zap.String("dbName", collectionBackup.GetDbName()),
@@ -629,9 +632,10 @@ func (b *BackupContext) executeCreateBackup(ctx context.Context, request *backup
629632

630633
if !request.GetMetaOnly() {
631634
for _, collection := range toBackupCollectionInfos {
635+
collectionClone := collection
632636
log.Info("before backupCollectionExecute", zap.String("collection", collection.CollectionName))
633637
job := func(ctx context.Context) error {
634-
err := b.backupCollectionExecute(ctx, levelInfo, collection)
638+
err := b.backupCollectionExecute(ctx, levelInfo, collectionClone)
635639
return err
636640
}
637641
jobId := b.getBackupCollectionWorkerPool().SubmitWithId(job)
@@ -709,7 +713,7 @@ func (b *BackupContext) copySegments(ctx context.Context, segments []*backuppb.S
709713
zap.Int64("partition_id", segment.GetPartitionId()),
710714
zap.Int64("segment_id", segment.GetSegmentId()),
711715
zap.Int64("group_id", segment.GetGroupId()))
712-
log.Debug("copy segment")
716+
log.Info("copy segment")
713717
_, err := b.fillSegmentBackupInfo(ctx, levelInfo, segment)
714718
if err != nil {
715719
log.Error("Fail to fill segment backup info", zap.Error(err))

0 commit comments

Comments
 (0)