Skip to content

[Bug]: statement_info ETL rejects internal reports exceeding ordinary TEXT capacity #29797

Closed

Description

@LeftHandCold

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

83d82b8

Other Environment Information

  • Observed during TKE Main Weekly run 37874777871, namespace mo-main-family-37874777871-1.
  • Topology: 1 TP CN + 2 AP CN; each CN has a 14-core CPU limit and 55 GiB memory limit.
  • MO image revision and registry digest verified by the run's image receipt.
  • Image digest: sha256:e4f01e8f3596bd4fb2e82b417cb62d28e5c38d1b6282b8df9f1706dbf6651783.
  • Example ETL worker: nightly-regression-dis-ap-cn-d7t5q.
  • This is MO's internal SQL-report ingestion into system.statement_info, not GitHub Actions artifact upload.

Actual Behavior

MO-generated statement-report files fail internal ingestion with error 1406 because a TEXT value exceeds the ordinary TEXT capacity:

Error 1406 (22001): Can't cast column from TEXT type to TEXT type
because of one or more values in that column.
Src length 127255 is larger than Dest length 65535

Bounded Loki queries independently confirmed these examples on 2026-10-09:

UTC time Observed event
08:50:11.314679 Assignment cast rejects a 127,255-byte TEXT value.
08:50:11.346203 ETL merge logs failed do write for a statement_info/*.csv file, with the same 1406 error.
08:50:21.347346 failed to upload file to MO, explicitly table=system.statement_info, for that same file and error.
08:50:32.451253 A different report file fails with source length 172,077 bytes.
08:50:43.641677 A different report file fails with source length 286,369 bytes.
08:51:17.155588 A different report file fails with source length 307,317 bytes.
09:51:47.653595 Internal ingestion is still encountering a report exceeding the limit: 78,786 bytes.

The corresponding first example is approximately 16:50:11-16:50:21 Asia/Shanghai. The final example is 17:51:47 Asia/Shanghai. These are bounded samples, not a count of all affected files or a claim that one file was retried continuously for an hour.

This prevents affected report batches from becoming available in system.statement_info. The failed file is not deleted by the ordinary upload path and remains eligible for subsequent merge attempts.

Expected Behavior

The internal statement-report producer, export format, and destination schema must agree on supported value sizes. Valid MO-generated diagnostic reports must not permanently fail ingestion under the default internal schema.

Enforcing SQL TEXT byte limits is correct for ordinary user tables; the internal telemetry integration must accommodate that contract rather than rely on oversized TEXT assignments being accepted.

Steps to Reproduce

Observed production-equivalent path:

  1. Use a main build containing [Compatibility]: enforce BLOB/TEXT family byte limits #29121 with the standard system.statement_info schema and internal report/ETL ingestion enabled.
  2. Execute workload producing statement reports with at least one ordinary TEXT field above 65,535 bytes.
  3. Observe report CSV generation followed by ETL merge / LOAD DATA INLINE ... INTO TABLE system.statement_info.
  4. The assignment cast rejects the oversized value with 1406; failed do write and failed to upload file to MO are logged.

The real workload above demonstrates the failure. The incident CSV has not been downloaded or parsed, so an exact minimal SQL reproducer and the offending field name are not yet established. It would be misleading to assert that the specific field is definitely exec_plan.

For a deterministic follow-up test, serialize a complete StatementInfo row containing a valid execution-plan JSON larger than 65,535 bytes through the actual exporter and bulkInsert path, then verify ingestion and file lifecycle. That test is suggested, not claimed to have been run here.

Additional information

Confirmed code-level capacity mismatch

  1. Internal schema: statement, statement_tag, statement_fingerprint, error, exec_plan, stats, and sql_source_type use table.TextColumn or table.TextDefaultColumn.
  2. Schema SQL generation: this column kind generates ordinary TEXT, not MEDIUMTEXT/LONGTEXT.
  3. Statement serialization: FillRow forwards fields into the export row. In particular, ExecPlan2Json marshals and returns execution-plan JSON without a 65,535-byte bound; FillRow forwards it into exec_plan without a matching size guard. Error text is likewise forwarded without this cap. The regular statement text has its own size handling, so not every field is unbounded.
  4. Internal SQL upload: bulkInsert serializes records as CSV and executes LOAD DATA INLINE into the destination table.
  5. TEXT assignment enforcement: strToStr applies the declared TEXT byte capacity to assignments. Above-capacity values are rejected in strict mode. Legacy width-zero TEXT is also interpreted as ordinary TEXT capacity by stringFamilyByteWidth.
  6. Failure/file lifecycle: Flush failure returns before source-file deletion. The outer loop waits 10 seconds, logs the failed upload, and continues to other files. Retained files can be selected again by a later merge run. This is not an immediate tight infinite retry of the same file.

The capacity-contract defect is established by the schema/producer/consumer code and the actual internal LOAD failures. Identifying the particular oversized field in each incident file remains a separate evidence gap.

Relationship to #29121 and current main

  • [Compatibility]: enforce BLOB/TEXT family byte limits #29121, merge commit f42330b618f05d117bcaadf9a3fa01f874bd3cc3, introduced family byte-capacity enforcement at assignment boundaries, including LOAD. Before that change the generic ordinary-TEXT cast path did not enforce this bound; the internal schema/producer contract was not aligned as part of that change.
  • This is an internal-observability integration defect exposed by stricter capacity enforcement, not evidence that the general TEXT compatibility fix should be reverted.
  • The same schema, serialization, internal upload, and failure/file-lifecycle code remains in source-reviewed main@d2a0055ebe1a0b2423368e046c1812c18f6face8. No matching statement-info widening/migration or producer-size fix was found in that source review. Latest main has not been runtime-retested here.
  • No claim is made here about 4.2: it needs its own exact-version/ancestry and runtime check.

Impact and boundaries

  • Missing/delayed statement reports in SQL observability; a rejected batch can also delay other valid reports in that batch.
  • Retained ETL files and repeated attempts are potential backlog/retry-work amplification; total backlog size and resource cost were not measured in this investigation.
  • This is not evidence of user-table corruption, a broken Q15 plan, or failed GitHub artifact transport.
  • Whether any particular routing probe was absent because of this defect has not been established.
  • Avoid resolving this by silent blind truncation of JSON, globally weakening SQL-mode checks, or indiscriminately discarding report files. A fix should define a consistent bounded reporting/schema contract and consider existing-cluster upgrade compatibility.

Related issues and evidence

Activity

  1. added
    kind/bug
    on Oct 9, 2026
  2. added a commit that references this issue on Oct 10, 2026
    62827a1
  3. Ariznawlll commented on Oct 12, 2026

    @Ariznawlll
    Collaborator

    测试版本

    MatrixOne main@02a2823c2007d5e4fb4ada148e93743df337551a(2026-10-12 取得的 main HEAD;已包含 #29812)。本次在 macOS arm64 本地真实 SQL 嵌入式集群和 Go 定向测试执行;原始 TKE 1 TP + 2 AP CN 周回归未重跑。

    原问题验证

    原问题是内部 system.statement_info 报告中的超长 TEXT 值导致 LOAD DATA INLINE 报 1406,进而影响整批报告入库。当前 main 对诊断文本作 UTF-8 安全、以字节为单位的 65,535 上限处理;超长 exec_plan 改为合法 JSON 摘要,保留截断标识和原始长度。历史遗留 CSV 在内部导入边界也作归一化。

    Happy Path 覆盖

    • 使用真实 SQL 写入路径向 system.statement_info 插入当前格式与历史格式两行,均成功查询;逐行核对 statement/error/exec_plan/stats/rows_read/bytes_scan,普通指标未丢失。
    • 小于及等于 65,535 字节的正常文本保持原值;普通 TEXT 控制行可以正常写入。
    • 对原问题相关的大于上限的多字节文本、65536 字节的执行计划和转义字符组成的历史 error,均成功落库;文本不超过 65,535 字节且 UTF-8 合法,计划摘要为可解析 JSON,并带有 truncated=true 与 original_bytes。

    Unhappy Path 覆盖

    • 分别覆盖 65,534 / 65,535 / 65,536 字节边界、多字节字符、非法 UTF-8、反复归一化不重复截断、混合正常/超长批次。
    • system.statement_info 的历史超长字段可以归一化;其他数据库中同名表不被误处理。模糊/不匹配的表布局明确返回错误。
    • 普通用户表严格模式 TEXT 仍拒绝 65,536 字节值并返回 1406,未通过削弱全局长度校验掩盖问题。
    • 覆盖源文件合并后失败与重试、异常计划 JSON、超长聚合/缓存计划等定向单测。

    白盒验证

    TestStatementInfoDiagnosticCapacitySQL 以及 pkg/util/export/etl/db、pkg/util/trace/impl/motrace、pkg/util/export 相关 8 个定向测试在该提交各运行 3 次,全部通过。检查到修复既约束新生成的报告,也在旧 CSV 导入边界兜底;不会把该内部策略扩散到用户表。

    回归测试

    此问题属于内部遥测 ETL 契约,真正断言点在生产者、历史 CSV 归一化、LOAD DATA 和文件重试边界,已由合并到 main 的 Go UT/SQL 集成测试覆盖;不适合只加一个外部 SQL MOTR 用例。尚未重跑原 TKE 周回归,因此未宣称其 3-CN、长时大数据 ETL 链路已完成验收。

    测试证据

    • 修复 PR:fix: bound statement_info diagnostics to TEXT capacity #29812。
    • main 定向命令:go test ./pkg/tests/dml -run '^TestStatementInfoDiagnosticCapacitySQL$' -count=3;go test ./pkg/util/export/etl/db ./pkg/util/trace/impl/motrace ./pkg/util/export -run 'Test(StatementInfoDiagnosticCapacity|BulkInsertStatementInfoHistoricalDiagnostics|BulkInsertStatementInfoRejectsAmbiguousLayout|StatementInfoCapacityAndPlanOwnership|StatementInfoMalformedErrorDiagnostics|StatementInfoAggregationCapacity|StatementInfoCachedMalformedPlanCapacity|MergeStatementInfoOversizedCSVRecovery)' -count=3;各包结果均为 ok。

    当前 main 上原始“超长内部报告导致整批 statement_info 导入 1406”路径在确定性 SQL 集成和内部边界测试中已修复。原 TKE 周回归的端到端观察仍未覆盖;我将该 issue 转回修复负责人,保留上述环境边界。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions