Skip to content

[Bug]: INSERT SELECT hangs and leaks transaction after COS upload idle-connection failure #27876

Closed

Description

@Ariznawlll

Description

在最新 MatrixOne main 的 Big Data 10Y 测试中,1B INSERT INTO ... SELECT ... 向带复合主键、二级索引和唯一索引的目标表写入时,COS multipart upload 返回 http: server closed idle connection。服务端已经记录 SQL 失败,但没有及时将错误返回客户端,相关事务持续被报告为 found leak txn,会话最终挂到客户端超时退出。

Environment

  • Branch: main
  • Commit: 46950ae0bd00e5a504445865abb6448f9dbefced
  • Deployment: TKE,3 CN(14C/55GiB)+ 1 TN(14C/55GiB)+ 3 Log + 2 Proxy
  • Namespace: mo-big-data-commit-46950ae-suite-10y
  • Test: Big Data 10Y run 33284942789 / job 99227536060

Steps to reproduce

目标表约 10 亿行,包含复合主键、普通二级索引和唯一索引:

CREATE TABLE big_data_test.table_with_com_pk_index_for_insert_1B (
  id BIGINT,
  col1 TINYINT,
  -- 其余 24 列省略
  PRIMARY KEY (id, col1),
  KEY (col3, col4),
  UNIQUE KEY (col4)
);

INSERT INTO big_data_test.table_with_com_pk_index_for_insert_1B(
  id,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,
  col13,col14,col15,col16,col17,col18,col19,col20,col21,col22,col23,col24,col25
)
SELECT *
FROM big_data_test.table_with_pk_for_load_1B
WHERE col4 != -7508478199581380391;

预期写入 999999998 行。

Actual behavior

以下时间均为 UTC:

  1. 10:14:43:CN nightly-regression-dis-tp-cn-lx6xx 接收连接 9699,session 01a0522a-0d3a-72bd-84e1-28b5f64a46e2,开始执行 INSERT。

  2. 10:52:37 起:CN 每 20 分钟报告该会话的事务 2474ed21381a480e18d07e55422417b3 为 found leak txn。

  3. 11:45:38:remote pipeline 连续报告:

    connector cleanup timed out sending terminal Error signal
    pipeline_failed=true
    http: server closed idle connection
    
  4. 11:45:41:服务端已经将 INSERT 记录为失败:

    Post "https://mo-nightly-gz-1308875761.cos.ap-guangzhou.myqcloud.com/
    mo-benchmark-33284942789/data/..._00000?uploads":
    http: server closed idle connection
    

    statement id:01a0522a-0ffc-7b38-bdbb-94bad8105cb4。

  5. 同一会话随后继续残留事务 2474ed21381a480e18d07e55422442e8,CN 在 12:12、12:32、12:52、13:12 持续报告 found leak txn;13:22:27 才记录 Exec.Run : 1h36m45.535s。

  6. 客户端没有收到 11:45:41 已产生的真实错误,只在 12:14:43 达到 7200 秒后报测试侧 execution timeout。

  7. 测试随后在同一连接执行 SELECT COUNT(*),再次等待 7200 秒;直到 14:14:43 测试进程退出,CN 才清理连接 9699。

相关四小时窗口内没有 OOM、exit 137 或 panic。

Expected behavior

  • COS multipart upload 的 transient idle-connection failure 应按 fileservice retry 策略重试;重试耗尽时应立即向 SQL 客户端返回原始错误。
  • remote pipeline cleanup 不应吞掉 terminal Error 或让 SQL 一直等待到客户端超时。
  • SQL 失败后相关 txn、锁和 session 应立即 rollback/释放,不应持续产生 found leak txn。
  • 后续连接或查询不应被前一条失败语句拖死。

Stability and controls

  • Reproducer: 本次 nightly 1/1 复现;单次 case 占用 4 小时,尚未连续执行 3 次。
  • Controls: 同一 run、同一数据源和集群中,Basic Insert(约 4m41s)、PK Insert(约 38m)、PK Index Insert(约 1h30m)、Sortkey Insert(约 7m42s)、Alter Insert(约 3m35s)均完成。
  • Failure atomicity/data check: INSERT 未向客户端返回终态,后续 COUNT(*) 也在同一会话超时,因此本次无法确认目标表最终行数;这正是需要修复的失败后状态不可观测问题。
  • Resource control: 相关窗口没有 OOM、exit 137 或 panic,不是 CN 被杀或内存崩溃。

Evidence

  • GitHub Actions: job 99227536060
  • Client SQL start: 2026-08-30 10:14:43 UTC
  • Server-side original failure: 2026-08-30 11:45:41 UTC
  • Client-side timeout: 2026-08-30 12:14:43 UTC
  • Session cleanup: 2026-08-30 14:14:43 UTC
  • CN: nightly-regression-dis-tp-cn-lx6xx
  • Connection/session: 9699 / 01a0522a-0d3a-72bd-84e1-28b5f64a46e2

Code analysis

已确认:

  • 服务端真实失败来自 qcloud/COS multipart upload 初始化请求(?uploads)。
  • pkg/sql/compile remote connector cleanup 无法发送 terminal Error,日志明确记录 connector cleanup timed out sending terminal Error signal。
  • frontend 已记录 INSERT status=fail,但客户端没有收到该错误;同一会话的事务继续被 leak checker 报告。

待研发确认的推测:

  1. pkg/fileservice 对 server closed idle connection 的 retry 可能没有覆盖 multipart upload 初始化阶段,或错误在上层转换后绕过 retry 判断;
  2. remote connector 的接收方退出或 channel 不可写后缺少可靠的错误 fallback,导致 frontend/客户端等待链没有结束;
  3. pipeline 失败后的 transaction rollback/cleanup 依赖 terminal signal 完成,signal 丢失后事务持续存活。

Regression coverage

修复后应保留 Big Data 覆盖,并增加可控的小规模故障注入测试:在 multi-CN INSERT INTO SELECT 的 COS multipart upload 阶段注入一次 server closed idle connection,断言:

  1. 可重试时 SQL 最终成功;
  2. 重试耗尽时客户端收到原始 COS 错误,而不是超时或 context canceled;
  3. 失败后目标表无部分提交;
  4. 同一连接可继续执行 SELECT 1;
  5. 不产生持续的 found leak txn。

Related

Activity

  1. added this to the MO-202608 milestone on Aug 30, 2026
  2. added
    kind/bug
    on Aug 30, 2026
  3. added theissue type on Aug 30, 2026
  4. ck89119 commented on Aug 31, 2026

    @ck89119
    Contributor

    Please help verify this issue @Ariznawlll

  5. Ariznawlll commented on Sep 3, 2026

    @Ariznawlll
    CollaboratorAuthor

    还没跑。明天更新结果

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s-1

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions