Skip to content

[Bug]: publication retries hide cancellation and pause/cancel behind a stale query error #29670

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues (searched for lastErr and publication cancellation; no matching report found).

Branch Name

codex/quality-29249-lifecycle-20261007 (PR #29663)

Commit ID

a625495

Other Environment Information

  • OS: Linux/amd64
  • Go: 1.27.0; GOMAXPROCS=2; normal and race modes
  • Local package-level reproduction without an external database or network workload

Actual Behavior

After an upstream query returns a retryable error, a context cancellation or ActiveRoutine pause/cancel terminates the retry policy correctly. UpstreamExecutor.execWithRetry then replaces that terminal error with the previous query error stored in lastErr. ExecSQL propagates this incorrect error to its caller.

Executed observations:

  • Cancel the context after the first failed attempt: errors.Is(err, context.Canceled) is false; the returned error is the previous failure.
  • Pause or cancel the routine after a connection-reset failure: the returned error is connection reset rather than task paused/task cancelled.
  • Exactly one query callback executes in these reproductions; this report does not claim data corruption or a demonstrated goroutine hang.

Expected Behavior

Return the terminal error selected by Policy.Do, retaining the existing deliberate ErrNonRetryable-to-retry-limit mapping. Historical operation errors may be retained for diagnostics but must not override cancellation, deadline, or routine termination.

Steps to Reproduce

In the publication package, construct an UpstreamExecutor with retries enabled. Invoke execWithRetry with a callback that returns a retryable connection-reset error and, in that first callback, cancels the parent context or closes the routine's pause/cancel channel. Assert the final error is the respective terminal signal and that the callback executes exactly once. A nil backoff is a supported instance-local option for the routine-transition cases; context cancellation was also reproduced with the default backoff.

The context-cancellation case fails in normal mode. Context, pause and cancel cases all fail their error assertions under race. A temporary control overlay removing only the final lastErr override makes all three pass.

Additional information

Root cause: pkg/publication/sql_executor.go:764-765 on the reported revision returns lastErr ahead of the policy's final err. InternalSQLExecutor already returns the authoritative policy result and does not have this override.

Review evidence: #29663 (review)

The correction and zero/positive attempt-timeout regressions are being included in the existing PR #29663.

Activity

  1. added
    kind/bug
    on Oct 7, 2026
  2. added a commit that references this issue on Oct 7, 2026
    3d796ac
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