Skip to content

fix: preserve root execution errors when JoinMapBuildError wraps cancellation #27646

Closed

Description

@XuPeng-SH

Problem

The multi-table INSERT BVT can return internal error: context canceled instead of the actual execution error that caused the query to fail.

Observed in CI run 32945651664, job 98107580796:

  • Case: test/distributed/cases/dml/insert/multi_insert_schema.sql
  • Row: 86
  • SQL: insert all into conv (id, e) values (id + 10, name) select id, name from src where name = 'delta';
  • Expected: internal error: convert to MySQL enum failed: item delta is not in enum [alpha beta gamma other][12,0,0]
  • Actual: internal error: context canceled

The invalid ENUM value is intentional: this is an unhappy-path test. The query must fail, but it must return the real ENUM conversion error and preserve the multi-table INSERT rollback semantics.

Root cause

The target pipeline raises the real ENUM conversion error and cancels sibling pipelines. The sibling HashBuild/JoinMap dependency then receives context.Canceled.

pkg/vm/message/joinMapDependency.go:NewJoinMapBuildError converts any non-*moerr.Error into moerr.NewInternalErrorNoCtx(err.Error()). For context.Canceled, this loses the cancellation type and cause and turns cleanup fallout into an ordinary internal error. Scope error aggregation can then select this derived error and mask the original execution error.

The relevant sequence in the CI log is:

  1. ENUM conversion error is logged.
  2. joinMapDependency.go logs context canceled.
  3. The frontend returns internal error: context canceled.

Scope / attribution

  • PR #27560 introduced the multi-table INSERT fan-out topology that exposes this race.
  • PR #27636 is not the cause; it changes transaction-timestamp-to-TIMESTAMP conversion and does not touch ENUM or JoinMap error propagation.
  • This is not an OOM, CN crash, or Proxy connectivity failure.

Expected behavior

For the above SQL, the client must consistently receive the ENUM conversion error. context.Canceled from sibling cleanup must remain secondary. The operation must remain atomic and must not leave partial writes in any target table.

Acceptance criteria

  • Preserve cancellation identity/cause when publishing JoinMap build failures.
  • Ensure scope/pipeline aggregation prefers the causal execution error over sibling cancellation fallout, including joined/wrapped errors.
  • Add a regression test covering a multi-table INSERT target conversion failure with a concurrent JoinMap/DEDUP dependency.
  • Run the relevant BVT repeatedly (including Proxy multi-CN mode) and verify deterministic error text and rollback.

Activity

  1. added
    kind/bug
    bvt
    on Aug 26, 2026
  2. self-assigned this
    on Aug 26, 2026
  3. added a commit that references this issue on Aug 26, 2026
    2339b3b
  4. added 3 commits that reference this issue on Sep 17, 2026
    4d09cdb
    9d3c909
    d4bd99c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/stabilitybvtkind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions