Skip to content

Commit 3ee1d9b

Browse files
authored
Merge pull request #2419 from actiontech/issue1468-fix
调整批量执行SQL的策略
2 parents 4d94fb1 + 9274d4b commit 3ee1d9b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

sqle/model/task_files.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ type FileExecStatistic struct {
116116
}
117117

118118
func (a FileExecStatistic) FileExecStatus() string {
119+
// 一旦存在执行失败的SQL,则执行失败
120+
if a.FailedCount > 0 {
121+
return SQLExecuteStatusFailed
122+
}
119123
// 手工执行后,手工执行和SQLE执行互斥,因此先判断
120124
if a.ManuallyExecutedCount > 0 {
121125
return SQLExecuteStatusManuallyExecuted
@@ -140,10 +144,7 @@ func (a FileExecStatistic) FileExecStatus() string {
140144
// 若不包含初始化的SQL,但存在正在执行的SQL,则文件状态为执行中
141145
return SQLExecuteStatusDoing
142146
}
143-
// 执行完毕后
144-
if a.FailedCount > 0 {
145-
return SQLExecuteStatusFailed
146-
}
147+
// 执行完毕后 程序执行到这里,其他所有状态数量均等于0,若存在成功的SQL,则执行成功
147148
if a.SucceededCount > 0 {
148149
return SQLExecuteStatusSucceeded
149150
}

sqle/server/sqled.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,12 @@ func (a *action) executeSqlsGroupByBatchId(sqls []*model.ExecuteSQL) error {
569569
if err := a.executeSQLBatch(sqlBatch); err != nil {
570570
return err
571571
}
572+
for _, sqlInBatch := range sqlBatch {
573+
if sqlInBatch.ExecStatus == model.SQLExecuteStatusFailed {
574+
// 一旦出现执行失败的SQL,则不再执行其他未执行的SQL
575+
return nil
576+
}
577+
}
572578
// clear sql batch
573579
sqlBatch = make([]*model.ExecuteSQL, 0)
574580
}

0 commit comments

Comments
 (0)