[4.2] fix: reuse remote backend after early stop - #27785
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed exact head d598e464c597733cf0160019e4c1ac8de1e093b9 against 4.2-dev@635de0535a21807c02ee49f37331406921c7889b. The early-stop path itself is coherent, but the backport has one blocking cancellation-classification gap.
runErr comes from suppressRemoteRunCancelError(s.Proc.Ctx, err), which suppresses any QueryInterrupted/context-canceled result once the pipeline context is done. Unlike the main-line implementation (normalizeScopeRunError(err, pipelineCtx, queryCtx)), it cannot distinguish an internal LIMIT-driven pipeline stop from cancellation of the query context itself. With a real query cancellation, this head therefore sets runErr == nil, skips Proc.Cancel, calls CleanRootOperator as success, calls prepareForLocalCleanup, and allows finishStreamForReuse to ignore the canceled sender context and return the backend through Close(false). Main deliberately keeps that case terminal.
Please preserve the query-vs-pipeline distinction in the 4.2 backport and add the missing control: cancel the query context while RemoteRun is active and assert a terminal cancellation/EventError and poisoned Close(true), alongside the current internal early-stop success/Close(false) case. Substantive errors should remain terminal as well.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head d598e46. Audited the early-stop backend ownership transfer, response termination, cleanup cardinality, pool reuse/generation boundary, and cancellation/error paths (Q1-Q3). The changed tests and green exact-head CI cover the regression without introducing an unbounded wait, retained state, or material hot-path regression. No blocker found.
d598e46 to
72868b9
Compare
What type of PR is this?
Which issue(s) this PR fixes
Issue #27757.
What this PR does / why we need it
WithTimeoutCausedeadline classification and joined-error preservationEventEndonly for a successful internal early stop; publishEventErrorfor terminal cancellation/failureNo wire-format or timeout-default change is introduced. The normal success path retains an immediate nil-error fast path.
Validation
TestSuppressRemoteRunCancelError: passTestIssue27757RemoteRunCancellationClassification: pass-race -count=100: passpkg/sql/compile: passpkg/sql/compileunder-race: passgo vet ./pkg/sql/compile: passgit diff --check: pass