Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: engine checks for backup (#15773)

boojackcd298ee84583
diff --git a/backend/runner/taskrun/data_update_executor.go b/backend/runner/taskrun/data_update_executor.go
index c769a68014..56eb6afedd 100644
--- a/backend/runner/taskrun/data_update_executor.go
+++ b/backend/runner/taskrun/data_update_executor.go
@@ -82,46 +82,53 @@ func (exec *DataUpdateExecutor) RunOnce(ctx context.Context, driverCtx context.C
PriorBackupStart: &storepb.TaskRunLog_PriorBackupStart{},
})
- priorBackupDetail, backupErr := exec.backupData(ctx, driverCtx, statement, task.Payload, task, issueN, instance, database)
- if backupErr != nil {
- exec.store.CreateTaskRunLogS(ctx, taskRunUID, time.Now(), exec.profile.DeployID, &storepb.TaskRunLog{
- Type: storepb.TaskRunLog_PRIOR_BACKUP_END,
- PriorBackupEnd: &storepb.TaskRunLog_PriorBackupEnd{
- Error: backupErr.Error(),
- },
- })
- // Create issue comment for backup error.
- if issueN != nil {
- if _, err := exec.store.CreateIssueComment(ctx, &store.IssueCommentMessage{
- IssueUID: issueN.UID,
- Payload: &storepb.IssueCommentPayload{
- Event: &storepb.IssueCommentPayload_TaskPriorBackup_{
- TaskPriorBackup: &storepb.IssueCommentPayload_TaskPriorBackup{
- Task: common.FormatTask(issueN.Project.ResourceID, task.PipelineID, task.StageID, task.ID),
- Error: backupErr.Error(),
+ var priorBackupDetail *storepb.PriorBackupDetail
+ // Check if we should skip backup or not.
+ switch instance.Metadata.GetEngine() {
+ case storepb.Engine_MYSQL, storepb.Engine_TIDB, storepb.Engine_MSSQL, storepb.Engine_ORACLE, storepb.Engine_POSTGRES:
+ var backupErr error
+ priorBackupDetail, backupErr = exec.backupData(ctx, driverCtx, statement, task.Payload, task, issueN, instance, database)
+ if backupErr != nil {
+ exec.store.CreateTaskRunLogS(ctx, taskRunUID, time.Now(), exec.profile.DeployID, &storepb.TaskRunLog{
+ Type: storepb.TaskRunLog_PRIOR_BACKUP_END,
+ PriorBackupEnd: &storepb.TaskRunLog_PriorBackupEnd{
+ Error: backupErr.Error(),
+ },
+ })
+ // Create issue comment for backup error.
+ if issueN != nil {
+ if _, err := exec.store.CreateIssueComment(ctx, &store.IssueCommentMessage{
+ IssueUID: issueN.UID,
+ Payload: &storepb.IssueCommentPayload{
+ Event: &storepb.IssueCommentPayload_TaskPriorBackup_{
+ TaskPriorBackup: &storepb.IssueCommentPayload_TaskPriorBackup{
+ Task: common.FormatTask(issueN.Project.ResourceID, task.PipelineID, task.StageID, task.ID),
+ Error: backupErr.Error(),
+ },
},
},
- },
- }, api.SystemBotID); err != nil {
- slog.Warn("failed to create issue comment", "task", task.ID, log.BBError(err), "backup error", backupErr)
+ }, api.SystemBotID); err != nil {
+ slog.Warn("failed to create issue comment", "task", task.ID, log.BBError(err), "backup error", backupErr)
+ }
}
+ // Check if we should skip backup error and continue to run migration.
+ skip, err := exec.shouldSkipBackupError(ctx, task)
+ if err != nil {
+ return true, nil, errors.Errorf("failed to check skip backup error or not: %v", err)
+ }
+ if !skip {
+ return true, nil, backupErr
+ }
+ } else {
+ exec.store.CreateTaskRunLogS(ctx, taskRunUID, time.Now(), exec.profile.DeployID, &storepb.TaskRunLog{
+ Type: storepb.TaskRunLog_PRIOR_BACKUP_END,
+ PriorBackupEnd: &storepb.TaskRunLog_PriorBackupEnd{
+ PriorBackupDetail: priorBackupDetail,
+ },
+ })
}
- // Check if we should skip backup error and continue to run migration.
- skip, err := exec.shouldSkipBackupError(ctx, task)
- if err != nil {
- return true, nil, errors.Errorf("failed to check skip backup error or not: %v", err)
- }
- if !skip {
- return true, nil, backupErr
- }
- } else {
- exec.store.CreateTaskRunLogS(ctx, taskRunUID, time.Now(), exec.profile.DeployID, &storepb.TaskRunLog{
- Type: storepb.TaskRunLog_PRIOR_BACKUP_END,
- PriorBackupEnd: &storepb.TaskRunLog_PriorBackupEnd{
- PriorBackupDetail: priorBackupDetail,
- },
- })
}
+
terminated, result, err := runMigration(ctx, driverCtx, exec.store, exec.dbFactory, exec.stateCfg, exec.schemaSyncer, exec.profile, task, taskRunUID, db.Data, statement, task.Payload.GetSchemaVersion(), &sheetID)
if result != nil {
// Save prior backup detail to task run result.