Skip to content

[Bug] Stability (3ebdb25 / 90e3400): After CN roll, some statements hang forever on lock table bind changed (no Exec.Run return); found leak txn flags live sessions #26125

Closed

Description

Environment

Field Value
Cluster mo-stb-main-3ebdb25-202607101119
Namespace mo-stb-main-3ebdb25-202607101119
Image (incident) matrixone:commit-90e3400 (full-stack roll inside the window)
Endpoint 10.222.6.254:6001
Artifact root /data1/stability-test/29066558663_3ebdb25
Workloads TPCC, sysbench, TPCH, fulltext/vector (ivf_dml_scenarios)
Analysis window 2026-07-23 10:00 CST → 2026-07-24 ~10:40 CST (~24h; roll is inside the window)

Scope: After a CN / full-stack roll, a small subset of statements already on the execution path never return during a LockService lock table bind changed storm (stuck after Exec.Build completes or after ranges), while the client blocks until query_result_timeout / wait_timeout (~24h). Peer statements on the same table correctly fail after a 10s retry budget. Leak-check reports those still-COM_QUERY aged txns as found leak txn (unique=2) → release gate FAIL.

Out of scope / not this issue:

Summary

Signal Value Interpretation
Roll time 07-23 11:38–11:42 CST log/DN/proxy/CN restart steps; CN qr22s → swzgh
Hung #1 TPCH q10 txn=54298e79…e6ef After Exec.Build @11:40:15 → 23h+ with no Exec.Run completion
Hung #2 vector UPDATE test_vectors txn=442f9f6c…cf8a Silent after ranges @11:41:22; tbl-id 318606
Same-second peer fate 11:41:32 lock retry budget exhausted / lock table bind changed Same table other INSERT/UPDATE fail correctly
Historical q10 45–120s Same artifact run.log; 23h = hang, not slow query
Client mysql in tcp_recvmsg; session wrapped by timeout 86400s No statement-level timeout
Server timeouts have_statement_timeout=off, max_execution_time=0, query_result_timeout=24 Hang can last ~24h
Leak unique 2 (do not count log lines) Leak-check every ~10min on both CNs
wait-active 0; commit after roll ~150–200/s Not a txn-create stall

MatrixOne defect: When LockService bind becomes invalid during a roll, the error-return path is incomplete: some waiters/pipelines finish “10s retry → error”, while statements already in Exec.Run / lock wait get neither context cancel nor error until the client times out. Leak-check also conflates “aged statement with a live session” with “disconnect orphan txn”.

Timeline (CST)

Time Event Evidence
11:38–11:42 Full-stack roll to 90e3400; Starting shutdown; failed to keep lock table bind ×19 Loki + kube_pod_container_status_restarts_total step
11:39:59 CN swzgh start pod startTime
11:40:10 TPCH run.log: start q10 artifact
11:40:14–15 New connection accept; Exec.Build 1.62s; then this txn has only leak logs, no Run completion Loki 019f8d0f-3d89… / txn-id
11:41:22 Vector new connection (55wzr); txn.table.ranges.log blocks=456 (55wzr + swzgh) Loki
11:41:32 Same table 318606: lock table bind changed + lock retry budget exhausted for backend availability error (retry-budget 10s) → other vector statements ERROR Loki lockop/lock_op.go
~12:00+ Both hung txns start periodic found leak txn Loki
→ +23h processlist still same COM_QUERY; TPCH run.log stuck on q10; client still ESTAB + recv show processlist / /proc/.../stack

Evidence

A. TPCH — Build then no Run

11:40:15  cn-swzgh  frontend/mysql_cmd_executor.go
  msg="time of Exec.Build : 1.619007149s"
  session_id=019f8d0f-3132-7ea5-8668-4923f89521ba
  statement_id=019f8d0f-3d89-72c1-b153-52004150213f
  txn-id=54298e79cad2cfb818c4ce238373e6ef

# For this txn-id after Build until analysis time: non-leak logs = 1 (Build only); rest are found leak txn

Baseline (same run.log, before roll):

query q10 has be executed successfully, and cost: 45059–120349   # ~45–120s

B. Vector — silent after ranges; peers on same table fail-return

Hung txn ranges:

{"msg":"txn.table.ranges.log","name":"test_vectors","tbl-id":318606,
 "txn":"442f9f6cddb96da118c4ce357ba8cf8a/Active/...",
 "blocks":456,"cost":"593.135µs"}

Same second (other txns, correct failure):

{"caller":"lockop/lock_op.go:1120",
 "msg":"lock retry budget exhausted for backend availability error",
 "table-id":318606,
 "error":"lock table bind changed",
 "retry-budget":"10s",
 "txn-id":"54298e79cad2cfb818c4ce23837482b5"}
{"caller":"frontend/txn.go:64","msg":"lock table bind changed",
 "session_info":"... account vector_test:admin ..."}

