From ef9f611b6e3a7506bc28d270aeafbf9fabcbd919 Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Thu, 14 May 2026 11:32:48 +0000 Subject: [PATCH 1/5] feat(locale): add Hive slow log i18n keys (#2865) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add 8 new i18n keys shared by CE and EE for the upcoming Hive slow log audit plan task type: - ApMetaHiveSlowLog (task type display name) - ApMetricHiveSlowLogDbUser (metric column header) - HiveSlowLogErrSysDbNotFound - HiveSlowLogErrTableNotFound - HiveSlowLogErrColumnMismatch - HiveSlowLogErrConnectFailed - HiveSlowLogErrAuthInvalid - HiveSlowLogErrUnknown The five HiveSlowLogErr* keys carry the operator-facing guidance described in design §3.5 (Hive HS2 query_history prerequisites and auth misconfig remediation). Both active.zh.toml / active.en.toml are kept aligned with the Go variable declarations in message_zh.go. These files are shared by CE (actiontech/sqle) and EE (actiontech/sqle-ee); the EE-side files are committed here so that EE feat-2865 can build before the CE-side counterpart is cherry-picked in code_review. Refs: actiontech/sqle-ee#2865 --- sqle/locale/active.en.toml | 8 ++++++++ sqle/locale/active.zh.toml | 8 ++++++++ sqle/locale/message_zh.go | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/sqle/locale/active.en.toml b/sqle/locale/active.en.toml index 29d2abfc9..d50f8266c 100644 --- a/sqle/locale/active.en.toml +++ b/sqle/locale/active.en.toml @@ -29,6 +29,7 @@ ApMetaGaussDBProcesslist = "GaussDB Processlist" ApMetaGaussDBSlowLog = "GaussDB Slow Log" ApMetaGoldenDBTopSQL = "GoldenDB TOP SQL" ApMetaHanaTopSQL = "HANA TOP SQL" +ApMetaHiveSlowLog = "Hive slow log" ApMetaHuaweiRdsMySQLSlowLog = "Huawei Cloud RDS MySQL slow log" ApMetaMDBSlowLog = "slow log(Monitor DB)" ApMetaMSSQLTopSQL = "SQL Server TOP SQL" @@ -67,6 +68,7 @@ ApMetaTBaseProcesslist = "TBase Active Session Collection" ApMetaTiDBProcesslist = "TiDB Processlist" ApMetaTopSQL = "Top SQL" ApMetricEngine = "engine" +ApMetricHiveSlowLogDbUser = "Execution user" ApMetricNameActiveTimeTotal = "Total active time (ms)" ApMetricNameActiveWaitTimeTotal = "Total active wait time (ms)" ApMetricNameBufferGetCounter = "Logical read count" @@ -185,6 +187,12 @@ ExportWorkflowName = "Task name" ExportWorkflowNumber = "Task ID" FileOrderMethodPrefixNumAsc = "Prefix number ascending" FileOrderMethodSuffixNumAsc = "Suffix number ascending" +HiveSlowLogErrAuthInvalid = "Invalid Hive datasource `auth` parameter. Allowed values: `NOSASL` / `NONE` / `LDAP` / `CUSTOM`. Please correct it on the SQLE datasource management page. Origin error: %s" +HiveSlowLogErrColumnMismatch = "Hive slow log collection SQL failed: invalid column reference. The Hive version may differ from the SQLE adapted baseline (Hive 4.2). Please share the output of `SELECT version()` with the SQLE maintainer. Origin error: %s" +HiveSlowLogErrConnectFailed = "Hive instance connection failed: HiveServer2 may have SASL/LDAP authentication enabled while the datasource `auth` is set to `NOSASL`. Please edit this Hive datasource on the SQLE datasource management page and change `auth` to `NONE` or `LDAP`. Origin error: %s" +HiveSlowLogErrSysDbNotFound = "Hive instance `sys` database does not exist. Please contact your Hive platform operator: 1) set `hive.query.history.enabled=true` in HS2 `hive-site.xml`; 2) restart HS2 so that it auto-creates the `sys.query_history` table. Origin error: %s" +HiveSlowLogErrTableNotFound = "Hive instance `sys.query_history` table does not exist. HS2 may not have query history enabled. Please verify that `hive.query.history.enabled` is true and HS2 has been restarted. Origin error: %s" +HiveSlowLogErrUnknown = "Hive slow log collection failed: %s" LicenseDurationOfRunning = "Running days" LicenseEstimatedMaturity = "Estimated maturity date" LicenseInstanceNum = "Instance count" diff --git a/sqle/locale/active.zh.toml b/sqle/locale/active.zh.toml index 3f33e028d..093a05296 100644 --- a/sqle/locale/active.zh.toml +++ b/sqle/locale/active.zh.toml @@ -29,6 +29,7 @@ ApMetaGaussDBProcesslist = "GaussDB 进程列表" ApMetaGaussDBSlowLog = "GaussDB 慢日志" ApMetaGoldenDBTopSQL = "GoldenDB TOP SQL" ApMetaHanaTopSQL = "HANA TOP SQL" +ApMetaHiveSlowLog = "Hive慢日志" ApMetaHuaweiRdsMySQLSlowLog = "华为云RDS MySQL慢日志" ApMetaMDBSlowLog = "慢日志(监控库)" ApMetaMSSQLTopSQL = "SQL Server TOP SQL" @@ -67,6 +68,7 @@ ApMetaTBaseProcesslist = "TBase 活跃会话采集" ApMetaTiDBProcesslist = "TiDB Processlist" ApMetaTopSQL = "Top SQL" ApMetricEngine = "引擎" +ApMetricHiveSlowLogDbUser = "执行用户" ApMetricNameActiveTimeTotal = "活动总时间(ms)" ApMetricNameActiveWaitTimeTotal = "活动等待总时间(ms)" ApMetricNameBufferGetCounter = "逻辑读次数" @@ -185,6 +187,12 @@ ExportWorkflowName = "工单名称" ExportWorkflowNumber = "工单编号" FileOrderMethodPrefixNumAsc = "文件名前缀数字升序" FileOrderMethodSuffixNumAsc = "文件名后缀数字升序" +HiveSlowLogErrAuthInvalid = "Hive 数据源 auth 参数值非法。允许的值:`NOSASL` / `NONE` / `LDAP` / `CUSTOM`。请在 SQLE 数据源管理页修正。原始错误:%s" +HiveSlowLogErrColumnMismatch = "Hive 慢日志采集 SQL 执行失败:字段引用错误。可能是 Hive 版本与 SQLE 适配版本(基线 Hive 4.2)存在差异;请把 `SELECT version()` 输出反馈给 SQLE 维护者。原始错误:%s" +HiveSlowLogErrConnectFailed = "Hive 实例连接失败:可能是 HiveServer2 启用了 SASL/LDAP 鉴权而数据源配置的 `auth` 为 `NOSASL`。请在 SQLE 数据源管理页编辑该 Hive 数据源,把 `auth` 改为 `NONE` 或 `LDAP`。原始错误:%s" +HiveSlowLogErrSysDbNotFound = "Hive 实例 `sys` 库不存在。请联系 Hive 平台运维:1) 在 HS2 的 hive-site.xml 中配置 `hive.query.history.enabled=true`;2) 重启 HS2 服务后,HS2 会自动创建 `sys.query_history` 表。原始错误:%s" +HiveSlowLogErrTableNotFound = "Hive 实例 `sys.query_history` 表不存在。HS2 可能未启用 query history。请检查 HS2 配置 `hive.query.history.enabled` 是否为 true,并确认 HS2 已重启。原始错误:%s" +HiveSlowLogErrUnknown = "Hive 慢日志采集失败:%s" LicenseDurationOfRunning = "已运行时长(天)" LicenseEstimatedMaturity = "预计到期时间" LicenseInstanceNum = "实例数" diff --git a/sqle/locale/message_zh.go b/sqle/locale/message_zh.go index c252eb9c6..9fb2b0bc5 100644 --- a/sqle/locale/message_zh.go +++ b/sqle/locale/message_zh.go @@ -413,6 +413,7 @@ var ( ApMetaAliRdsMySQLSlowLog = &i18n.Message{ID: "ApMetaAliRdsMySQLSlowLog", Other: "阿里RDS MySQL慢日志"} ApMetaAliRdsMySQLAuditLog = &i18n.Message{ID: "ApMetaAliRdsMySQLAuditLog", Other: "阿里RDS MySQL审计日志"} ApMetaBaiduRdsMySQLSlowLog = &i18n.Message{ID: "ApMetaBaiduRdsMySQLSlowLog", Other: "百度云RDS MySQL慢日志"} + ApMetaHiveSlowLog = &i18n.Message{ID: "ApMetaHiveSlowLog", Other: "Hive慢日志"} ApMetaHuaweiRdsMySQLSlowLog = &i18n.Message{ID: "ApMetaHuaweiRdsMySQLSlowLog", Other: "华为云RDS MySQL慢日志"} ApMetaOracleTopSQL = &i18n.Message{ID: "ApMetaOracleTopSQL", Other: "Oracle TOP SQL"} ApMetaOracleSlowLog = &i18n.Message{ID: "ApMetaOracleSlowLog", Other: "Oracle慢日志"} @@ -444,6 +445,7 @@ var ( ApMetaMSSQLTopSQL = &i18n.Message{ID: "ApMetaMSSQLTopSQL", Other: "SQL Server TOP SQL"} ApMetricQueryTimeAvg = &i18n.Message{ID: "ApMetricQueryTimeAvg", Other: "平均查询时间(s)"} ApMetricRowExaminedAvg = &i18n.Message{ID: "ApMetricRowExaminedAvg", Other: "平均扫描行数"} + ApMetricHiveSlowLogDbUser = &i18n.Message{ID: "ApMetricHiveSlowLogDbUser", Other: "执行用户"} ApMetaPerformanceCollectTips = &i18n.Message{ID: "ApMetaPerformanceCollectTips", Other: "性能指标采集将产生较大性能开销,请谨慎开启。开启后,系统将持续采集该数据源的性能数据(如QPS、连接数等),并生成性能趋势图表,体现在性能洞察页面。"} ApMetaSQLServerPerformanceCollect = &i18n.Message{ID: "ApMetaSQLServerPerformanceCollect", Other: "SQLServer性能采集"} ApMetaSQLServerPerformanceCollectTips = &i18n.Message{ID: "ApMetaSQLServerPerformanceCollectTips", Other: "定时采集SQLServer实例的连接数和QPS等性能指标"} @@ -501,6 +503,13 @@ var ( OperatorLessThan = &i18n.Message{ID: "OperatorLessThan", Other: "小于"} OperationParamAuditLevel = &i18n.Message{ID: "OperationParamAuditLevel", Other: "触发审核级别"} + + HiveSlowLogErrSysDbNotFound = &i18n.Message{ID: "HiveSlowLogErrSysDbNotFound", Other: "Hive 实例 `sys` 库不存在。请联系 Hive 平台运维:1) 在 HS2 的 hive-site.xml 中配置 `hive.query.history.enabled=true`;2) 重启 HS2 服务后,HS2 会自动创建 `sys.query_history` 表。原始错误:%s"} + HiveSlowLogErrTableNotFound = &i18n.Message{ID: "HiveSlowLogErrTableNotFound", Other: "Hive 实例 `sys.query_history` 表不存在。HS2 可能未启用 query history。请检查 HS2 配置 `hive.query.history.enabled` 是否为 true,并确认 HS2 已重启。原始错误:%s"} + HiveSlowLogErrColumnMismatch = &i18n.Message{ID: "HiveSlowLogErrColumnMismatch", Other: "Hive 慢日志采集 SQL 执行失败:字段引用错误。可能是 Hive 版本与 SQLE 适配版本(基线 Hive 4.2)存在差异;请把 `SELECT version()` 输出反馈给 SQLE 维护者。原始错误:%s"} + HiveSlowLogErrConnectFailed = &i18n.Message{ID: "HiveSlowLogErrConnectFailed", Other: "Hive 实例连接失败:可能是 HiveServer2 启用了 SASL/LDAP 鉴权而数据源配置的 `auth` 为 `NOSASL`。请在 SQLE 数据源管理页编辑该 Hive 数据源,把 `auth` 改为 `NONE` 或 `LDAP`。原始错误:%s"} + HiveSlowLogErrAuthInvalid = &i18n.Message{ID: "HiveSlowLogErrAuthInvalid", Other: "Hive 数据源 auth 参数值非法。允许的值:`NOSASL` / `NONE` / `LDAP` / `CUSTOM`。请在 SQLE 数据源管理页修正。原始错误:%s"} + HiveSlowLogErrUnknown = &i18n.Message{ID: "HiveSlowLogErrUnknown", Other: "Hive 慢日志采集失败:%s"} ) var ( From d3ead99675231f873a47e3cca2f7e98ed6cf30d0 Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Thu, 28 May 2026 02:27:28 +0000 Subject: [PATCH 2/5] fix(locale): add HiveSlowLogErrHS2ServerError i18n key (#2865) --- sqle/locale/active.en.toml | 1 + sqle/locale/active.zh.toml | 1 + sqle/locale/message_zh.go | 1 + 3 files changed, 3 insertions(+) diff --git a/sqle/locale/active.en.toml b/sqle/locale/active.en.toml index d50f8266c..d6fbdd6cd 100644 --- a/sqle/locale/active.en.toml +++ b/sqle/locale/active.en.toml @@ -190,6 +190,7 @@ FileOrderMethodSuffixNumAsc = "Suffix number ascending" HiveSlowLogErrAuthInvalid = "Invalid Hive datasource `auth` parameter. Allowed values: `NOSASL` / `NONE` / `LDAP` / `CUSTOM`. Please correct it on the SQLE datasource management page. Origin error: %s" HiveSlowLogErrColumnMismatch = "Hive slow log collection SQL failed: invalid column reference. The Hive version may differ from the SQLE adapted baseline (Hive 4.2). Please share the output of `SELECT version()` with the SQLE maintainer. Origin error: %s" HiveSlowLogErrConnectFailed = "Hive instance connection failed: HiveServer2 may have SASL/LDAP authentication enabled while the datasource `auth` is set to `NOSASL`. Please edit this Hive datasource on the SQLE datasource management page and change `auth` to `NONE` or `LDAP`. Origin error: %s" +HiveSlowLogErrHS2ServerError = "Hive HS2 server returned an error. Common causes: 1) `sys.query_history` table does not exist - please ensure `hive.query.history.enabled=true` is set in HS2 `hive-site.xml` and Restart HS2; 2) `sys` database does not exist - same as above, HS2 auto-creates it after restart; 3) Hive version differs from the SQLE adapted baseline (Hive 4.2). Please inspect HS2 server-side logs for details. Origin error: %s" HiveSlowLogErrSysDbNotFound = "Hive instance `sys` database does not exist. Please contact your Hive platform operator: 1) set `hive.query.history.enabled=true` in HS2 `hive-site.xml`; 2) restart HS2 so that it auto-creates the `sys.query_history` table. Origin error: %s" HiveSlowLogErrTableNotFound = "Hive instance `sys.query_history` table does not exist. HS2 may not have query history enabled. Please verify that `hive.query.history.enabled` is true and HS2 has been restarted. Origin error: %s" HiveSlowLogErrUnknown = "Hive slow log collection failed: %s" diff --git a/sqle/locale/active.zh.toml b/sqle/locale/active.zh.toml index 093a05296..293684349 100644 --- a/sqle/locale/active.zh.toml +++ b/sqle/locale/active.zh.toml @@ -190,6 +190,7 @@ FileOrderMethodSuffixNumAsc = "文件名后缀数字升序" HiveSlowLogErrAuthInvalid = "Hive 数据源 auth 参数值非法。允许的值:`NOSASL` / `NONE` / `LDAP` / `CUSTOM`。请在 SQLE 数据源管理页修正。原始错误:%s" HiveSlowLogErrColumnMismatch = "Hive 慢日志采集 SQL 执行失败:字段引用错误。可能是 Hive 版本与 SQLE 适配版本(基线 Hive 4.2)存在差异;请把 `SELECT version()` 输出反馈给 SQLE 维护者。原始错误:%s" HiveSlowLogErrConnectFailed = "Hive 实例连接失败:可能是 HiveServer2 启用了 SASL/LDAP 鉴权而数据源配置的 `auth` 为 `NOSASL`。请在 SQLE 数据源管理页编辑该 Hive 数据源,把 `auth` 改为 `NONE` 或 `LDAP`。原始错误:%s" +HiveSlowLogErrHS2ServerError = "Hive HS2 服务端返回错误。常见原因:1) `sys.query_history` 表不存在 —— 请确认 HS2 的 hive-site.xml 中已配置 `hive.query.history.enabled=true` 并重启 HS2 服务;2) `sys` 库不存在 —— 同上,重启 HS2 后会自动创建;3) Hive 版本与 SQLE 适配基线(Hive 4.2)字段不一致。请查阅 HS2 服务端日志获取详细错误信息。原始错误:%s" HiveSlowLogErrSysDbNotFound = "Hive 实例 `sys` 库不存在。请联系 Hive 平台运维:1) 在 HS2 的 hive-site.xml 中配置 `hive.query.history.enabled=true`;2) 重启 HS2 服务后,HS2 会自动创建 `sys.query_history` 表。原始错误:%s" HiveSlowLogErrTableNotFound = "Hive 实例 `sys.query_history` 表不存在。HS2 可能未启用 query history。请检查 HS2 配置 `hive.query.history.enabled` 是否为 true,并确认 HS2 已重启。原始错误:%s" HiveSlowLogErrUnknown = "Hive 慢日志采集失败:%s" diff --git a/sqle/locale/message_zh.go b/sqle/locale/message_zh.go index 9fb2b0bc5..cf01c181a 100644 --- a/sqle/locale/message_zh.go +++ b/sqle/locale/message_zh.go @@ -509,6 +509,7 @@ var ( HiveSlowLogErrColumnMismatch = &i18n.Message{ID: "HiveSlowLogErrColumnMismatch", Other: "Hive 慢日志采集 SQL 执行失败:字段引用错误。可能是 Hive 版本与 SQLE 适配版本(基线 Hive 4.2)存在差异;请把 `SELECT version()` 输出反馈给 SQLE 维护者。原始错误:%s"} HiveSlowLogErrConnectFailed = &i18n.Message{ID: "HiveSlowLogErrConnectFailed", Other: "Hive 实例连接失败:可能是 HiveServer2 启用了 SASL/LDAP 鉴权而数据源配置的 `auth` 为 `NOSASL`。请在 SQLE 数据源管理页编辑该 Hive 数据源,把 `auth` 改为 `NONE` 或 `LDAP`。原始错误:%s"} HiveSlowLogErrAuthInvalid = &i18n.Message{ID: "HiveSlowLogErrAuthInvalid", Other: "Hive 数据源 auth 参数值非法。允许的值:`NOSASL` / `NONE` / `LDAP` / `CUSTOM`。请在 SQLE 数据源管理页修正。原始错误:%s"} + HiveSlowLogErrHS2ServerError = &i18n.Message{ID: "HiveSlowLogErrHS2ServerError", Other: "Hive HS2 服务端返回错误。常见原因:1) `sys.query_history` 表不存在 —— 请确认 HS2 的 hive-site.xml 中已配置 `hive.query.history.enabled=true` 并重启 HS2 服务;2) `sys` 库不存在 —— 同上,重启 HS2 后会自动创建;3) Hive 版本与 SQLE 适配基线(Hive 4.2)字段不一致。请查阅 HS2 服务端日志获取详细错误信息。原始错误:%s"} HiveSlowLogErrUnknown = &i18n.Message{ID: "HiveSlowLogErrUnknown", Other: "Hive 慢日志采集失败:%s"} ) From 1abbe7b50c7388274b4590b4bbeeba13339c0e4a Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Thu, 28 May 2026 02:27:32 +0000 Subject: [PATCH 3/5] fix(locale): add HiveSlowLogErrPluginTransportClosing i18n key (#2865) --- sqle/locale/active.en.toml | 1 + sqle/locale/active.zh.toml | 1 + sqle/locale/message_zh.go | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sqle/locale/active.en.toml b/sqle/locale/active.en.toml index d6fbdd6cd..b65bb9aae 100644 --- a/sqle/locale/active.en.toml +++ b/sqle/locale/active.en.toml @@ -191,6 +191,7 @@ HiveSlowLogErrAuthInvalid = "Invalid Hive datasource `auth` parameter. Allowed v HiveSlowLogErrColumnMismatch = "Hive slow log collection SQL failed: invalid column reference. The Hive version may differ from the SQLE adapted baseline (Hive 4.2). Please share the output of `SELECT version()` with the SQLE maintainer. Origin error: %s" HiveSlowLogErrConnectFailed = "Hive instance connection failed: HiveServer2 may have SASL/LDAP authentication enabled while the datasource `auth` is set to `NOSASL`. Please edit this Hive datasource on the SQLE datasource management page and change `auth` to `NONE` or `LDAP`. Origin error: %s" HiveSlowLogErrHS2ServerError = "Hive HS2 server returned an error. Common causes: 1) `sys.query_history` table does not exist - please ensure `hive.query.history.enabled=true` is set in HS2 `hive-site.xml` and Restart HS2; 2) `sys` database does not exist - same as above, HS2 auto-creates it after restart; 3) Hive version differs from the SQLE adapted baseline (Hive 4.2). Please inspect HS2 server-side logs for details. Origin error: %s" +HiveSlowLogErrPluginTransportClosing = "Hive slow log collection failed: the sqle-hive-plugin subprocess exited abnormally (gRPC channel closed with the signal `transport is closing`). The most common trigger is an invalid Hive datasource `auth` value (gohive panics inside `innerConnect` with `panic: Unrecognized auth`, and the panic message is not propagated across the gRPC channel after the plugin process crashes). Please self-check in the following order: 1) Verify on the SQLE datasource management page that `auth` is one of the allowed values: `NOSASL` / `NONE` / `LDAP` / `CUSTOM`; 2) Confirm host / port reachability; 3) Inspect the plugin / HS2 server-side logs for the panic stack. Origin error: %s" HiveSlowLogErrSysDbNotFound = "Hive instance `sys` database does not exist. Please contact your Hive platform operator: 1) set `hive.query.history.enabled=true` in HS2 `hive-site.xml`; 2) restart HS2 so that it auto-creates the `sys.query_history` table. Origin error: %s" HiveSlowLogErrTableNotFound = "Hive instance `sys.query_history` table does not exist. HS2 may not have query history enabled. Please verify that `hive.query.history.enabled` is true and HS2 has been restarted. Origin error: %s" HiveSlowLogErrUnknown = "Hive slow log collection failed: %s" diff --git a/sqle/locale/active.zh.toml b/sqle/locale/active.zh.toml index 293684349..6a7e992d6 100644 --- a/sqle/locale/active.zh.toml +++ b/sqle/locale/active.zh.toml @@ -191,6 +191,7 @@ HiveSlowLogErrAuthInvalid = "Hive 数据源 auth 参数值非法。允许的值 HiveSlowLogErrColumnMismatch = "Hive 慢日志采集 SQL 执行失败:字段引用错误。可能是 Hive 版本与 SQLE 适配版本(基线 Hive 4.2)存在差异;请把 `SELECT version()` 输出反馈给 SQLE 维护者。原始错误:%s" HiveSlowLogErrConnectFailed = "Hive 实例连接失败:可能是 HiveServer2 启用了 SASL/LDAP 鉴权而数据源配置的 `auth` 为 `NOSASL`。请在 SQLE 数据源管理页编辑该 Hive 数据源,把 `auth` 改为 `NONE` 或 `LDAP`。原始错误:%s" HiveSlowLogErrHS2ServerError = "Hive HS2 服务端返回错误。常见原因:1) `sys.query_history` 表不存在 —— 请确认 HS2 的 hive-site.xml 中已配置 `hive.query.history.enabled=true` 并重启 HS2 服务;2) `sys` 库不存在 —— 同上,重启 HS2 后会自动创建;3) Hive 版本与 SQLE 适配基线(Hive 4.2)字段不一致。请查阅 HS2 服务端日志获取详细错误信息。原始错误:%s" +HiveSlowLogErrPluginTransportClosing = "Hive 慢日志采集失败:sqle-hive-plugin 进程异常退出(gRPC 通道关闭,错误信号 `transport is closing`)。最常见的原因是 Hive 数据源 `auth` 参数值非法(plugin 内 gohive 在 `innerConnect` 内 `panic: Unrecognized auth`,进程崩溃后 panic 信息不会跨 gRPC 传递)。请按以下顺序自查:1) 在 SQLE 数据源管理页确认 `auth` 是允许的值:`NOSASL` / `NONE` / `LDAP` / `CUSTOM`;2) 确认 host / port 可达;3) 查阅 plugin / HS2 服务端日志获取 panic 堆栈。原始错误:%s" HiveSlowLogErrSysDbNotFound = "Hive 实例 `sys` 库不存在。请联系 Hive 平台运维:1) 在 HS2 的 hive-site.xml 中配置 `hive.query.history.enabled=true`;2) 重启 HS2 服务后,HS2 会自动创建 `sys.query_history` 表。原始错误:%s" HiveSlowLogErrTableNotFound = "Hive 实例 `sys.query_history` 表不存在。HS2 可能未启用 query history。请检查 HS2 配置 `hive.query.history.enabled` 是否为 true,并确认 HS2 已重启。原始错误:%s" HiveSlowLogErrUnknown = "Hive 慢日志采集失败:%s" diff --git a/sqle/locale/message_zh.go b/sqle/locale/message_zh.go index cf01c181a..876ce9508 100644 --- a/sqle/locale/message_zh.go +++ b/sqle/locale/message_zh.go @@ -509,8 +509,9 @@ var ( HiveSlowLogErrColumnMismatch = &i18n.Message{ID: "HiveSlowLogErrColumnMismatch", Other: "Hive 慢日志采集 SQL 执行失败:字段引用错误。可能是 Hive 版本与 SQLE 适配版本(基线 Hive 4.2)存在差异;请把 `SELECT version()` 输出反馈给 SQLE 维护者。原始错误:%s"} HiveSlowLogErrConnectFailed = &i18n.Message{ID: "HiveSlowLogErrConnectFailed", Other: "Hive 实例连接失败:可能是 HiveServer2 启用了 SASL/LDAP 鉴权而数据源配置的 `auth` 为 `NOSASL`。请在 SQLE 数据源管理页编辑该 Hive 数据源,把 `auth` 改为 `NONE` 或 `LDAP`。原始错误:%s"} HiveSlowLogErrAuthInvalid = &i18n.Message{ID: "HiveSlowLogErrAuthInvalid", Other: "Hive 数据源 auth 参数值非法。允许的值:`NOSASL` / `NONE` / `LDAP` / `CUSTOM`。请在 SQLE 数据源管理页修正。原始错误:%s"} - HiveSlowLogErrHS2ServerError = &i18n.Message{ID: "HiveSlowLogErrHS2ServerError", Other: "Hive HS2 服务端返回错误。常见原因:1) `sys.query_history` 表不存在 —— 请确认 HS2 的 hive-site.xml 中已配置 `hive.query.history.enabled=true` 并重启 HS2 服务;2) `sys` 库不存在 —— 同上,重启 HS2 后会自动创建;3) Hive 版本与 SQLE 适配基线(Hive 4.2)字段不一致。请查阅 HS2 服务端日志获取详细错误信息。原始错误:%s"} - HiveSlowLogErrUnknown = &i18n.Message{ID: "HiveSlowLogErrUnknown", Other: "Hive 慢日志采集失败:%s"} + HiveSlowLogErrHS2ServerError = &i18n.Message{ID: "HiveSlowLogErrHS2ServerError", Other: "Hive HS2 服务端返回错误。常见原因:1) `sys.query_history` 表不存在 —— 请确认 HS2 的 hive-site.xml 中已配置 `hive.query.history.enabled=true` 并重启 HS2 服务;2) `sys` 库不存在 —— 同上,重启 HS2 后会自动创建;3) Hive 版本与 SQLE 适配基线(Hive 4.2)字段不一致。请查阅 HS2 服务端日志获取详细错误信息。原始错误:%s"} + HiveSlowLogErrPluginTransportClosing = &i18n.Message{ID: "HiveSlowLogErrPluginTransportClosing", Other: "Hive 慢日志采集失败:sqle-hive-plugin 进程异常退出(gRPC 通道关闭,错误信号 `transport is closing`)。最常见的原因是 Hive 数据源 `auth` 参数值非法(plugin 内 gohive 在 `innerConnect` 内 `panic: Unrecognized auth`,进程崩溃后 panic 信息不会跨 gRPC 传递)。请按以下顺序自查:1) 在 SQLE 数据源管理页确认 `auth` 是允许的值:`NOSASL` / `NONE` / `LDAP` / `CUSTOM`;2) 确认 host / port 可达;3) 查阅 plugin / HS2 服务端日志获取 panic 堆栈。原始错误:%s"} + HiveSlowLogErrUnknown = &i18n.Message{ID: "HiveSlowLogErrUnknown", Other: "Hive 慢日志采集失败:%s"} ) var ( From 2c016b37928e46cea4156c14dbcb17e3e5e7b199 Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Tue, 26 May 2026 11:43:26 +0000 Subject: [PATCH 4/5] chore(docs): regenerate swagger after rebase onto main-ee main-ee swagger.json already contained the `default_port` field on DBService-related schemas, but feat-2865 had not been regenerated after the rebase. Re-run `swag init` (driven by `make install`) to bring the swagger.json / swagger.yaml / docs.go on this branch back in sync with main-ee. No source code or behavior changes. --- sqle/docs/docs.go | 3 +++ sqle/docs/swagger.json | 3 +++ sqle/docs/swagger.yaml | 2 ++ 3 files changed, 8 insertions(+) diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index 9e990882d..b06ca4bca 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -16345,6 +16345,9 @@ var doc = `{ "db_type": { "type": "string" }, + "default_port": { + "type": "integer" + }, "params": { "type": "array", "items": { diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index bc7dc526a..cbe47c4f2 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -16329,6 +16329,9 @@ "db_type": { "type": "string" }, + "default_port": { + "type": "integer" + }, "params": { "type": "array", "items": { diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index 039a69bb2..98e524b8e 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -1809,6 +1809,8 @@ definitions: properties: db_type: type: string + default_port: + type: integer params: items: $ref: '#/definitions/v1.InstanceAdditionalParamResV1' From f1fea42cc87878a15294f8cd41830cad2c292a7d Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Wed, 27 May 2026 03:53:38 +0000 Subject: [PATCH 5/5] fix(audit_plan): guard nil AuditPlanTaskInfo in HTTP handlers + backfill missing task info on save (#2865) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GetInstanceAuditPlans / ConvertAuditPlanTypeToResByID / GetInstanceAuditPlanOverview / UpdateAuditPlanStatus 直接读 auditPlan.AuditPlanTaskInfo.LastCollectionStatus 而无 nil 守护。当 audit_plans_v2 有行而对应 audit_plan_task_infos 行缺失(或被软删除,GORM 软删 除会让 Preload 返回 nil)时,进程级 panic: panic: runtime error: invalid memory address or nil pointer dereference at sqle/api/controller/v2/instance_audit_plan.go:339 ConvertAuditPlanTypeToResByID HTTP handler 在写响应前 panic,连接被关闭,DMS 反向代理把 EOF 包装成 `400 remote sqle unreachable, could not forward: EOF` 抛给前端,影响「SQL 管控配置」列表 + 详情页。 三处补 nil 守护: - v2/instance_audit_plan.go ConvertAuditPlanTypeToResByID - v1/instance_audit_plan.go GetInstanceAuditPlanOverview - v1/instance_audit_plan.go UpdateAuditPlanStatus(写路径,缺失时按 audit_plan_id 现场建一行) 另在 model/instance_audit_plan.go BatchSaveAuditPlans 的 else 分支(更新已有计划) 补「task_info 不存在则建一行」逻辑,根上避免历史数据/手工改库后再次出现孤行 → panic 链路彻底闭合。 验证: - sqled.out 空,sqled.log 自重启后 0 行 Go runtime panic - 直连 + DMS 代理 6 条 HTTP 全部 200(含 v1 overview / v2 list / v2 detail) - UI /sqle/project/700300/sql-management-conf 列表 + 单实例详情正常加载 - 单测 TestHiveSlowLog_* / TestHiveTopSQLTaskV2_* / model + controller v1 全部 PASS Fixes actiontech/sqle-ee#2865 --- sqle/api/controller/v1/instance_audit_plan.go | 11 ++++++++++- sqle/api/controller/v2/instance_audit_plan.go | 6 +++++- sqle/model/instance_audit_plan.go | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/sqle/api/controller/v1/instance_audit_plan.go b/sqle/api/controller/v1/instance_audit_plan.go index dfaaa869e..0f4df91f7 100644 --- a/sqle/api/controller/v1/instance_audit_plan.go +++ b/sqle/api/controller/v1/instance_audit_plan.go @@ -686,6 +686,10 @@ func GetInstanceAuditPlanOverview(c echo.Context) error { } typeBase := ConvertAuditPlanTypeToRes(c.Request().Context(), v.ID, v.Type) + lastCollectionStatus := "" + if v.AuditPlanTaskInfo != nil { + lastCollectionStatus = v.AuditPlanTaskInfo.LastCollectionStatus + } resAuditPlan := InstanceAuditPlanInfo{ ID: v.ID, Type: typeBase, @@ -696,7 +700,7 @@ func GetInstanceAuditPlanOverview(c echo.Context) error { TotalSQLNums: totalSQLNums, UnsolvedSQLNums: unsolvedSQLNums, ActiveStatus: v.ActiveStatus, - LastCollectionStatus: v.AuditPlanTaskInfo.LastCollectionStatus, + LastCollectionStatus: lastCollectionStatus, } if v.AuditPlanTaskInfo != nil { resAuditPlan.LastCollectionTime = v.AuditPlanTaskInfo.LastCollectionTime @@ -866,6 +870,11 @@ func UpdateAuditPlanStatus(c echo.Context) error { auditPlan.ActiveStatus = req.Active // 重启扫描任务时,重置最后采集状态 if req.Active == model.ActiveStatusNormal { + if auditPlan.AuditPlanTaskInfo == nil { + auditPlan.AuditPlanTaskInfo = &model.AuditPlanTaskInfo{ + AuditPlanID: auditPlan.ID, + } + } auditPlan.AuditPlanTaskInfo.LastCollectionStatus = "" err = s.Save(auditPlan.AuditPlanTaskInfo) if err != nil { diff --git a/sqle/api/controller/v2/instance_audit_plan.go b/sqle/api/controller/v2/instance_audit_plan.go index 0a1fb0a62..8f07f30ae 100644 --- a/sqle/api/controller/v2/instance_audit_plan.go +++ b/sqle/api/controller/v2/instance_audit_plan.go @@ -330,13 +330,17 @@ func ConvertAuditPlanTypeToResByID(ctx context.Context, id string, token string) } for _, meta := range auditplan.Metas { if meta.Type == auditPlan.Type { + lastCollectionStatus := "" + if auditPlan.AuditPlanTaskInfo != nil { + lastCollectionStatus = auditPlan.AuditPlanTaskInfo.LastCollectionStatus + } return AuditPlanTypeResBase{ AuditPlanType: auditPlan.Type, AuditPlanTypeDesc: locale.Bundle.LocalizeMsgByCtx(ctx, meta.Desc), AuditPlanId: auditPlan.ID, Token: token, ActiveStatus: auditPlan.ActiveStatus, - LastCollectionStatus: auditPlan.AuditPlanTaskInfo.LastCollectionStatus, + LastCollectionStatus: lastCollectionStatus, }, nil } } diff --git a/sqle/model/instance_audit_plan.go b/sqle/model/instance_audit_plan.go index 8ea7c2e45..158bf99c5 100644 --- a/sqle/model/instance_audit_plan.go +++ b/sqle/model/instance_audit_plan.go @@ -534,6 +534,22 @@ func (s *Storage) BatchSaveAuditPlans(auditPlans []*AuditPlanV2) error { if err := txDB.Save(auditPlan).Error; err != nil { return err } + // 更新已存在的扫描任务时,兜底补齐缺失的 audit_plan_task_infos 行, + // 避免历史数据/手工修改造成 Preload 后 AuditPlanTaskInfo == nil 引发空指针。 + var taskInfoCount int64 + if err := txDB.Model(&AuditPlanTaskInfo{}). + Where("audit_plan_id = ?", auditPlan.ID). + Count(&taskInfoCount).Error; err != nil { + return err + } + if taskInfoCount == 0 { + apTaskInfo := &AuditPlanTaskInfo{ + AuditPlanID: auditPlan.ID, + } + if err := txDB.Save(apTaskInfo).Error; err != nil { + return err + } + } } } return nil