Skip to content

[Bug] sysbench1000w Insert Duplicate fails: CN memory pressure (40-41 GiB) causes cascading connection failures #26088

Not planned

Description

@Ariznawlll

Issue

sysbench1000w "Insert Duplicate 1000 threads" test fails with connection timeouts due to CN memory pressure. During the test, CN memory spikes to 40-41 GiB (close to the 55 GiB limit), triggering DN OOM alerts and cascading connection failures across the cluster.

Environment

Field Value
CI Run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/29940401960/job/89124090085
MO Commit 273400583d84d8da0ea2d61d9cb1c3dbd75db708 (4.2-dev)
Namespace mo-branch-commit-273400583-20260723
Cluster TKE (3 CN + 1 DN + 2 Proxy)
Failure Time 2026-07-23 06:24:24 - 06:31:37 UTC
Failed Step Step 34: Start OLTP Insert Duplicate Test No Auto_increment With 1000 Threads

Failure Details

Step 34 ran for 7 minutes (06:24:24 - 06:31:37 UTC) before timing out. The test normally completes in 5-7 minutes.

Error Messages

  1. CN service error (06:31:56 on CN gr4jr):
cannot get salt, maybe not use proxy
error: read tcp 10.143.140.190:6001->10.143.140.182:49052: i/o timeout
  1. Proxy connection failures (06:31:50-55):
close conneciton failed
error: close tcp4 10.143.140.186:6001->10.128.1.138:42544: use of closed network connection
  1. DN OOM alerts (06:31:53-59):
MergeExecutorEvent-PauseDueToOOMAlert
available-mem: 0

Memory Usage at Failure Time

CN Pods (06:28-06:30 UTC peak):

CN Pod Peak Memory Time
7f25f 41.4 GiB 06:28
gr4jr 40.8 GiB 06:30
cznhr 40.5 GiB 06:25

DN Pod: 38.9 GiB peak at 06:31

Normal vs Failed Tests

Test Duration Result
Read-Only 1000 5 min ✅
Random_points 1000 5 min ✅
Random_ranges 1000 5 min ✅
Read-Write 1000 5 min ✅
Write_only 1000 5 min ✅
Update-index 1000 5 min ✅
Update-Non-index 1000 5 min ✅
Delete 1000 5 min ✅
Insert 1000 13 min ✅
Insert Ignore 1000 7 min ✅
Insert Duplicate 1000 7 min ❌ Failed

Root Cause Analysis

Error Chain

CN memory spikes to 40-41 GiB (approaching 55 GiB limit)
  → DN detects memory pressure, triggers MergeExecutorEvent-PauseDueToOOMAlert (available-mem: 0)
  → CN service fails to allocate memory for new connections
  → CN reports "cannot get salt, i/o timeout" errors
  → Proxy detects closed connections: "close conneciton failed"
  → Sysbench client cannot establish new connections
  → Test times out after 7 minutes
  → Step 34 marked as failure

Why Insert Duplicate Specifically?

The "Insert Duplicate" test performs INSERT ... ON DUPLICATE KEY UPDATE operations with 1000 concurrent threads. This workload:

  1. Generates high memory pressure due to duplicate key checking and update operations
  2. Causes CN memory to spike to 40-41 GiB
  3. Triggers DN OOM protection (available-mem: 0)
  4. Results in cascading connection failures across the cluster

Other tests (Read-Only, Random_points, etc.) completed successfully because they generate less memory pressure.

Impact

  • Test Reliability: Insert Duplicate test fails intermittently under high memory pressure
  • Cluster Stability: Memory pressure causes cascading failures affecting all connections
  • User Impact: Similar memory pressure issues could affect production workloads with high-concurrency INSERT operations

Related Issues

This is similar to previous sysbench1000w failures caused by memory pressure:

  • Insert Ignore 1000 threads also took 7 minutes (longer than normal 5 min)
  • Insert 1000 threads took 13 minutes (longer than normal 5 min)
  • These tests show signs of memory pressure even when they don't fail completely

Suggested Investigation

  1. Memory Profiling: Profile CN memory usage during Insert Duplicate workload to identify memory allocation hotspots
  2. DN OOM Threshold: Investigate why DN triggers OOM alerts at 38.9 GiB (well below the 55 GiB limit)
  3. Connection Pool: Check if CN connection pool properly handles memory pressure scenarios
  4. Memory Limits: Review if 55 GiB is sufficient for high-concurrency INSERT workloads with 1000 threads

Logs

Activity

  1. added
    kind/bug
    severity/s1
    and removed
    severity/s1
    on Jul 23, 2026
  2. added theissue type on Jul 23, 2026
  3. added this to the MO-202607 milestone on Jul 23, 2026
  4. Ariznawlll commented on Jul 23, 2026

    @Ariznawlll
    CollaboratorAuthor

    Updated Root Cause Analysis

    After re-analyzing the evidence, this is not purely a memory exhaustion issue, but rather a cascading failure triggered by DN memory pressure.

    Key Evidence

    1. CN memory: 40-41 GiB (limit 55 GiB, 14 GiB headroom remaining) — not close to OOM
    2. DN memory: 38.9 GiB, triggered MergeExecutorEvent-PauseDueToOOMAlert (available-mem:0)
    3. Error: cannot get salt, i/o timeout — connection timeout, not memory allocation failure
    4. DN available-mem:0: DN's merge executor detected low memory, not CN

    Revised Error Chain

    DN memory pressure (38.9 GiB, available-mem: 0)
      → DN merge executor pauses (MergeExecutorEvent-PauseDueToOOMAlert)
      → DN operations slow down (merge is critical for storage operations)
      → CN operations that depend on DN become slow
      → CN cannot establish new connections quickly enough
      → Connection pool exhausted or connection attempts timeout
      → CN reports "cannot get salt, i/o timeout"
      → Proxy detects closed connections
      → Sysbench client cannot connect → test times out
    

    Why This Happens

    The "Insert Duplicate" workload generates high memory pressure on the DN (not CN). The DN's merge executor detects available-mem:0 and pauses merge operations. Since merge is critical for storage operations (compaction, cleanup), this causes:

    1. DN operations to slow down significantly
    2. CN operations that depend on DN (reads, writes, metadata) to become slow
    3. Connection establishment to timeout because CN cannot complete the handshake quickly
    4. Connection pool to exhaust because new connections cannot be established

    Questions for Investigation

    1. Why does DN report available-mem:0 at 38.9 GiB? What is the DN's memory limit? Is the threshold too aggressive?
    2. Why does DN merge pause affect CN connection establishment? What is the dependency chain?
    3. Is this a memory leak or workload issue? Is the DN memory usage expected for this workload?
    4. Why does "Insert Duplicate" specifically trigger this? What is different about INSERT ... ON DUPLICATE KEY UPDATE compared to other INSERT operations?

    Suggested Next Steps

    1. Profile DN memory usage during Insert Duplicate workload to identify memory allocation hotspots
    2. Check DN memory limits and thresholds — why does available-mem:0 trigger at 38.9 GiB?
    3. Investigate DN merge pause impact — how does merge pause affect CN operations?
    4. Compare with other INSERT operations — why does Insert Duplicate generate more DN memory pressure than Insert Ignore or regular Insert?
  5. Ariznawlll commented on Jul 23, 2026

    @Ariznawlll
    CollaboratorAuthor

    Root Cause Found: GOMEMLIMIT Misconfiguration

    After further investigation, I found the real root cause: DN GOMEMLIMIT is set too low.

    Configuration

    Setting Value
    DN container memory limit 55 GiB
    DN GOMEMLIMIT 35 GiB
    DN memory cache 5 GiB
    Actual DN memory usage at failure 38.9 GiB

    The Problem

    The DN was using 38.9 GiB, which is above the GOMEMLIMIT of 35 GiB. This caused:

    1. Go runtime detected memory pressure (usage > GOMEMLIMIT)
    2. Go runtime reported available-mem:0 to the merge executor
    3. Merge executor triggered MergeExecutorEvent-PauseDueToOOMAlert
    4. Merge operations paused, causing DN operations to slow down
    5. CN operations that depend on DN became slow
    6. Connection establishment timed out
    7. Sysbench test failed with connection timeout

    Why GOMEMLIMIT is 35 GiB but container limit is 55 GiB?

    This is a misconfiguration. The GOMEMLIMIT should be set closer to the container limit (e.g., 50 GiB) to allow the Go runtime to use more memory before triggering OOM alerts.

    The current configuration:

    • Container limit: 55 GiB (hard limit, container will be killed if exceeded)
    • GOMEMLIMIT: 35 GiB (soft limit, Go runtime will trigger GC and OOM alerts when exceeded)

    The gap between 35 GiB and 55 GiB (20 GiB) is wasted - the Go runtime won't use it because it thinks it's running out of memory at 35 GiB.

    Revised Error Chain

    DN memory usage reaches 38.9 GiB
      → Exceeds GOMEMLIMIT (35 GiB)
      → Go runtime detects memory pressure
      → Go runtime reports available-mem:0
      → DN merge executor triggers PauseDueToOOMAlert
      → Merge operations pause
      → DN operations slow down
      → CN operations that depend on DN become slow
      → Connection establishment times out
      → Sysbench client cannot connect
      → Test fails
    

    Suggested Fix

    Increase DN GOMEMLIMIT from 35 GiB to 50 GiB (or closer to the container limit of 55 GiB).

    This will allow the Go runtime to use more memory before triggering OOM alerts, preventing the cascade failure during high-load workloads like Insert Duplicate.

    Configuration Locations

    • Workflow file: .github/workflows/nightly-regression-on-tke.yml

      • Variable: dn_gomemlimit: 35000MiB
      • Should be changed to: dn_gomemlimit: 50000MiB
    • MO cluster config: mo-bench-tke.yaml

      • Template: DN_GOMEMLIMIT
      • Substituted with: 35000MiB
      • Should be changed to: 50000MiB

    Impact

    This misconfiguration affects all high-load workloads that push DN memory usage above 35 GiB:

    • sysbench1000w Insert Duplicate (this failure)
    • sysbench1000w Insert (took 13 min instead of 5 min)
    • sysbench1000w Insert Ignore (took 7 min instead of 5 min)
    • Any workload that pushes DN memory above 35 GiB

    Verification

    After increasing GOMEMLIMIT to 50 GiB, the DN should be able to handle high-load workloads without triggering OOM alerts, and the sysbench tests should complete normally.

  6. added
    severity/s0
    and removed
    severity/s0
    on Jul 23, 2026
  7. ck89119 commented on Jul 23, 2026

    @ck89119
    Contributor

    排查结论更新

    我结合失败任务日志,以及 TKE Grafana 中的 Loki、Prometheus 和 Pyroscope 数据进行了排查,并与使用相同 MO commit、相同资源配置的上一次成功运行做了对比。

    结论

    现有证据不支持将 DN GOMEMLIMIT=35 GiB 认定为直接根因,此次失败也不是 OOM 或容器重启引起的级联故障。

    直接失败原因是:冷启动阶段出现极端长尾,5 条 duplicate insert 语句超过了客户端约 100 秒的 socket 超时。客户端断开后,对应 CN 上的语句才以 context canceled 结束并回滚。

    随后负载恢复到 4.7k-7.7k TPS 并继续完成。任务失败仅仅是因为用例要求成功率必须为 100%。

    证据

    • 失败运行:29940401960,job 89124090085
    • MO commit:273400583d84d8da0ea2d61d9cb1c3dbd75db708
    • Namespace:mo-branch-commit-273400583-20260723
    • Insert Duplicate 时间窗:2026-07-23 06:25:53-06:31:36 UTC
    • 结果:SUCCESS=901359,ERROR=5,TPS=3001,RT_MAX=86747 ms
    • 5 个客户端错误均为 Communications link failure,距离最后一次收发数据约 100.1 秒。
    • 在 CN 日志中关联到的 3 个 SQL 参数(8966083、8264909、8022201),都是同一类 INSERT ... ON DUPLICATE KEY UPDATE prepared statement,并在客户端超时后立即以 context canceled 结束。
    • 未发现 OOMKilled、cgroup OOM、exit 137、进程重启或容器重启;所有 CN/DN 的 restart counter 均为 0。

    与成功运行对比

    上一次成功运行 29762051867,job 88479648594,使用了完全相同的 MO commit 和相同的资源/GOMEMLIMIT 配置。

    它的 Insert Duplicate 同样存在严重的冷启动长尾:

    • Namespace:mo-branch-commit-273400583-20260720
    • 时间窗:2026-07-20 22:41:02-22:46:47 UTC
    • 结果:SUCCESS=1063158,ERROR=0,TPS=3529,RT_MAX=89996 ms
    • CN/DN 内存峰值与失败运行相当,部分还更高。
    • 两次运行中,每个 CN 的 active txn 都达到约 160,wait-active 都达到约 180。
    • 两次运行中,DN merge 可用内存都长期为 0,并且都持续触发 merge scheduling pause。

    因此,merge throttling 和 DN 35 GiB GOMEMLIMIT 是相关的后台压力信号,但无法区分成功和失败运行,不能作为本次失败的直接根因。将 DN GOMEMLIMIT 提高到 50 GiB 也不会改变 merge scheduler 的 41.25 GiB 预算;同时 MatrixOne MPool/off-heap 内存不受 Go GOMEMLIMIT 约束,这样做反而可能提高 cgroup OOM 风险。

    当前根因范围

    目前能够复现和确认的边界是:1,000 并发线程下的冷缓存性能长尾具有波动性。

    相关压力包括:

    • 每个 CN 约 160 个 active transaction,另有约 180 个排队;
    • duplicate/dedup 执行期间的对象存储读取;
    • remote lock 和 pipeline 等待;
    • 少量 statement execution 达到 90-100 秒以上。

    失败运行中,statement execution 超过 84 秒的事件明显多于成功运行,其中 5 条最终越过客户端超时边界。现有数据表明 txn admission、S3 read、remote lock 和 pipeline execution 都与压力相关,但还不足以把整个长尾归因于某一个函数。

    建议后续分两部分处理:

    1. Nightly 稳定性:考虑增加 warm-up 或延长客户端超时,不要将其当作 OOM 配置故障处理。
    2. 性能问题:单独跟踪冷缓存下 90-100 秒长尾,继续拆分 txn admission、对象存储读取、remote lock、pipeline execution 和 commit 的耗时。

    冷缓存极端长尾的进一步结论

    继续对齐 S3FS 慢日志、Prometheus 直方图、Pyroscope 阻塞栈、节点网络指标以及上述 MO commit 的源码后,极端长尾的直接机制已经基本收敛。

    关键证据

    • 失败运行中,两个慢 CN 的 S3FS io-read-all 分位数分别达到 p999=86.5s 和 p999=79.0s;成功运行三个 CN 的 p999 仅为 32.0-36.8s。成功运行的普通冷读并不更快,但失败运行的极端尾部明显更厚。
    • 3 条已关联的超时 SQL 与同一 CN 上的 S3FS 慢读在结束时间上高度一致:
      • 参数 8966083:S3FS 读取耗时 98.927s,请求约 32 KiB,取消前仅收到 15,944 字节;慢读日志后约 0.4ms 出现 context canceled。
      • 参数 8264909:S3FS 读取耗时 88.598s,取消前收到约 40.2 MiB;慢读日志后约 0.6ms 出现 context canceled。
      • 参数 8022201:S3FS 读取耗时 88.327s,取消前收到约 24.6 MiB;慢读日志后约 0.8ms 出现 context canceled。
    • S3FS 慢事件本身没有 trace ID,因此上述关系是基于“同一 CN + 同一毫秒结束”的强相关,而不是 trace 级唯一映射。
    • Pyroscope 显示大量 goroutine 阻塞在 S3FS.Read -> io.ReadAll -> net/http response body -> TLS Conn.Read -> netpoll,说明主要等待发生在 COS HTTP 响应体读取阶段,而不是 txn admission、lock acquire 或 pipeline。
    • 失败运行两个慢 CN 所在节点在 duplicate 冷读期间的 TCP 重传比例约为 0.54% 和 0.72%,TcpExt_TCPTimeouts 增量约为 26 和 39;成功运行三个节点分别约为 0.02%-0.31% 和 0-7。这些是节点级聚合指标,不能单独证明物理故障位置,但与慢 COS body 的时间和节点分布一致。
    • 未发现 file service retry、S3 connection failure 或 DNS failure。响应体读取处于停滞而未返回错误,因此现有重试逻辑没有被触发。

    对应源码机制

    在 commit 273400583d84d8da0ea2d61d9cb1c3dbd75db708 中:

    • HTTP transport 的 20s 超时是 ResponseHeaderTimeout,只约束等待响应头;http.Client 没有整个请求或响应体读取超时。
    • COS GET 返回的 body 会包装为 retryableReader,但只有底层 Read 返回错误时才会重试。如果 TLS socket read 一直没有返回,重试器无法介入。
    • 因此,少量 COS 响应体读取可以持续停滞到 JDBC 客户端约 100 秒的 socket 超时;客户端断开并取消 context 后,CN 才终止并回滚对应语句。

    当前根因判断

    1. 触发因素:duplicate/dedup 冷扫描产生高并发 COS 读取时,两个 CN 节点到 COS 的网络路径出现明显 TCP 重传/RTO,少量响应体读取形成 88-105 秒极端长尾。
    2. MatrixOne 放大因素:响应体没有“持续无进展”超时;读取未返回错误时也无法执行 range 续读重试,导致外部网络停滞直接占住 SQL 和事务槽位,直到客户端超时。
    3. 并发放大:每个 CN 约 160 个 active txn、约 180 个等待事务,加上客户端连接的粘性分布,使少量慢读集中拖住对应 CN 上的请求。
    4. duplicate 阶段确实同时出现 remote lock RPC timeout,但 lock acquire 没有超过 48 秒的长尾,而且承担大量 remote lock timeout 的 CN 本身 S3 读取较快。因此它更像同一压力下的次生症状或放大项,不是这 5 条 100 秒超时的主要链路。

    建议验证与改进

    • A/B 重跑时将 CN 固定到相同节点或更换节点,同时采集 S3FS 慢读、TCP retransmit 和 TCP timeout,验证长尾是否随节点/网络路径迁移。
    • 增强 S3FS 慢读日志:记录 trace/span、预期字节数、实际读取字节数、无进展时间和续读次数,建立 SQL 到对象存储读取的唯一映射。
    • 评估“读取进度超时”而不是直接设置固定的 http.Client.Timeout=20s。正常的 100 MiB 冷读本身可能需要 20-30 秒,超时应在持续无字节进展时触发,并利用现有 range reader 从已读 offset 续传。
    • warm-up 或提高 JDBC socket timeout 可以降低 Nightly 偶发失败,但只能作为稳定性缓解,不能替代响应体停滞恢复机制。
  8. added
    severity/s0
    and removed on Jul 27, 2026
  9. Ariznawlll commented on Sep 4, 2026

    @Ariznawlll
    CollaboratorAuthor

    最新 main 本地规模对照

    • MatrixOne origin/main:e6b25ee7726596514f520925815692c1a44031e1
    • 拓扑:本地单 CN/TN/LOG,非 TKE 集群
    • 负载:16 个并发连接,每连接 5,000 次 prepared ODKU,总计 80,000 次;1,000 个不同主键循环冲突更新。

    结果:最终行数 1,000、SUM(v)=80,000,无执行错误、无丢更新;总耗时约 38.2 秒。

    该结果仅覆盖中等规模并发正确性,不能替代 issue 原始 1,000 线程/大数据量的 TKE 性能与稳定性验证,因此不据此关闭 #26088。

  10. Ariznawlll commented on Dec 2, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    未完成验收。近期 4.2-dev 的同规模 Insert Duplicate 回归未复现原客户端超时,按当前观察先关闭,后续若再次出现同类问题再重新打开并补充证据。

    关键证据

    • 原问题:run 29940401960,4.2-dev commit 273400583d84d8da0ea2d61d9cb1c3dbd75db708;1000 线程存在 5 次客户端连接超时。后续排查认为 COS 响应体读取长尾与这些超时强相关,未证明 DN GOMEMLIMIT 是直接根因,详见调查。
    • 近期 TKE 回归:run 46674761869,MatrixOne 167a1a91999f43146393995286b8237a0f6e0942;准备 10 张表、每表 1000 万行,1000 线程执行 Insert Duplicate,成功 671335、错误 0、最大响应约 4.2 秒。该次测试配置 CN 内存上限 55Gi、DN 内存上限 32Gi,DN GOMEMLIMIT 20000MiB。
    • 最近检查的六次同类步骤均通过:11 月 26 日、11 月 27 日、11 月 28 日、11 月 29 日、11 月 30 日、12 月 2 日(北京时间)。

    待解决点

    • 原运行是 3 CN,近期回归为 1 TP CN + 2 AP CN,负载路由和并发条件不同;没有进行原拓扑冷缓存与 COS 网络扰动的匹配对照,也未证明特定修复或根因消失。较低的部分内存配置下通过是近期有效信号,但不能单独证明旧环境不会复现。
    • 如果再出现同类客户端超时或 COS 读取长尾,应记录版本、拓扑、慢读与网络指标并重新打开本 issue,或按新证据另行跟踪。

    最终结论:未完成验收。已通过子项:近期同规模 1000 线程回归且未观察到原超时;未验收项:原拓扑和冷缓存网络长尾的匹配复验。根据当前不再复现的观察先关闭,后续复现再跟进。

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions