Skip to content

fix(cnservice): preserve pipeline connect retry budget - #28922

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
daviszhen:codex/issue-28895-pipeline-recovery
Sep 15, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
daviszhen:codex/issue-28895-pipeline-recovery

Conversation

@daviszhen

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #28895

What this PR does / why we need it:

The TPCC incident exposed a timeout-budget coupling in Pipeline backend creation: the same default 5-second value was passed to each goetty TCP Connect call and used as the total MORPC backend connect/retry window. A single i/o timeout could therefore consume the entire recovery window. The retry loop existed, but had no meaningful time left for another connection attempt; concurrent Pipeline streams coalesced on that one failed create state and surfaced 20502 together.

This change:

  • separates one TCP attempt timeout from the total backend connect/retry timeout;
  • keeps generic MORPC behavior backward compatible unless the new option is set;
  • configures Pipeline attempts to 1 second inside the existing 5-second total budget, capped when a smaller total is configured;
  • uses one monotonic deadline to cap the final attempt and retry sleep, and lets backend cancellation interrupt retry sleep;
  • adds a regression test in which the first dial times out and the second succeeds within the same total budget, plus Pipeline configuration bounds tests.

The scheduled remote CN remains fixed and the existing bounded failure contract from #27528 is preserved: this does not reroute a dispatched scope or extend the backend recovery budget. Persistent peer/network outages still fail within the configured bound. The lower-level trigger of the incident (target listener, node/network degradation, or connection pressure) still needs TKE metrics to distinguish; this PR fixes the confirmed client-side loss of retry opportunity.

Validation

  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/common/morpc ./pkg/cnservice/cnclient
  • focused regression tests with -count=5
  • focused regression tests with -race
  • go vet ./pkg/common/morpc ./pkg/cnservice/cnclient
  • git diff --check

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review of exact head 5c71ad9cc73b4602c1c37fec2eb41da1a32f1dee: no blocking findings.

Unhappy-path audit:

Layer Q1: cleanup ownership Q2: wait termination Q3: growth bound
Pipeline client client owns the published backend queue and factory waits retain their configured bounds per-remote backend cap remains unchanged
auto-create manager canceled/late successful creates retain and close their late backend before releasing the slot caller context, create-state completion, queue deadline, and factory deadline all wake waiters create queue is bounded and factory concurrency is fixed at four workers
remote backend / goetty each retry disconnects the prior session; terminal/late-result paths close the backend one monotonic deadline caps each dial and retry sleep; backend cancellation interrupts sleep; net.DialTimeout bounds an in-flight attempt retry timers are scoped and legacy dial goroutines remain bounded by the four create slots

I also checked configuration clamping, default compatibility, publication/generation races, and the exact first-time-create versus reconnect paths. Validation on this head: make thirdparties; focused regressions with -count=1 and -count=10; focused -race; complete go test -count=1 -timeout=180s ./pkg/common/morpc ./pkg/cnservice/cnclient; and git diff --check. All passed. Exact-head required CI, Ubuntu UT, coverage, SCA, Proxy BVT, and pessimistic Compose BVT are green.

@mergify

mergify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 medium deep review at exact head 5c71ad9\n\nP2 — The recovery test has only 100 ms of scheduling tolerance.\nIn pkg/common/morpc/backend_test.go:2676-2681, resetConn() allows 1150 ms, while the fake first dial sleeps 50 ms and production performs five 200 ms retry waits. More than 100 ms of accumulated scheduling delay can make the test fail even when retry-budget preservation is correct. Control elapsed time and retry waiting through an injected clock/wait mechanism while preserving assertions for first-attempt timeout, second-attempt success, and total-budget enforcement; increasing the deadline alone keeps the scheduling dependency.\n\nExact-head CI and owning-package race selections were green, but this test remains timing-sensitive.

@daviszhen

daviszhen commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed in 9168431. resetConn now uses an injected clock and retry-wait hook (with real-time production defaults), so the recovery test has no wall-clock scheduling dependency. The test deterministically verifies a 50 ms first-attempt timeout followed by a successful second attempt after the full 1 s retry wait ([50ms, 50ms], 1.05 s virtual elapsed). I also added a total-budget case that verifies the final attempt is clipped to the remaining 25 ms and returns ErrRPCTimeout exactly at 1.075 s.

