Skip to content

[Bug]: system.statement_info ingestion fails with TEXT length overflow during BF16 EXPLAIN ANALYZE diagnostics #29809

Closed

Description

@slyunnn

Description

The internal sys:mo_logger pipeline fails to insert statement records into system.statement_info during Wiki 10M BF16 EXPLAIN ANALYZE diagnostics. The generated LOAD DATA INLINE is rejected because a TEXT value exceeds the destination length limit of 65,535.

The same failure was observed in two separate runs on two MatrixOne main commits. A subsequent isolated local reproduction on the earlier affected main commit identified exec_plan as the overflowing field: a valid JSON plan of 88,094 bytes caused the real logging batch to fail, although the user query succeeded. A no-table literal query reproduces the problem; a BF16 index or 10M fixture is not necessary.

This issue reports a statement-log ingestion failure, not a vector-query correctness bug or a proven cause of slow queries. The original cloud payloads were abbreviated in CN logs, so their exact overflowing columns cannot be independently recovered from those artifacts. The local payload provides direct field-level evidence for this failure mechanism.

Environment

  • Branch: main
  • Deployment: TKE distributed MatrixOne, 3 CN + 1 TN
  • Dataset: Wiki, 10,000,000 rows, 768-dimensional F32 source vectors
  • Index: IVFFLAT with BF16 quantization, lists=3162
  • Diagnostic settings: probe_limit=5, ivf_preload_entries=0, K=10, one active query at a time
Run MatrixOne commit Test-script commit
37913063613, attempt 1 908166384d32e378a72cc3b5ef9e7075603c4e81 2032c464d62f02c454f1f50c5152dbb2bf8c3ec9
37876203973, attempt 3 23d8f61252f3017dff218b530817a240206fd762 676bda26465440036ac83766cb8292a259af21c5

Minimal local reproduction and boundary controls

Tested on Linux/arm64, one isolated CN/TN/LOG instance, MatrixOne main@23d8f61252f3017dff218b530817a240206fd762, 2 CPU / 2 GiB. Image: matrixorigin/matrixone:issue-29145-main-23d8f61252, image ID sha256:607662d9b54ef568d568e52c1a739d587794c994dc97a570b178e3d07506d066. This is a reproduction on an affected historical main commit, not an assertion that the latest main was retested.

Statement tracing and SQL export were enabled, statement aggregation disabled, trace-export-interval=2, long-query-time=0.000001. Each query deliberately sleeps 1.2 seconds to ensure a non-empty execution plan is recorded. No user data table is required.

import time
import pymysql

c = pymysql.connect(host="127.0.0.1", port=16709, user="dump",
                    password="111", charset="utf8mb4", autocommit=True)
with c.cursor() as q:
    q.execute("CREATE DATABASE IF NOT EXISTS issue29809_probe")
    q.execute("USE issue29809_probe")
    # Send a literal through the SQL protocol, not SQL REPEAT(), which may
    # produce a different plan. Run separately so the controls are not batched.
    for name, size in [("below", 28000), ("above", 29000),
                       ("repeat", 40000), ("recovery", 100)]:
        marker = f"SELECT /* issue29809_{name} */"
        q.execute(marker + " SLEEP(1.2), %s AS value", ("a" * size,))
        assert q.fetchone()[1] == "a" * size
        time.sleep(20)
        q.execute("SELECT statement_id, LENGTH(statement), LENGTH(exec_plan) "
                  "FROM system.statement_info WHERE `database`=%s "
                  "AND statement LIKE %s",
                  ("issue29809_probe", marker + "%"))
        print(name, q.fetchall())
c.close()

The complete plan size varies with serialized execution statistics. The relevant limit is the actual plan size, not an invariant SQL-literal character count.

