You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flowchart LR
A["API Controller"]
B["PrepareForTaskReExecution"]
C["Storage更新与任务查询"]
D["异步执行ReExecuteTaskSQLs"]
E["通知工作流执行结果"]
A -- "调用校验" --> B
B -- "验证任务/SQL状态" --> C
C -- "更新工作流状态" --> D
D -- "反馈结果" --> E
-workflowStatusChan := make(chan string, 1)+// 如果 updateStatus 不需要通过通道同步结果,则可以直接移除 workflowStatusChan
var lock sync.Mutex
go func() {
sqledServer := GetSqled()
task, err := sqledServer.AddTaskWaitResultWithSQLIds(string(workflow.ProjectId), strconv.Itoa(int(task.ID)), execSqlIds, ActionTypeExecute)
- { // NOTE: Update the workflow status before sending notifications to ensure that the notification content reflects the latest information.- lock.Lock()- updateStatus(s, workflow, l, workflowStatusChan)- lock.Unlock()- }+ lock.Lock()+ updateStatus(s, workflow, l, nil)+ lock.Unlock()
if err != nil || task.Status == model.TaskStatusExecuteFailed {
go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeExecuteFail)
} else {
go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeExecuteSuccess)
}
-
}()
Suggestion importance[1-10]: 7
__
Why: The suggestion points out that the workflowStatusChan is created but never consumed, which can lead to potential blocking or resource leakage; removing or properly handling it improves reliability.
+allowed := false
for _, record := range workflow.Record.InstanceRecords {
- if record.TaskId != task.ID {- continue- }-- for _, u := range strings.Split(record.ExecutionAssignees, ",") {- if u == user.GetIDStr() {- goto CheckReExecSqlIds- }+ if record.TaskId != task.ID {+ continue+ }+ for _, u := range strings.Split(record.ExecutionAssignees, ",") {+ if u == user.GetIDStr() {+ allowed = true+ break
}
}
+ if allowed {+ break+ }+}+if !allowed {
return e.New("you are not allow to execute the task")
+}-CheckReExecSqlIds:+// 校验 reExecSqlIds
Suggestion importance[1-10]: 6
__
Why: The suggestion replaces the goto statement with a flag variable to simplify the control flow, enhancing readability and maintainability without altering the core functionality.
-workflowStatusChan := make(chan string, 1)+// 如果 updateStatus 不需要通过通道同步结果,则可以直接移除 workflowStatusChan
var lock sync.Mutex
go func() {
sqledServer := GetSqled()
task, err := sqledServer.AddTaskWaitResultWithSQLIds(string(workflow.ProjectId), strconv.Itoa(int(task.ID)), execSqlIds, ActionTypeExecute)
- { // NOTE: Update the workflow status before sending notifications to ensure that the notification content reflects the latest information.- lock.Lock()- updateStatus(s, workflow, l, workflowStatusChan)- lock.Unlock()- }+ lock.Lock()+ updateStatus(s, workflow, l, nil)+ lock.Unlock()
if err != nil || task.Status == model.TaskStatusExecuteFailed {
go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeExecuteFail)
} else {
go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeExecuteSuccess)
}
-
}()
Suggestion importance[1-10]: 7
__
Why: The suggestion points out that the workflowStatusChan is created but never consumed, which can lead to potential blocking or resource leakage; removing or properly handling it improves reliability.
+allowed := false
for _, record := range workflow.Record.InstanceRecords {
- if record.TaskId != task.ID {- continue- }-- for _, u := range strings.Split(record.ExecutionAssignees, ",") {- if u == user.GetIDStr() {- goto CheckReExecSqlIds- }+ if record.TaskId != task.ID {+ continue+ }+ for _, u := range strings.Split(record.ExecutionAssignees, ",") {+ if u == user.GetIDStr() {+ allowed = true+ break
}
}
+ if allowed {+ break+ }+}+if !allowed {
return e.New("you are not allow to execute the task")
+}-CheckReExecSqlIds:+// 校验 reExecSqlIds
Suggestion importance[1-10]: 6
__
Why: The suggestion replaces the goto statement with a flag variable to simplify the control flow, enhancing readability and maintainability without altering the core functionality.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
关联的 issue
#3145
描述你的变更
上线失败SQL重新执行功能实现
确认项(pr提交后操作)
Tip
请在指定复审人之前,确认并完成以下事项,完成后✅
not_compatibleneed_update_docDescription
新增任务失败SQL重新执行入口
添加任务及工作流状态校验逻辑
修改任务执行状态判断和数据库查询接口
补充execute_sql_detail查询相关测试
Diagram Walkthrough
File Walkthrough
workflow.go
新增任务重新执行接口及校验逻辑sqle/api/controller/v1/workflow.go
task.go
更新任务模型及支持部分SQL重新执行sqle/model/task.go
workflow.go
新增工作流记录更新函数用于SQL重执行sqle/model/workflow.go
sqled.go
修改任务添加流程支持部分SQL重执行sqle/server/sqled.go
workflow.go
新增工作流重新执行任务SQL逻辑sqle/server/workflow.go
sqled_test.go
补充execute_sql_detail查询测试sqle/server/sqled_test.go