C. processlist (still present at analysis time)

conn_id account query_start (UTC) info
11188054 tpch_test 2026-07-23 03:40:14 TPCH q10 SELECT …
11188783 vector_test 2026-07-23 03:41:22 UPDATE test_vectors SET embedding=… WHERE id='uqjmox…'

D. Timeout config (amplifies hang window)

have_statement_timeout = off
max_execution_time     = 0
query_result_timeout   = 24
wait_timeout           = 86400

Root cause

Mechanism

CN / LockService roll
    ↓
lock table bind changed (keeper / peer CN down)
    ↓
Path A (majority): lockop retry ≤10s → error to client → retryable     ← OK
Path B (minority): past Build / ranges, in Run or lock wait
    → bind change does not cancel pipeline / waiter
    → never returns                                                     ← defect
    ↓
Client has no statement timeout → blocks ~24h
    ↓
leak-check reports found leak txn by txn age (session still Active)

Why this is a MatrixOne bug (not “it would finish without kill”)

Observation Implication
Same table, same second: most statements fail in 10s, two show 23h with no progress Fail path exists but does not cover all execution stages
Historical q10 ~1min, now 23h + no Exec.Run Hang, not a slow query
processlist still same session_id / txn_id Not a #24766 disconnect orphan; execution hang
wait-active=0, commit healthy Not a global txn-scheduler death

Expected vs actual

Expected Actual
Bind change → all related waiters/pipelines fail or cancel Some statements hang forever
OLAP/DML have a reasonable statement timeout max_execution_time=0; hang can last ~24h
found leak txn ≈ disconnect-without-Rollback orphans Aged statements with live sessions also reported as leak
After roll, TPCH/vector recover within minutes TPCH stuck on q10; one vector worker stuck; leak unique=2

Proposed fixes

P0 — MO: bind change must reach Run / lock wait

  • pkg/sql/colexec/lockop / LockService waiter: for any txn holding or waiting on the affected table-id bind, on lock table bind changed uniformly error or context-cancel; do not allow silent block past the retry budget.
  • Exec.Run / pipeline: on CN roll or lock-bind invalidation, propagate cancel into in-flight pipelines (align with existing Starting shutdown path; cover the window where a query just started on a new CN while the old bind is already invalid).

P1 — MO: statement timeout + leak classification

  • Default or configurable max_execution_time / statement timeout (suggest soak OLAP ≤30min, OLTP DML ≤ a few minutes); on timeout → kill query + Rollback.
  • Leak-check: distinguish disconnect orphans vs aged statements still in COM_QUERY; for the latter, alert and optionally auto-cancel (e.g. after 1h) instead of log-only.

P2 — Operator / soak scripts

  • CN drain: reject new SQL and cancel in-flight work before shutdown.
  • TPCH: replace session-wide timeout 86400s with per-statement timeout; set pymysql read_timeout for vector.
  • Post-roll runbook: processlist rows with query_start older than N minutes → KILL <conn_id> (ops mitigation, not the root fix).

Verification

  1. While TPCH q10 / UPDATE test_vectors is running, trigger a CN roll or lock-bind switch: expect error or cancel within seconds to ~10–20s; must not still be COM_QUERY with no Exec.Run after 20+ minutes.
  2. Within 30min after roll: found leak txn unique=0 (or only short-lived then cancelled).
  3. TPCH run.log advances past q10; vector workers do not permanently stick on a single UPDATE.

Related

Activity

  1. ghost added this to the MO-202607 milestone on Jul 24, 2026
  2. ghost added
    kind/bug
    on Jul 24, 2026
  3. ghost added theissue type on Jul 24, 2026
  4. ghost added
    severity/s0
    on Jul 24, 2026
  5. aptend commented on Jul 24, 2026

    @aptend
    Contributor

    Independent follow-up and issue linkage

    I re-checked the two stuck transactions against the IDC Loki data and the leakcheck goroutine profiles. The hang is real, and the roll/draining window is an important trigger, but the available evidence does not connect either stuck transaction to an ErrLockTableBindChanged lock wait.

    For the full 24-hour window, exact txn-id searches returned:

    • TPCH q10 54298e79...73e6ef: 146 records (141 leak reports, 1 Exec.Build), with 0 lock table bind changed, 0 lock retry, and 0 Exec.Run completion.
    • vector UPDATE 442f9f6c...ba8cf8a: 146 records (141 leak reports, 2 range logs), with 0 lock table bind changed, 0 lock retry, and 0 Exec.Run completion.

    The same-table/same-second statements that exhausted the 10-second lock retry budget were different transactions. They establish that a bind-change storm existed, but do not establish that these two transactions entered that error path.

    The goroutine evidence points to two already-known pipeline defects that were not included in incident image 90e3400:

    1. TPCH q10: the frontend is blocked in Compile.runOnce waiting for scope results; child scopes are blocked in MergeRun, with many workers in shuffle.(*Shuffle).Call for the full query lifetime. This matches the nested local-shuffle wait cycle tracked in [Bug] TPCH Q16 hangs indefinitely: Shuffle execution engine deadlock in waitBatchOrEnd (TPCH 100G stuck for 15+ hours) #25922 and addressed by fix: prevent nested local shuffle deadlocks #26055 (0d7eeb38) and the execution-layer follow-up fix: decouple local shuffle producers from consumers #26097 (27cf9a7e).

    2. vector UPDATE: connection 11188783 was accepted by 55wzr about 26 seconds after that CN logged Starting shutdown. The coordinator is blocked in Compile.runOnce; one remote scope is blocked in receiveMessageFromCnServerIfConnector. The apparent LockOp stack is actually waiting for upstream data in PipelineSignalReceiver -> Merge, not inside LockService.Lock. On swzgh, the corresponding remote-server pipeline is also blocked in PipelineSignalReceiver / nested RemoteRun -> MergeRun. This is consistent with the remote dispatch receiver placement/lifecycle class tracked in [Bug] 30s remote dispatch watchdog can falsely fail slow receiver registration #25816 and fixed by fix(pipeline): normalize retained dispatch receiver routes #26025 (ebd05ba52). The profile does not expose receiver UUID/FromAddr, so the exact fix(pipeline): normalize retained dispatch receiver routes #26025 subcase is a high-confidence match rather than a fully proven identity.

    Therefore the recommended next step is validation, not another speculative LockService change:

    If the issue reproduces on that image, it should remain open with the new goroutine/receiver evidence and be treated as a remaining shutdown/pipeline cancellation defect. If it does not reproduce across repeated roll windows, the two observed hangs are best considered covered by the linked shuffle/remote-dispatch fixes. The separate hardening items remain valid: a draining CN should stop accepting new SQL, in-flight pipelines need bounded cancellation, and found leak txn should distinguish live long-running statements from disconnected orphan transactions.

  6. assigned and unassigned on Jul 24, 2026
  7. Repository owner unassigned on Jul 24, 2026
  8. ghost assigned on Jul 24, 2026
  9. aptend commented on Jul 27, 2026

    @aptend
    Contributor

    Root-cause update: same terminal-wakeup defect as #26202

    The canonical root-cause explanation is in this #26202 comment; it is not repeated here.

    For the f3752fce3 main reproduction, the new evidence aligns with that mechanism:

    • f3752fce3 already contains fix(pipeline): normalize retained dispatch receiver routes #26025, fix: prevent nested local shuffle deadlocks #26055, and fix: decouple local shuffle producers from consumers #26097, so this reproduction is not explained by those fixes being absent.
    • On coordinator CN 55wzr, both vector UPDATE sessions remain blocked in Compile.runOnce; a child scope is blocked in messageSenderOnClient.receiveMessage, with local children blocked in PipelineSignalReceiver / Merge.
    • On peer CN pg95j, the two execution trees present in the 10:11/10:12 goroutine dumps are no longer present by 10:20, while the coordinator remains blocked. This is consistent with remote execution/cleanup completing without the coordinator-side pipeline receiving a usable terminal wakeup.
    • The same f3752fce3 cluster independently logged live terminal-delivery failures such as connector cleanup timed out sending terminal End/Abort signal with a backpressured Ch2 (channel_len=13, channel_cap=14). Those warning lines belong to another transaction, so they prove the failure condition exists in this cluster but are not claimed as the direct log record for these two UPDATE transactions.

    Therefore the current root-cause classification for the main reproduction is:

    A residual PipelineEdge/PipelineSignalReceiver lifecycle hole: terminal state may be recorded while its typed terminal signal is not fully delivered through a backpressured Ch2; receivers that only wait on Ch2 and do not observe PipelineEdge.Done() can wait forever.

    This supersedes the earlier “likely covered by #26025” conclusion for the vector UPDATE. It is not a LockService wait, and it is not the 1–8 hand-written select count.

    The same logical patch as #26202 should be forward-ported to main. Validation for this issue should rerun the vector workload across CN/full-stack rolls and require the UPDATE to finish or return an error within a bounded interval, with no persistent live-session found leak txn entries.

  10. assigned and unassigned on Jul 28, 2026
  11. ghost closed this as completedon Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugseverity/s0

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions