From 971415368f637262b347ba7113ff533948559ef3 Mon Sep 17 00:00:00 2001 From: Thomas-HuWei Date: Mon, 11 Nov 2024 16:21:19 +0800 Subject: [PATCH 1/5] add End to GetRestoreStateRequest log --- core/backup_server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/backup_server.go b/core/backup_server.go index ddb1122..ff210e0 100644 --- a/core/backup_server.go +++ b/core/backup_server.go @@ -264,6 +264,7 @@ func (h *Handlers) handleGetRestore(c *gin.Context) (interface{}, error) { if h.backupContext.params.HTTPCfg.SimpleResponse { resp = SimpleRestoreResponse(resp) } + log.Info("End to GetRestoreStateRequest", zap.Any("resp", resp)) c.JSON(http.StatusOK, resp) return nil, nil } From 91b8d567733bf3e613635ccaf5fd17eaad570557 Mon Sep 17 00:00:00 2001 From: Thomas-HuWei Date: Mon, 11 Nov 2024 17:32:49 +0800 Subject: [PATCH 2/5] add restore backup log --- core/backup_server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/backup_server.go b/core/backup_server.go index ff210e0..0d9c6a8 100644 --- a/core/backup_server.go +++ b/core/backup_server.go @@ -264,7 +264,12 @@ func (h *Handlers) handleGetRestore(c *gin.Context) (interface{}, error) { if h.backupContext.params.HTTPCfg.SimpleResponse { resp = SimpleRestoreResponse(resp) } - log.Info("End to GetRestoreStateRequest", zap.Any("resp", resp)) + log.Info("End to GetRestoreStateRequest", + zap.Any("code", resp.GetCode()), + zap.String("msg", resp.GetMsg()), + zap.Any("progress", resp.GetData().Progress), + zap.Any("stateCode", resp.GetData().StateCode), + ) c.JSON(http.StatusOK, resp) return nil, nil } From 6d78f11c37250b190541f99977b19636955bb16e Mon Sep 17 00:00:00 2001 From: Thomas-HuWei Date: Thu, 5 Dec 2024 14:48:45 +0800 Subject: [PATCH 3/5] fix restore not return error --- core/backup_impl_restore_backup.go | 6 ++++++ core/backup_meta_manager.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/core/backup_impl_restore_backup.go b/core/backup_impl_restore_backup.go index 50bfc31..31333eb 100644 --- a/core/backup_impl_restore_backup.go +++ b/core/backup_impl_restore_backup.go @@ -372,12 +372,18 @@ func (b *BackupContext) executeRestoreBackupTask(ctx context.Context, backupBuck job := func(ctx context.Context) error { endTask, err := b.executeRestoreCollectionTask(ctx, backupBucketName, backupPath, restoreCollectionTaskClone, id) if err != nil { + b.meta.UpdateRestoreTask(id, setRestoreStateCode(backuppb.RestoreTaskStateCode_FAIL), + setRestoreErrorMessage(endTask.ErrorMessage)) + b.meta.UpdateRestoreCollectionTask(id, endTask.Id, + setRestoreCollectionStateCode(backuppb.RestoreTaskStateCode_FAIL), + setRestoreCollectionErrorMessage(endTask.ErrorMessage)) log.Error("executeRestoreCollectionTask failed", zap.String("TargetDBName", restoreCollectionTaskClone.GetTargetDbName()), zap.String("TargetCollectionName", restoreCollectionTaskClone.GetTargetCollectionName()), zap.Error(err)) return err } + restoreCollectionTaskClone.StateCode = backuppb.RestoreTaskStateCode_SUCCESS log.Info("finish restore collection", zap.String("db_name", restoreCollectionTaskClone.GetTargetDbName()), diff --git a/core/backup_meta_manager.go b/core/backup_meta_manager.go index a2e10f2..612a088 100644 --- a/core/backup_meta_manager.go +++ b/core/backup_meta_manager.go @@ -569,3 +569,33 @@ func (meta *MetaManager) GetRestoreTask(taskID string) *backuppb.RestoreBackupTa defer meta.mu.Unlock() return meta.restoreTasks[taskID] } + +func (meta *MetaManager) UpdateRestoreCollectionTask(restoreID string, restoreCollectionId string, opts ...RestoreCollectionTaskOpt) { + meta.mu.Lock() + defer meta.mu.Unlock() + restoreBackup := meta.restoreTasks[restoreID] + tasks := restoreBackup.GetCollectionRestoreTasks() + for i := 0; i < len(tasks); i++ { + if tasks[i].Id == restoreCollectionId { + cBackup := proto.Clone(tasks[i]).(*backuppb.RestoreCollectionTask) + for _, opt := range opts { + opt(cBackup) + } + tasks[i] = cBackup + } + } +} + +type RestoreCollectionTaskOpt func(task *backuppb.RestoreCollectionTask) + +func setRestoreCollectionStateCode(stateCode backuppb.RestoreTaskStateCode) RestoreCollectionTaskOpt { + return func(task *backuppb.RestoreCollectionTask) { + task.StateCode = stateCode + } +} + +func setRestoreCollectionErrorMessage(errorMessage string) RestoreCollectionTaskOpt { + return func(task *backuppb.RestoreCollectionTask) { + task.ErrorMessage = errorMessage + } +} From bb89c327beef4ca5b5f7b15cd8665afcbc355ce4 Mon Sep 17 00:00:00 2001 From: Thomas-HuWei Date: Thu, 5 Dec 2024 15:14:29 +0800 Subject: [PATCH 4/5] backup return error --- core/backup_impl_create_backup.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/backup_impl_create_backup.go b/core/backup_impl_create_backup.go index c433fed..eb2034d 100644 --- a/core/backup_impl_create_backup.go +++ b/core/backup_impl_create_backup.go @@ -765,6 +765,8 @@ func (b *BackupContext) executeCreateBackup(ctx context.Context, request *backup if err != nil { backupInfo.StateCode = backuppb.BackupTaskStateCode_BACKUP_FAIL backupInfo.ErrorMessage = err.Error() + b.meta.UpdateBackup(backupInfo.Id, setStateCode(backuppb.BackupTaskStateCode_BACKUP_FAIL), + setErrorMessage(err.Error())) return err } log.Info("finish backup all collections", From 49baf6dc03832dbdf6ca78281a7574e8810a063b Mon Sep 17 00:00:00 2001 From: Thomas-HuWei Date: Thu, 5 Dec 2024 15:16:54 +0800 Subject: [PATCH 5/5] modify OWNERS --- OWNERS | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OWNERS b/OWNERS index 2b1bdfb..c024ec5 100644 --- a/OWNERS +++ b/OWNERS @@ -1,6 +1,8 @@ filters: "*": reviewers: - - wayblink + - huanghaoyuanhhy + - Thomas-HuWei approvers: - - wayblink \ No newline at end of file + - huanghaoyuanhhy + - Thomas-HuWei \ No newline at end of file