Test Actual exec_plan bytes Result
28,000 ASCII characters, separate batch 64,092 User result correct; statement record persisted
29,000 ASCII characters, separate batch 66,093 User result correct; internal logger TEXT overflow; no matching record after 20 seconds
40,000 ASCII characters, initial mixed batch 88,094 User result correct; internal logger TEXT overflow; raw fallback CSV identifies exec_plan
40,000 ASCII characters, repeated separately 88,089 Same overflow reproduced; user result correct
100 ASCII characters after the failures 8,281 User result correct; statement record persisted after 20 seconds

For the 88,094-byte record, stored statement is only 1,027 bytes and valid UTF-8. The execution plan is valid JSON. Its size exactly matches the Src length 88094 error at 2026-10-10 03:05:51 UTC. This rules out oversized stored SQL text as the cause of that local batch failure.

Original TKE reproduction

These are the original workload steps. The local reproducer above avoids loading 10M rows.

  1. Prepare the Wiki 10M BF16 fixture using the pinned test-script revision above. The existing TKE workflow selector is ivf_bf16_quantization_10m,wiki_threshold_diagnostic.

  2. Run the pinned diagnostic script against that fixture:

    python3 -u script/feature_25026_threshold_diagnostic.py \
      --host <proxy-host> --output evidence.json
  3. The script selects source IDs 1, 2 and 3 and executes EXPLAIN followed by EXPLAIN ANALYZE for ordinary file_id PRE filtering and distance-threshold PRE/POST filtering. It uses the same source vector and file_id across each sample's variants, with the threshold l2_distance(...) <= 2.5.

  4. Inspect CN logs for sys:mo_logger failures while writing system.statement_info. Exact SQL, parameters and plans are retained in wiki_threshold_diagnostic/evidence.json in the artifacts below.

The older script in run 37876203973 stopped after the first query timeout; only the newer run attempted all nine executions.

Actual behavior

Latest run, 2026-10-09 11:10:55 UTC (19:10:55 Asia/Shanghai):

Can't cast column from TEXT type to TEXT type because of one or more values in that column.
Src length 102392 is larger than Dest length 65535

The associated frontend log records account sys:mo_logger and a failed internal statement:

LOAD DATA INLINE FORMAT='csv', DATA='...' INTO TABLE system.statement_info FIELDS TERMINATED BY ','
status: fail

The earlier run recorded the same failure at 2026-10-09 09:10:09 UTC (17:10:09 Asia/Shanghai):

Src length 104250 is larger than Dest length 65535

These are internal logging writes, not user attempts to insert oversized values into a TEXT column. Eventual persistence of the original cloud records remains unverified because those environments were cleaned up.

Local batch impact and multibyte observation

The initial local failed CSV batch contains four tested SELECT records: a short control (plan 8,271 bytes), 20,000 ASCII characters (48,098 bytes), 40,000 ASCII characters (88,094 bytes), and 10,000 Chinese characters (68,091 bytes). All four user queries returned the exact expected values. None of these four statement IDs was queryable in system.statement_info at the initial 20-second check; the raw records were retained in the ETL fallback CSV. Thus this is not proof of permanent data loss, but the oversized record also delayed normal records sharing its batch.

Automatic ETL retry was observed, not merely assumed: at 03:10:11–03:10:41 UTC, cn-service.ETLMerge retried all three local failed files, reproduced the same 88,089 / 88,094 / 66,093 overflow errors and reported total: 3, success: 0. At 03:11:16 UTC, the initial four statement IDs still each returned count 0, approximately 5 minutes 25 seconds after the first ingestion failure. The CSV files remained available. A later independent short-query batch did persist, so this is batch-level unavailability with failed retry, not complete shutdown of statement logging. No permanent-loss claim is made beyond this observation window.

Initial batch statement IDs, in the order listed above:

01a123c6-16a0-774b-83a0-eba1212e88b6
01a123c6-1b60-7c29-b115-afec6d0e2e62
01a123c6-2031-7434-a774-44608048d68d
01a123c6-24fe-7c80-9d50-27a5718f6e46

