Repository navigation
fix(cnservice): bound stale pipeline backend retries - #27528
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head 97c7d7f02be064a7855f4268104cf8400d04b3f0.
[P1] The terminal liveness probe is bypassed by the actual pipeline-stream path, so the stale backend can still survive indefinitely. PipelineClient exposes NewStream, and stream sends set RPCMessage.stream=true. In remoteBackend.doWrite (pkg/common/morpc/backend.go:687-693), liveness tracking explicitly requires !f.send.stream, so stream traffic never establishes pendingSince. On every read timeout, keepDataConnectionAfterProbe (backend.go:1348-1352) sees oldestWritten == 0 and returns true before invoking the new independent control client. An active stream in rb.mu.activeStreams does not participate in this decision. Therefore a blackholed/removed CN with an active pipeline stream follows the same 120-second timeout loop forever; livenessProbeFailureIsTerminal is never reached, and the PR does not close issue #27523 for its primary call path.
I reproduced this deterministically without clock/network flakiness: create a backend with one active stream, a terminal liveness probe that returns endpoint gone, and a read-timeout error. Expected: false/retire and one probe call. Exact-head result: true/keep and zero probe calls.
Please make active stream state participate in the timeout/probe decision (with a generation-safe timestamp/progress contract), or track stream writes/progress explicitly. Preserve legitimately idle backends, but do not classify a backend owning an active pipeline stream as traffic-free. Add both a focused state-machine regression and an end-to-end NewPipelineClient stream test showing that a failed independent ping terminates the old stream/backend generation.
Q1/Q3 otherwise close: the control client is closed on data-client construction failure and normal shutdown, probe contexts are bounded/cancelable, and control/data backend counts remain bounded. The confirmed break is Q2: the active stream wait chain never reaches the newly added probe/termination edge. Existing full morpc/cnclient tests, build, vet, and diff checks pass because current tests exercise unary pending state or only client construction, not stream liveness. I did not wait for CI.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review completed on exact head 358b6a48bbcdfc7d64c2b780a88419954a259cd1.
No blockers. The prior request-changes findings were valid, and this revision removes the problematic control-probe/active-stream timestamp mechanism rather than adding more lifecycle state. Pipeline NewStream now directly bounds both global factory admission and the connect/retry phase for the originally scheduled endpoint. Initial backend creation against a stale CN therefore terminates within a finite Pipeline-specific budget and fails the statement without redirecting.
Validated the retryable RPC-timeout regression, full cnclient and morpc packages, sql/compile consumer, build/vet/diff checks, adaptive focused race stress at count=100, full cnclient race, and a conflict-free merge-tree against latest main. Independent final review also found no blockers. I did not wait for CI.
LeftHandCold
left a comment
There was a problem hiding this comment.
Reviewed exact head 358b6a48bbcdfc7d64c2b780a88419954a259cd1 against PR base main@b284c710e1da8854d6c28b4dfe8531731b7194ab.
No blockers. The Pipeline client now bounds both process-wide factory admission and the subsequent connect/retry phase with the configured per-connect timeout. This closes the initial stale-CN backend-creation hang while keeping the scheduled endpoint fixed and leaving unrelated MORPC clients on their existing policy. I traced the timeout, late factory completion, generation ownership, caller error cleanup, and capacity bounds; Q1-Q3 close without a new lifecycle edge.
Validated focused and full cnclient tests, full morpc tests, compile consumer failure cleanup, build/vet for cnclient, morpc, and compile, adaptive focused race stress at count=100, full cnclient race, diff checks, and a conflict-free merge-tree against latest main. CI was still running at review time.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Backport of #27528 for `4.2-dev`. Related issue: #27523. ## What this PR does / why we need it: - Bounds Pipeline asynchronous backend-creation queue admission by the configured per-connect timeout. - Bounds the subsequent connect/retry phase by the same timeout, so a stale scheduled CN route cannot inherit a potentially day-long SQL context. - Keeps the scheduled CN endpoint fixed: recovery establishes that route within budget or fails the statement; it does not silently redirect work to another CN. - Adds a regression using the retryable RPC-timeout error produced by the backend connect loop. The backport patch-id is identical to the final two-file diff of #27528. ## Validation - `GOWORK=off go list -mod=readonly ./pkg/cnservice/cnclient` - `GOWORK=off go build -mod=readonly ./pkg/cnservice/cnclient` - `GOWORK=off go vet -mod=readonly ./pkg/cnservice/cnclient` - focused `TestPipelineBackendCreateOptionsBoundRetry` - full `./pkg/cnservice/cnclient` tests - focused race stress: `TestPipelineBackendCreateOptionsBoundRetry`, `-race -count=100` - full `./pkg/cnservice/cnclient` race test - full `./pkg/common/morpc` tests - full `./pkg/sql/compile` tests - `git diff --check`
What type of PR is this?
Which issue(s) this PR fixes:
issue #27523
What this PR does / why we need it:
Validation
./pkg/cnservice/cnclientfull tests./pkg/common/morpcfull tests./pkg/sql/compilefull testscount=100) and fullcnclientpackage race testmain