Skip to content

feat: persist and expose SQL online fail stage and reason - #3348

Merged
Seechi-Yolo merged 2 commits into
mainfrom
sqle/feat-3037
Jul 27, 2026
Merged

feat: persist and expose SQL online fail stage and reason#3348
Seechi-Yolo merged 2 commits into
mainfrom
sqle/feat-3037

Conversation

@LordofAvernus

@LordofAvernus LordofAvernus commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

User description

关联的 issue

https://github.com/actiontech/sqle-ee/issues/3037

描述你的变更

  • Persist fail_stage/exec_result and task exec_fail_* on backup/execute/connect failures
  • Expose fail_stage/fail_reason/exec_fail_* on task SQL and task read APIs with history backup_result fallback
  • Mark subsequent not-run SQLs as not_executed; keep backup safety rules unchanged

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 新增任务与SQL失败相关字段

  • 更新API控制器和模型结构

  • 添加在线失败持久化及回退逻辑

  • 修订文档、Swagger及本地化配置


Diagram Walkthrough

flowchart LR
  A["新增任务失败字段"] --> B["更新API控制器及模型结构"]
  B --> C["添加在线失败持久化处理"]
  C --> D["更新文档与本地化配置"]
Loading

File Walkthrough

Relevant files
Enhancement
8 files
task.go
新增任务响应中失败信息字段                                                                                       
+10/-0   
task.go
添加SQL失败字段及更新查询过滤                                                                                 
+35/-4   
message_zh.go
增加“未执行”本地化提示信息                                                                                     
+1/-0     
task.go
新增任务失败字段与失败阶段常量                                                                                   
+47/-8   
online_fail_persist.go
添加在线失败落库与任务摘要逻辑                                                                                   
+136/-0 
sqled.go
更新执行流程中失败状态的保存逻辑                                                                                 
+99/-2   
workflow.go
数据源连接失败时调用失败持久化                                                                                   
+3/-0     
workflow_schedule.go
处理连接失败并更新工作流状态                                                                                     
+9/-0     
Documentation
5 files
docs.go
增加失败信息字段描述和过滤枚举项                                                                                 
+23/-1   
swagger.json
补充Swagger中执行失败相关字段                                                                             
+23/-1   
swagger.yaml
补充Swagger YAML中的失败和未执行状态字段                                                             
+15/-0   
active.en.toml
新增英文“未执行”本地化配置信息                                                                                 
+1/-0     
active.zh.toml
新增中文“未执行”本地化配置信息                                                                                 
+1/-0     

Write fail_stage/exec_result and task exec_fail_* on backup/execute/connect failures so workflow detail can show readable reasons after refresh.
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 1851aa1)

🎫 Ticket compliance analysis ✅

3037 - Fully compliant

Compliant requirements:

  • 已新增任务和 SQL 失败相关字段
  • API 控制器和模型结构均已更新
  • 持久化及回退逻辑针对在线失败场景进行了处理
⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

索引检查

在处理执行 SQL 批量错误时,通过 results.ExecErr.ErrSqlIndex 获取失败 SQL 索引后,对索引越界或异常情况做了降级处理,但逻辑略显模糊,建议增加更严格的边界检查和明确的降级策略,以确保在索引不在预期范围时不会导致错误统计或错误记录。

idx := int(results.ExecErr.ErrSqlIndex)
var failedSQL *model.ExecuteSQL
if idx >= 0 && idx < len(executeSQLs) {
	failedSQL = executeSQLs[idx]
} else if len(executeSQLs) > 0 {
	a.entry.Errorf("execSQLs ExecErr.ErrSqlIndex=%d out of range [0,%d), degrade to nearest index", idx, len(executeSQLs))
	if idx < 0 {
		failedSQL = executeSQLs[0]
	} else {
		failedSQL = executeSQLs[len(executeSQLs)-1]
	}
}
if failedSQL != nil && failedSQL.ExecStatus == model.SQLExecuteStatusTerminateSucc {
	return fmt.Errorf("sql execute err msg: %v", results.ExecErr.SqlExecErrMsg)
}
reason := results.ExecErr.SqlExecErrMsg
if persistErr := a.persistOnlineFailure(failedSQL, model.OnlineFailStageSQLExecute, reason); persistErr != nil {
	a.entry.Errorf("persist online failure after execSQLs execErr, task=%v err=%v", a.task.ID, persistErr)
}
return fmt.Errorf("sql execute err msg: %v", results.ExecErr.SqlExecErrMsg)

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

…_fail_sql_number

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 1851aa1

@Seechi-Yolo
Seechi-Yolo merged commit 2a3201e into main Jul 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants