Skip to content

[Bug]: CDC persists transient target setup/release failures as permanent table errors #29434

Closed

Description

@LeftHandCold

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

Incident: 5a96035fc792b07b7a28e2f509dc0dcd4236e048.

The relevant CDC code is unchanged at reviewed current main b9013dc6bb058ec74935a62ac3a35f57d13c2f98.

Other Environment Information

  • TKE nightly regression, run 36335119263, CDC job 108722779810.
  • Namespace: mo-main-family-36335119263-1.
  • Source CDC executor CN: nightly-regression-dis-tp-cn-krqql.
  • MO-to-MO CDC, TPCC source tpcc_10, target tke_family_tpcc_sink.
  • Task: tke_family_tpcc_36335119263_1, ID 01a0e500-91c5-799f-a607-e04e3462e1a5.
  • All times below are UTC on 2026-09-27; add eight hours for 2026-09-28 CST.

Actual Behavior

A transient pipeline-setup error is persisted as a non-retryable table error on its first occurrence, and the table detector then fails and stops the entire CDC task. This is not merely slow catch-up or a client convergence timeout.

The decisive table is bmsql_history. The observed sequence is:

UTC Evidence
22:39:15.784 Initial TPCC source/target digest matches for three consecutive checks.
22:40:10.702 through 22:40:30.459 Existing history reader reports target ownership lock poll exceeded 2s on repeated attempts.
22:41:25.047639 Frontend still classifies history's existing lock error as retryable: retry-count=1, max-retry=3.
22:41:47.657886 cdc.frontend.task.add_exec_pipeline_failed, history, with context deadline exceeded\nsql: connection is already closed.
22:41:47.692405 cdc.watermark.update_errmsg_persist, same task/table: retryable=false, retry-count=1, formatted-msg="N:1790548907:internal error: context deadline exceeded\nsql: connection is already closed".
22:42:36.050907 Frontend detects that same permanent history error, age approximately 49 seconds.
22:42:46.383494 cdc.frontend.task.failed_by_permanent_table_error, same task ID and history table.
22:43:18.094 through 22:58:15.358 Post-write TPCC convergence checks remain unchanged and fail.

Observed source/target differences after source writes stop:

Table Source rows Target rows Difference
bmsql_oorder 301286 300992 294
bmsql_order_line 3013886 3010928 2958

These differences establish stopped replication and stale downstream data. They do not prove irreversible source data loss or that replay after recovery would fail.

Expected Behavior

With the task generation still valid and the callback context alive, a transient target setup/connection or advisory-lock release timeout should retire the failed connection and enter the existing bounded retry/rebuild policy. It should not immediately be classified as a permanent schema/data error solely because the returned error lacks a CDC wrapper.

Real schema/configuration errors must remain permanent. Cancellation, ownership loss, ambiguous DDL, and retry exhaustion must keep their distinct safety semantics; this report does not request blanket or unlimited retry.

Steps to Reproduce

The incident is captured in the linked CDC job and correlated service logs. Two smaller component validations target the production ownership-release and pipeline-error classification boundary, without rerunning the full daily workload:

  1. Keep the parent task/callback context live and the generation valid.
  2. Acquire a target lock using the real Executor target-lock path with a sqlmock database.
  3. Make the target RELEASE_LOCK response return a deadline error.
  4. Observe connection discard/close and the joined error returned by ReleaseTargetLock; source inspection confirms sink initialization returns it directly.
  5. Separately, inject that error at NewSinker in the real frontend handleNewTables path. Read the persisted watermark row and exercise GetTableErrMsg on its error metadata.
  6. Keep successful release, explicitly wrapped transient errors, and a genuine permanent SQL error as controls.

Executed on current main b9013dc6 in an isolated macOS arm64 worktree with Go 1.26.4 and matching freshly built CGo libraries. Temporary diagnostic tests were added, without production changes:

env -u LC_TERMINAL -u LC_TERMINAL_VERSION LC_ALL=C LC_CTYPE=C LANG=C \
  .agents/skills/mo-dev/scripts/mo-cgo-test -count=3 -timeout=120s \
  -run '^(TestCDCSetupErrorHarness|TestCDCNewTableSetupErrorClassificationHarness)$' \
  ./pkg/cdc ./pkg/frontend

Both packages passed three repetitions of the behavior assertions, including these controls:

Probe Observed current behavior
Successful RELEASE_LOCK Success, pinned-lock reference cleared.
Real RELEASE_LOCK query returns only context.DeadlineExceeded Production cleanup generates a joined deadline + sql.ErrConnDone, without a retryable CDC wrapper.
Real non-retry setup ExecSQL receives a transport error Returned without a retryable wrapper.
Frontend receives raw joined deadline/closed-connection setup error with live callback Persists N:, ShouldRetry=false, next GetTableErrMsg gate blocks.
Frontend receives syntax error Persists N: and blocks, as expected.
Frontend receives typed retryable setup error Persists R: and permits retry.

These tests reproduce the defect, not a fix. The frontend fixture uses the legacy protocol and a stubbed NewSinker; the two tests are not a full stable-epoch/real-MySQL end-to-end reproduction. The incident's matching task/table logs establish the live stable-task failure. No package-wide test, race test, BVT, or new Daily was run.

Additional information

Confirmed code-level classification gap

At the incident revision:

  1. createMysqlSinker2 returns initialization SQL errors directly. After successful initialization, lines 278-281 likewise return ReleaseTargetLock errors directly.
  2. Executor.releaseTargetLock uses an independent five-second cleanup context. A query error discards the pinned physical session, then joins the query error with sql.Conn.Close()'s error. That result has no retryable CDC wrapper.
  3. handleNewTables setup-error handling correctly excludes obsolete/cancelled callbacks. For a live callback, however, its IsRetryable expression at lines 2905-2909 accepts only four specific CDC wrapper types. A raw or joined deadline/closed-connection error therefore evaluates false.
  4. UpdateWatermarkErrMsg persists this supplied false classification as N:....
  5. The next table discovery invokes failTaskForPermanentTableError, marks the task failed and cancels the remaining readers.

Important evidence boundaries

  • The runtime setup error -> non-retryable metadata -> whole-task failure chain is directly observed, with matching task/table identifiers.
  • A target-lock release deadline can produce this exact error shape through the current production code. The archived logs do not include the individual target SQL/connection identifier for the history setup attempt, so its exact lower-level stalled SQL is not claimed as uniquely proven.
  • The earlier two-second GET_LOCK errors are classified retryably. The decisive history error was not max retry exceeded; it was a different setup error recorded with retryable=false, retry-count=1.
  • cannot release target ownership lock with an active transaction is recorded for district, after history's permanent-error shutdown starts. It must not be substituted for the cause that failed history or used to assert a separate transaction leak without further evidence.
  • The initial target-side latency trigger remains undetermined; this issue is specifically about incorrectly escalating the recoverable setup failure.

Existing issues and regression status

Acceptance boundary

Validate target-release/transport timeout with a live parent context through both sink setup and frontend persistence; it must remain bounded-retryable. Retain checks that syntax/configuration failures remain permanent, lifecycle cancellation does not poison a newer owner, the failed physical connection is discarded, and repeated failures can still exhaust the configured retry policy.

Activity

  1. self-assigned this
    on Sep 29, 2026
  2. added a commit that references this issue on Oct 9, 2026
    a6e19cc
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