Skip to content

Commit

Permalink
fix MinioChunkManager.Exist a exist path return false (#257)
Browse files Browse the repository at this point in the history
Signed-off-by: wayblink <anyang.wang@zilliz.com>
  • Loading branch information
wayblink authored Dec 11, 2023
1 parent 1bda6a6 commit 5214359
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion core/backup_impl_restore_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ func collectGroupIdsFromSegments(segments []*backuppb.SegmentBackupInfo) []int64
}

func (b *BackupContext) executeBulkInsert(ctx context.Context, db, coll string, partition string, files []string, endTime int64) error {
log.Debug("execute bulk insert",
log.Info("execute bulk insert",
zap.String("db", db),
zap.String("collection", coll),
zap.String("partition", partition),
Expand Down Expand Up @@ -712,6 +712,10 @@ func (b *BackupContext) getBackupPartitionPaths(ctx context.Context, bucketName
log.Warn("check binlog exist fail", zap.Error(err))
return []string{}, err
}
log.Debug("check delta log exist",
zap.Int64("partitionID", partition.PartitionId),
zap.String("deltaPath", deltaPath),
zap.Bool("exist", exist))
if !exist {
return []string{insertPath, ""}, nil
}
Expand Down
13 changes: 11 additions & 2 deletions core/storage/minio_chunk_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,25 @@ func (mcm *MinioChunkManager) MultiWrite(ctx context.Context, bucketName string,

// Exist checks whether chunk is saved to minio storage.
func (mcm *MinioChunkManager) Exist(ctx context.Context, bucketName string, filePath string) (bool, error) {
_, err := mcm.Client.StatObject(ctx, bucketName, filePath, minio.StatObjectOptions{})
//_, err := mcm.Client.StatObject(ctx, bucketName, filePath, minio.StatObjectOptions{})
paths, _, err := mcm.ListWithPrefix(ctx, bucketName, filePath, false)
if err != nil {
errResponse := minio.ToErrorResponse(err)
log.Warn("MinioChunkManager Exist errResponse",
zap.String("bucket", bucketName),
zap.String("filePath", filePath),
zap.Any("errResponse", errResponse),
)
if errResponse.Code == "NoSuchKey" {
return false, nil
}
log.Warn("failed to stat object", zap.String("path", filePath), zap.Error(err))
return false, err
}
return true, nil
if len(paths) > 0 {
return true, nil
}
return false, nil
}

// Read reads the minio storage data if exists.
Expand Down

0 comments on commit 5214359

Please sign in to comment.