From 52143599b05435cda4fac8266ef0143e19db8d1e Mon Sep 17 00:00:00 2001 From: wayblink Date: Mon, 11 Dec 2023 21:22:03 +0800 Subject: [PATCH] fix MinioChunkManager.Exist a exist path return false (#257) Signed-off-by: wayblink --- core/backup_impl_restore_backup.go | 6 +++++- core/storage/minio_chunk_manager.go | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/backup_impl_restore_backup.go b/core/backup_impl_restore_backup.go index 3cda8f9..f8f8865 100644 --- a/core/backup_impl_restore_backup.go +++ b/core/backup_impl_restore_backup.go @@ -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), @@ -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 } diff --git a/core/storage/minio_chunk_manager.go b/core/storage/minio_chunk_manager.go index 7525682..dad68a8 100644 --- a/core/storage/minio_chunk_manager.go +++ b/core/storage/minio_chunk_manager.go @@ -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.