Validation:

  • go test ./pkg/common/morpc -count=1
  • go test -race ./pkg/common/morpc -run 'TestBackendConnectAttemptTimeout(RecoversOnRetry|HonorsTotalBudget)$' -count=20

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 medium deep re-review APPROVE at exact head 891a4c3\n\nAll seven changed files reviewed; the earlier timing blocker is resolved by deterministic clock/wait injection, with recovery and total-budget assertions preserved. Correctness, concurrency, lifecycle, liveness, resource bounds, compatibility, and test closures revealed no blocking regressions. Exact-head CI and author validation passed.

@mergify mergify Bot added the queued label Sep 15, 2026
@mergify

mergify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-15 16:10 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-15 16:13 UTC · at ebce26c080d14cd175d4f1b3d6eea365ed4d74cc

This pull request spent 3 minutes 38 seconds in the queue, with no time running CI.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Reason

Pull request #28922 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 9d5cc76 into matrixorigin:main Sep 15, 2026
20 of 21 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 15, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…28922)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#28895

## What this PR does / why we need it:

The TPCC incident exposed a timeout-budget coupling in Pipeline backend
creation: the same default 5-second value was passed to each goetty TCP
`Connect` call and used as the total MORPC backend connect/retry window.
A single `i/o timeout` could therefore consume the entire recovery
window. The retry loop existed, but had no meaningful time left for
another connection attempt; concurrent Pipeline streams coalesced on
that one failed create state and surfaced 20502 together.

This change:

- separates one TCP attempt timeout from the total backend connect/retry
timeout;
- keeps generic MORPC behavior backward compatible unless the new option
is set;
- configures Pipeline attempts to 1 second inside the existing 5-second
total budget, capped when a smaller total is configured;
- uses one monotonic deadline to cap the final attempt and retry sleep,
and lets backend cancellation interrupt retry sleep;
- adds a regression test in which the first dial times out and the
second succeeds within the same total budget, plus Pipeline
configuration bounds tests.

The scheduled remote CN remains fixed and the existing bounded failure
contract from matrixorigin#27528 is preserved: this does not reroute a dispatched
scope or extend the backend recovery budget. Persistent peer/network
outages still fail within the configured bound. The lower-level trigger
of the incident (target listener, node/network degradation, or
connection pressure) still needs TKE metrics to distinguish; this PR
fixes the confirmed client-side loss of retry opportunity.

## Validation

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s
./pkg/common/morpc ./pkg/cnservice/cnclient`
- focused regression tests with `-count=5`
- focused regression tests with `-race`
- `go vet ./pkg/common/morpc ./pkg/cnservice/cnclient`
- `git diff --check`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…28922)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#28895

## What this PR does / why we need it:

The TPCC incident exposed a timeout-budget coupling in Pipeline backend
creation: the same default 5-second value was passed to each goetty TCP
`Connect` call and used as the total MORPC backend connect/retry window.
A single `i/o timeout` could therefore consume the entire recovery
window. The retry loop existed, but had no meaningful time left for
another connection attempt; concurrent Pipeline streams coalesced on
that one failed create state and surfaced 20502 together.

This change:

- separates one TCP attempt timeout from the total backend connect/retry
timeout;
- keeps generic MORPC behavior backward compatible unless the new option
is set;
- configures Pipeline attempts to 1 second inside the existing 5-second
total budget, capped when a smaller total is configured;
- uses one monotonic deadline to cap the final attempt and retry sleep,
and lets backend cancellation interrupt retry sleep;
- adds a regression test in which the first dial times out and the
second succeeds within the same total budget, plus Pipeline
configuration bounds tests.

The scheduled remote CN remains fixed and the existing bounded failure
contract from matrixorigin#27528 is preserved: this does not reroute a dispatched
scope or extend the backend recovery budget. Persistent peer/network
outages still fail within the configured bound. The lower-level trigger
of the incident (target listener, node/network degradation, or
connection pressure) still needs TKE metrics to distinguish; this PR
fixes the confirmed client-side loss of retry opportunity.

## Validation

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s
./pkg/common/morpc ./pkg/cnservice/cnclient`
- focused regression tests with `-count=5`
- focused regression tests with `-race`
- `go vet ./pkg/common/morpc ./pkg/cnservice/cnclient`
- `git diff --check`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants