Skip to content

[Bug]: TPCC 1000W/1000 terminals cross-CN pipeline timeout returns 20502 #28895

Closed

Description

@Ariznawlll

Description

In the normal main TKE TPCC 1000 warehouses / 1000 terminals workload, several independent STOCK_LEVEL requests received ErrorCode: 20502, backend connection closed. Server logs show a five-second failure while a TP CN creates a pipeline MORPC backend to another live TP CN. The incident also affected CN heartbeat, lockservice, task service and log-service requests in the same time window.

Environment

Steps to reproduce

  1. Deploy the above main commit using the TKE nightly distributed topology.
  2. Prepare TPCC data for 1000 warehouses.
  3. Run the 1000-terminal TPCC transaction phase for five minutes with the standard regression workload mix.
  4. Preserve all TP CN, DN, LogService and Proxy logs from at least 60 seconds before the first client error through recovery.

Actual behavior

The 1000-terminal phase started at 18:36:57. The following service degradation preceded the client-visible SQL failures:

18:37:01  tp-cn-jqkcn (10.143.100.107): CN heartbeat -> context deadline exceeded
18:37:05  tp-cn-59s9b: lockservice failed to validate transactions -> backend connection closed
18:37:08  tp-cn-drn42: remote unlock / ISCP transaction finish -> context deadline exceeded
18:37:10  log-2: query cron task -> context deadline exceeded
18:37:13  tp-cn-59s9b pipeline client -> 10.143.100.107:6002
            backend auto-create waited 5.000s
            dial tcp4 10.143.100.107:6002: i/o timeout
18:37:13  five TPCC STOCK_LEVEL executions return 20502 backend connection closed
18:37:24+ tp-cn-jqkcn: task SQL, logger writes and frontend sessions -> context canceled / routine closed or busy

The exact server-side request failure was logged at process/process.go:766 as Failed to newMessageSenderOnClient sql=execute __mo_stmt_id_24, err=backend connection closed; __mo_stmt_id_24 is the TPCC STOCK_LEVEL query against bmsql_stock. The initiating MORPC error was:

auto-create backend timed out: waited=5.000072847s timeout=5s
dial tcp4 10.143.100.107:6002: i/o timeout
connect to remote failed: rpc timeout

The client recorded exactly five unexpected STOCK_LEVEL failures at the same second. The workload completed its five-minute duration, but the runner correctly failed because benchmarksql-error.log contained those unexpected database errors.

Expected behavior

A supported TPCC 1000-terminal workload must not expose internal cross-CN MORPC connection creation/timeout failures as 20502 to client transactions. A transient slow connection or a delayed peer must be bounded and recovered/isolated without cancelling unrelated in-flight TPCC requests.

Stability and controls

  • Reproducer observed: 1/1 run so far. Repetition is required to establish rate and commit range.
  • Controls in the same job passed: TPCC 10W/10T, 10W/100T, 100W/100T and 100W/1000T.
  • TPCC consistency verification completed successfully after the failing phase; no persistent data inconsistency was found.
  • Pod restart count was zero for all TP CNs in the incident window. No OOM event or CPU CFS throttling was observed.

Evidence

  • Client errors: five STOCK_LEVEL requests at 18:37:13, each with 20502 backend connection closed.
  • tp-cn-59s9b could not establish a MORPC pipeline backend to tp-cn-jqkcn:6002 within five seconds.
  • The same window contains independent lockservice, taskservice, CN-heartbeat and LogService deadline errors, so this is not a malformed TPCC statement or a test assertion issue.
  • tp-cn-jqkcn had many FileService S3 read slow events around the onset (roughly 0.8-2.2 seconds). This is correlation only, not a confirmed root cause.

Code analysis

This is related by symptom, but not proven duplicate of #26475. #26475 was fixed by #26473 and that merge is already contained in c61ed374. The previous incident was a lockservice local backend-create timeout at a 500 ms boundary; this incident is a five-second pipeline-client dial timeout to port 6002 during query execution. The current failure may therefore be an uncovered MORPC/pipeline availability path or a new regression.

The direct initiating component is still unproven: the evidence does not distinguish a delayed/unavailable tp-cn-jqkcn listener, network-path disruption, FileService-induced service stall, or another MORPC lifecycle transition.

Regression coverage

The TKE nightly TPCC 1000W/1000T case already detects this failure. After a product fix, rerun this same workload repeatedly and require zero 20502, zero CN heartbeat/lockservice timeout burst, and a successful consistency check. Preserve per-CN MORPC backend-create/connection metrics and logs for any recurrence.

Related

Activity

  1. added
    kind/bug
    on Sep 15, 2026
  2. self-assigned this
    on Sep 15, 2026
  3. daviszhen commented on Sep 15, 2026

    @daviszhen
    Contributor

    Follow-up analysis: confirmed failure path and next actions

    I correlated the issue evidence, the exact code at c61ed374a8, the raw TPCC job log, related incidents, and the previous successful nightly.

    Confirmed failure path

    1. tp-cn-59s9b tried to create a Pipeline MORPC backend to tp-cn-jqkcn at 10.143.100.107:6002.
    2. The TCP connection attempt did not complete within five seconds and returned dial tcp4 ... i/o timeout.
    3. Pipeline config uses the same TimeOutForEachConnect value for the transport connect timeout and backend auto-create wait budget. The default is five seconds. Consequently, one full-length dial can consume the complete recovery budget, leaving no meaningful second attempt:
      • const (
        // TODO: need to find out why rpc timeout, or move heartbeat check to another way.
        defaultRPCTimeout = 120 * time.Second
        dfMaxSenderNumber = 100000
        dfConnectTimeout = 5 * time.Second
        dfClientReadBufferSize = 1 << 10
        dfClientWriteBufferSize = 1 << 10
        )
      • func pipelineBackendCreateOptions(cfg *PipelineConfig) []morpc.ClientOption {
        // A scheduled Pipeline scope is pinned to one remote CN. Bound both global
        // factory admission and all connect/retry attempts for that fixed address so
        // a stale cluster-service route fails the statement instead of inheriting a
        // potentially day-long SQL context. The existing per-connect timeout bounds
        // each of the two wait phases, so the total wait is finite and at most twice
        // that value. It is always positive after cfg.fill().
        return []morpc.ClientOption{
        morpc.WithClientAutoCreateQueueWaitTimeout(cfg.TimeOutForEachConnect),
        morpc.WithClientAutoCreateWaitTimeout(cfg.TimeOutForEachConnect),
        }
      • func (rb *remoteBackend) resetConn() error {
        start := time.Now()
        defer func() {
        rb.metrics.connectDurationHistogram.Observe(time.Since(start).Seconds())
        }()
        wait := time.Second
        sleep := time.Millisecond * 200
        for {
        if !rb.running() {
        return backendClosed
        }
        select {
        case <-rb.ctx.Done():
        return backendClosed
        default:
        }
        rb.logger.Debug("start connect to remote", rb.logFields()...)
        rb.closeConn(false)
        rb.metrics.connectCounter.Inc()
        err := rb.conn.Connect(rb.remote, rb.options.connectTimeout)
        if err == nil {
        rb.logger.Debug("connect to remote succeed", rb.logFields()...)
        // Transport-progress evidence belongs to one physical connection.
        // Never carry a stalled old-generation latch onto a fresh socket.
        rb.resetDataProgress()
        rb.activeReadLoop(false)
        return nil
        }
        rb.metrics.connectFailedCounter.Inc()
        // only retry on temp net error
        canRetry := false
        if ne, ok := err.(net.Error); ok && ne.Timeout() {
        canRetry = true
        rb.metrics.observeBackendError(rb.remote, "connect", err)
        }
        rb.rateLimitLogger.Error("connect-retry",
        "init remote connection failed, retry later",
        append(rb.logFields(), zap.Bool("can-retry", canRetry), zap.Error(err))...)
        if !canRetry {
        err = moerr.NewBackendCannotConnectNoCtx(err)
        rb.metrics.observeBackendError(rb.remote, "connect", err)
        return err
        }
        duration := time.Duration(0)
        for {
        time.Sleep(sleep)
        duration += sleep
        if time.Since(start) > rb.options.connectTimeout {
        err := moerr.NewRPCTimeoutNoCtx()
        rb.metrics.observeBackendError(rb.remote, "connect", err)
        return err
        }
    4. MORPC admits at most one queued/in-flight factory call for the same remote generation and coalesces concurrent demand on that state. The five simultaneous STOCK_LEVEL failures are therefore consistent with one failed backend-create state fanning out to five waiters, rather than five independent TCP failures:
      • // triggerCreateAtGenerationLocked admits at most one queued or in-flight
        // factory call for a remote generation. The caller must hold c.mu.
        func (m *clientGCManager) triggerCreateAtGenerationLocked(
        c *client,
        backend string,
        generation *backendGeneration,
        ) (*backendCreateState, bool) {
        if generation == nil || c.mu.closing || c.mu.closed ||
        c.mu.backendGeneration[backend] != generation ||
        !c.canCreateLocked(backend) {
        return nil, false
        }
        if pending := c.mu.creating[backend]; pending != nil {
        // An existing request for this generation already represents the
        // caller's demand. A different generation must never be coalesced.
        return pending, pending.generation == generation
        }
        m.mu.RLock()
        defer m.mu.RUnlock()
        if m.stopping {
        return nil, false
        }
        pending := newBackendCreateState(generation, m.createCtx)
        c.mu.creating[backend] = pending
        select {
        case m.createC <- createRequest{
        c: c,
        backend: backend,
        state: pending,
        }:
        return pending, true
    5. ErrBackendCreateTimeout currently reuses ErrBackendClosed, so the specific pre-dispatch creation timeout is flattened into client error 20502:
      • // ErrBackendCreateTimeout indicates that auto-create wait timeout exceeded.
        // This typically means backend creation or recovery is too slow.
        // This is a boundary condition error (NoCtx + Counter for monitoring).
        // Uses ErrBackendClosed code for compatibility with existing error handling.
        ErrBackendCreateTimeout = moerr.NewBackendClosedNoCtx()
    6. The failure occurs in NewStream, before sendPipeline, so this remote scope had not yet sent its execution payload:
      • // generate a new sender to do send work.
        sender, err = newMessageSenderOnClient(
        s.Proc.Ctx,
        s.Proc.GetService(),
        s.NodeInfo.Addr,
        s.Proc.Mp(),
        c.anal,
        )
        if err != nil {
        c.proc.Errorf(s.Proc.Ctx, "Failed to newMessageSenderOnClient sql=%s, txnID=%s, err=%v",
        c.sql, c.proc.GetTxnOperator().Txn().DebugString(), err)
        return nil, err
        }
        sender.proc = s.Proc
        // Capture the execution-attempt sink, rather than looking it up from proc
        // when the terminal message arrives. Retry/reuse can replace proc.WarningSink
        // before an old RPC callback is delivered; a closed captured sink then drops
        // that stale callback instead of publishing it into the new attempt.
        sender.warningSink = s.Proc.GetWarningSink()
        debugMsg := ""
        _, sub_sql, exist := fault.TriggerFault("inject_send_pipeline")
        if exist {
        if strings.Contains(c.sql, sub_sql) {
        debugMsg = fmt.Sprintf("inject_send_pipeline: client2server,compile = %p", c)
        }
        }
        if err = sender.sendPipeline(scopeEncodeData, processEncodeData, withoutOutput, maxMessageSizeToMoRpc, debugMsg); err != nil {
        return sender, err

    The job completed 147,106 transactions with exactly five errors and then passed consistency verification. This bounds the observed impact to transient availability; there is no data-corruption evidence.

    Root-cause assessment

    The immediate TCP connect failure is proven. The component that first caused it is not.

    The strongest current classification is a transient target-CN/node/network liveness degradation. CN heartbeat, lockservice, remote unlock, task service, and LogService deadlines occurred in the same window, so this is not a malformed STOCK_LEVEL statement or a prepared-statement defect.

    The leading product-level hypothesis to test is Pipeline connection/session pressure at the target listener or node network stack:

    This is a hypothesis, not a proven root cause. FileService S3 slow reads may amplify general resource pressure, but user-space S3 latency does not directly explain a TCP handshake timeout without an intermediate mechanism such as listener backlog saturation, FD pressure, scheduler/resource starvation, or network packet loss.

    This also does not currently look like a direct new MORPC behavior regression. The previous day's identical 1000W/1000T step passed on a68a200c0bfb0c18f1b7f49d26b20b8d0d9b017f:
    https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34764591964/job/103766317397

    Between that revision and c61ed374a8, the only MORPC production-code change was #28697, which added the underlying connect error to the terminal log and explicitly preserved propagation/retry behavior. One passing run and one failing run are insufficient to establish a regression range.

    Next actions

    1. Prove or reject create-state fan-out. For the incident/reproduction window compare:

      • mo_rpc_backend_auto_create_timeout_total{name="pipeline-client"}
      • mo_rpc_backend_auto_create_timeout_event_total{name="pipeline-client"}

      A delta of five request timeouts versus one distinct event would confirm one backend creation failure affected five waiters.

    2. Capture the missing target-side evidence at one-second resolution:

      • mo_rpc_server_session_size{name="pipeline-server"}
      • mo_rpc_backend_pool_size{name="pipeline-client"}
      • mo_pipeline_stream_connection{type="living"}
      • backend create/connect/error counters and connect latency
      • listener ListenOverflows / ListenDrops, SYN_RECV, ESTABLISHED and TIME_WAIT sockets
      • process FD usage and limits, conntrack/CNI drops, TCP retransmits
      • CPU saturation/run queue, GC pauses, memory working set/PSI, goroutine count, and FileService concurrency/latency
    3. Reproduce on both the exact SHA and latest main. Run the same 1000W/1000T stage repeatedly; 1/1 establishes the incident but not its rate. Preserve source/target CN identity and the first server-side transition for every failure.

    4. Product hardening after evidence:

      • give backend-create timeout a distinct structured error and retain the dial cause instead of exposing generic 20502;
      • separate per-dial timeout from total backend-create/recovery budget so a single dial cannot consume the whole budget;
      • add bounded, fair, context-aware active Pipeline connection admission per remote CN;
      • permit bounded retry only for a specifically classified pre-dispatch failure. Redirecting to another CN must happen through Compile/Scheduler replanning, not transparent MORPC address substitution.
    5. Acceptance: repeated 1000W/1000T runs with zero unexpected 20502, bounded Pipeline connection/session counts, no listener overflow/drop burst, successful consistency checks, and a fault-injection case showing that a delayed/unreachable :6002 endpoint terminates or recovers within a bounded contract without cancelling unrelated work.

    Related capacity/lifecycle history: #25690, #25691, and #25713. This incident remains distinct from #26475, whose initiating failure was a 500 ms lockservice backend-create path rather than a five-second Pipeline TCP dial.

  4. daviszhen commented on Sep 15, 2026

    @daviszhen
    Contributor

    TPCC rerun results

    We reran .github/workflows/nightly-regression-tke-new.yaml with Test_list=tpcc, Repo=matrixorigin/matrixone, no Commit_Batch or Concurrent_Test_List, and kept the runs serialized by the workflow concurrency group.

    Exact incident commit

    c61ed374a8a6daebc4e753a928cb63c584addb4c was run three times. All three runs completed successfully, and the tpcc1000.1000 target stage passed:

    • Run 984 — target window 06:57:34–07:04:24 UTC
    • Run 988 — target window 08:03:09–08:09:35 UTC
    • Run 989 — target window 09:03:22–09:09:49 UTC

    Main control runs

    The three runs were dispatched with Branch=main as requested. Since main advanced during the sequence, they did not all use the same commit:

    • Run 991 — b347a62a30719cf3f2c8ca5a2da0dcfb11639f8c; target stage passed, overall run passed.
    • Run 992 — b347a62a30719cf3f2c8ca5a2da0dcfb11639f8c; target stage passed, but the overall run failed in the post-test result checker because the 10x10 tpmC baseline check reported 3556.34 versus 4903.89 previously (more than 25% lower). This was not a tpcc1000.1000 load failure or a 20502 backend connection closed failure.
    • Run 993 — 20937392e1b9e951ebc40268e31b61a854cab09f; target stage passed, overall run passed.

    Conclusion

    The original c61ed374 run reproduced the workload successfully in all three attempts. The issue's reported cross-CN Pipeline/MORPC timeout and client-visible 20502 error were not reproduced in these reruns. The target 1000W/1000T stage completed successfully in all six runs.

    The GitHub workflow evidence artifacts and run logs are retained with each run. CN/network/MORPC time-series metrics were not exported as a separate Grafana snapshot in this rerun, so the absence of a reproduced failure should not be interpreted as proof that the underlying transient trigger is impossible.

    For a strict main control, the next comparison should pin one exact main SHA for all three repetitions instead of using the moving main branch.

  5. daviszhen commented on Sep 16, 2026

    @daviszhen
    Contributor

    回归测试

  6. Ariznawlll commented on Sep 16, 2026

    @Ariznawlll
    CollaboratorAuthor

    观察几天

  7. Ariznawlll commented on Sep 18, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论:通过,Issue 可关闭。

    修复提交 9d5cc76(PR #28922)已于 2026-09-15 合入 main。该修复将 Pipeline 单次 TCP 连接超时与总 backend-create/retry 预算分离:单次连接按 1 秒尝试,但仍受原有 5 秒总预算约束,因此第一次 dial 超时不会耗尽全部重试机会并直接向 TPCC 返回 20502。PR 同时加入了首个 dial 超时、后续重试成功的回归测试。

    修复后的 main TKE TPCC 1000W/1000 terminals 已连续两轮通过,且所用 MatrixOne commit 均包含该修复:

    两轮目标阶段均未再出现 20502 backend connection closed。原始故障涉及的目标 CN/节点网络或监听端瞬态退化没有被单独复现和归因;若后续出现新的跨 CN dial 超时,应以新的环境证据单独跟踪。

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