Raw initial fallback file: sys/logs/2026/10/10/statement_info/1791601551_7c4dccb4-4d3c-41f8-b482-5251dc7a41bf_ALL_909784512.csv; SHA-256: 7b79f5770089168ca1e04c70b5477931a259feee362e895477b965b914d9b840. The local reproduction scripts, raw CSV files, container log and structured field/persistence checks are archived; the minimal script above is included inline so no access to the local archive is required to reproduce.

Additionally, the Chinese query's fallback statement field is 1,027 bytes and invalid UTF-8: its ending includes the incomplete character bytes e4 b8 followed by 2e 2e 2e (...). Its exec_plan remains valid UTF-8/JSON. This is a directly observed multibyte truncation defect; it is not needed to reproduce the ASCII-only overflow, and its independent ingestion impact has not yet been isolated.

Expected behavior

The statement-log pipeline should handle oversized fields consistently with its storage schema—for example, by using an appropriate field capacity or a documented safe truncation policy—rather than failing its own batch ingestion.

For the verified local reproduction, exec_plan must be handled consistently with its destination capacity. Any truncation must preserve valid UTF-8 and an appropriate execution-plan representation. Normal records should not remain unavailable because another record in their batch is oversized.

Source evidence at the reproduced revision

  • schema.go declares exec_plan as a TEXT column.
  • report_statement.go obtains the serialized plan and assigns it to the row; ExecPlan2Json returns the marshaled plan without a destination-length check.
  • content.go falls back from SQL export to CSV for the batch when SQL export fails, matching the observed local file.

Stability and controls

  • The same ingestion error was observed in two independent cloud runs on two main commits. Local ASCII-only boundary tests reproduce the error without any vector data.
  • In the latest run, all nine static plans were collected; seven EXPLAIN ANALYZE executions completed and two were cancelled by the diagnostic's 60-second deadline.
  • Both cancellations were acknowledged and the original connection recovered before subsequent queries. The returned 1105 context canceled errors are expected consequences of those cancellations, not evidence that this logging failure caused the query failures.
  • The three-row BF16 control completed all nine local diagnostic executions without overflow. No user-result corruption or causal link to slow/cancelled queries has been established.

Evidence

Run Raw job / artifact Relevant file inside the artifact
37913063613, attempt 1 Job · Artifact wiki_threshold_diagnostic/nightly-regression-dis-tp-cn-tk4dm.log, lines 277–279
37876203973, attempt 3 Job · Artifact wiki_threshold_diagnostic/nightly-regression-dis-tp-cn-m6qmf.log, lines 127–129

Both artifacts also contain query output and structured execution evidence. The error first appears in function/func_cast.go and is then reported by the frontend for the internal logging write; this identifies the failure boundary, not the upstream field-sizing root cause.

Regression coverage

After fixing the defect, exercise the real statement-reporting pipeline and verify:

  1. Boundary lengths and oversized SQL/plan fields are stored or safely truncated according to the intended contract.
  2. Multibyte text remains valid after any truncation.
  3. Normal records in the same batch are still persisted, and the pipeline remains usable after an oversized record.
  4. User query execution and results are unaffected.

A direct oversized INSERT into a user TEXT column is not an equivalent regression test.

Related

Activity

  1. added this to the MO-202610 milestone on Oct 10, 2026
  2. added theissue type on Oct 10, 2026
  3. added
    kind/bug
    on Oct 10, 2026
  4. self-assigned this
    on Oct 10, 2026
  5. XuPeng-SH commented on Oct 10, 2026

    @XuPeng-SH
    Contributor

    fixed by #29812

  6. slyunnn commented on Oct 10, 2026

    @slyunnn
    Author

    Verification Environment

    • Latest fetched origin/main: 62827a1c8bfb1c846c0f3528e71503baacb3b3bc, fix: bound statement_info diagnostics to TEXT capacity (#29812).
    • Rebuilt with Go 1.27.1 on Linux/ARM64; newly started runtime reports this commit. Binary SHA-256: 3af12f7e2fb608aaaea4abf443ecad2f4e286d7e1c9db0871db2f736d835c69e.
    • Fresh isolated 2 CN / 1 TN / 1 Log service / Proxy topology, local-disk storage. CN statement tracing and SQL export enabled, statement aggregation disabled, export interval 2 seconds, long-query threshold 0.000001 seconds.
    • All endpoints were connected and actually exercised: Proxy 127.0.0.1:6721 (container 6009), CN1 127.0.0.1:16721 (container 16001), CN2 127.0.0.1:16722 (container 16002). Alternate host ports avoid existing services; this is not a test of the pre-existing 6001/16001/16002 deployment.
    • Client: PyMySQL, TCP text protocol COM_QUERY, utf8mb4. Literal payloads are sent through SQL, with SLEEP(1.2) to capture non-empty plans. The oracle checks real system.statement_info persistence, not direct oversized insertion into a user table.

    What Was Covered

    • OK — 18/18 user queries (6 per endpoint) returned exact expected values, and every corresponding statement record persisted within the bounded 45-second polling window.
    • OK — Below-capacity control retained valid full JSON plans of 64086 bytes on all endpoints.
    • OK — Above-capacity plans of 66087–66093 bytes and larger plans of 88088–88091 bytes were replaced with valid 141-byte JSON summaries, with truncated=true, original_bytes>65535, and limit_bytes=65535.
    • OK — Subsequent short-query records persisted with valid text and JSON after the oversized and multibyte cases; the primary query connections remained usable.
    • Failed — All 6 Chinese/emoji statement records contained invalid UTF-8. Their stored statement length was 1027 bytes; the retained prefix ended with incomplete e4 or f0 before 2e2e2e (...).
    • Failed — Direct retrieval of each invalid statement using a UTF-8 PyMySQL connection raised UnicodeDecodeError. This check used separate connections so the expected decoding failure did not contaminate later test results.
    • OK — The multibyte failures are independent of plan overflow: their plans remained valid full JSON of approximately 11 KB, below the capacity limit.
    • Not covered — This run did not replay historical ETL files, force normal/oversized records into the same batch, rerun TKE/Wiki 10M, or benchmark vector-query performance. The earlier same-commit verification separately reports historical ETL recovery; it is not presented as newly executed here.

    Findings

    Related merged fix: #29812 — fix: bound statement_info diagnostics to TEXT capacity, commit 62827a1c8bfb1c846c0f3528e71503baacb3b3bc.

    The original live execution-plan overflow is fixed in this regression. The remaining SQL-text integrity defect is confirmed through Proxy and both CNs, consistent with the earlier comment.

    commonutil.Abbreviate still slices the input by bytes at the frontend abbreviation boundary. CapStatementInfoText returns inputs within 65535 bytes unchanged, so it does not repair an already-invalid 1027-byte statement. Correct user-query results and successful log insertion therefore do not imply readable statement text.

    The first diagnostic attempt continued on a connection interrupted by a decode error and subsequently encountered a packet-sequence error. The final complete run isolated decoding checks onto disposable connections and completed normally; the UTF-8 defect remained directly reproducible. Script completion does not mean the failed UTF-8 assertions passed.

  7. added a commit that references this issue on Oct 10, 2026
    652c643
  8. dengn commented on Oct 12, 2026

    @dengn
    Contributor

    Additional observation during native BI compatibility testing on the same affected commit 23d8f61252f3017dff218b530817a240206fd762 (standalone Linux x86_64, 2026-10-12 UTC): the sys:mo_logger pipeline repeatedly reports failed LOAD DATA INLINE ... INTO TABLE system.statement_info batches with the existing TEXT-overflow signature.

    One recorded example:

    2026/10/12 23:16:01.896233 +0000
    account sys:mo_logger
    Can't cast column from TEXT type to TEXT type because of one or more values in that column.
    Src length 6356929 is larger than Dest length 65535
    

    There were 224 matching log records in the inspected interval; these are failed batch log entries, not 224 identified unique user statements. The inline CSV is abbreviated in the CN log, so this observation does not independently identify the overflowing column or quantify how many trace rows are missing.

    The user-facing analytics can still succeed: 534 SQL controls and 534 full JDBC results matched independent references during this iteration. This adds evidence that the logging failure also appears with ordinary BI/semantic-model workloads; no new issue is opened, and no current-HEAD regression or user-query computation failure is asserted.

  9. slyunnn commented on Oct 13, 2026

    @slyunnn
    Author

    Regression and extended verification for #29809 (2026-10-13)

    Verification Environment

    • Latest fetched origin/main: e5111936b9f5845d5d76c7b8f3a6f56b2361e4f4, fix(parser): accept reserved words in qualified identifiers (#30027).
    • The Linux/ARM64 mo-service binary was rebuilt from that exact commit and its reported commit ID matched it.
    • A fresh local-disk 2 CN / 1 TN / 1 Log service / Proxy topology was used. Proxy 127.0.0.1:6741 (container 6009), CN1 127.0.0.1:16741 (container 16001), and CN2 127.0.0.1:16742 were each connected and exercised.
    • Client protocol: PyMySQL over TCP MySQL text protocol (COM_QUERY, utf8mb4). The three endpoint sessions were isolated and executed in parallel; each session remained serial while waiting for its own asynchronous statement export.

    What Was Covered

    • OK — The original wide-literal diagnostic shape (28,000, 29,000, and 40,000 ASCII bytes) returned the expected user values and persisted one successful system.statement_info row at every endpoint.
    • OK — Every persisted exec_plan was valid JSON and within the 65535-byte TEXT capacity. Current main emits a bounded diagnostic summary of 638–643 bytes for these shapes instead of the historical full 66–88 KB plan that failed ingestion.
    • OK — Chinese and emoji literals crossing the prior abbreviation boundary persisted as strictly valid UTF-8 on Proxy, CN1, and CN2 (6/6 records).
    • OK — A short query after the wide and multibyte cases persisted normally and each primary session remained usable.
    • OK — The final run used unique database names and SQL markers; all 18/18 selected statement records were created by this run rather than inherited history.
    • Not covered — The historical Wiki 10M BF16 workload and pre-existing ETL fallback files were not replayed. They are not required to reproduce this statement-diagnostics sizing defect.
    • Not covered — Native binary prepared-statement (COM_STMT_PREPARE / COM_STMT_EXECUTE) was not repeated in this integration run; its focused coverage is part of merged #29826.

    Findings

    The original ingestion failure is fixed. The related fixes are 62827a1c8bfb1c846c0f3528e71503baacb3b3bc / #29812, fix: bound statement_info diagnostics to TEXT capacity, and 652c643666428f1c434e03369834f2a9bead7c27 / #29826, Fix UTF-8 statement diagnostics and bound prepared logging work.

    The initial re-validation configuration incorrectly gave each service a separate local-disk /mo-data, which made SHARED unavailable across CNs and caused 20405 file ... is not found. The topology was discarded and recreated with the required shared data volume before final results were collected; this was a test-environment error, not a product result.

    MOTR / BVT Coverage

    No MOTR change was added. The merged fixes already include focused ownership tests for capacity boundaries, UTF-8 boundaries, row serialization, ETL upload, and prepared diagnostics; this run supplied the missing current-main, multi-CN/Proxy integration evidence through the actual statement-reporting pipeline.

    Large-data regression is not needed: the defect is determined by diagnostic-field byte capacity and UTF-8 boundaries, not row count, vector index size, spill, concurrency, or resource scale. The original 10M workload is a workload source, not a necessary execution boundary for this logging failure.

    Final Conclusion

    Fixed. On latest main, the original wide diagnostic scenario, multibyte boundary cases, and recovery behavior all completed successfully through Proxy, CN1, and CN2. No MatrixOne service source or MOTR files were modified in this verification.

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

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions