Skip to content

[4.2-dev] fix(morpc): preserve slow responses after probe timeout - #26931

Merged
mergify[bot] merged 1 commit into
matrixorigin:4.2-devfrom
LeftHandCold:backport/4.2-morpc-preserve-slow-lock-responses
Aug 10, 2026
Merged

mergify[bot] merged 1 commit into
matrixorigin:4.2-devfrom
LeftHandCold:backport/4.2-morpc-preserve-slow-lock-responses

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

Related to #26888.

Backport of #26903 to 4.2-dev.

What this PR does / why we need it:

Backports the MORPC fix that prevents an inconclusive control-probe timeout from resetting a data backend that can still return valid slow Lock responses.

The #26888 incident occurred on 4.2-dev: one failed probe closed the shared backend and failed all pending Lock Futures together as ErrorCode 20505. The lock owner returned those responses shortly after the caller had already closed the connection.

This change affects only the response-inactivity path:

  • seal the inactive data generation from new admission before probing;
  • preserve its pending Futures when the independent control probe times out;
  • direct new requests to the bounded replacement generation;
  • retain immediate reset behavior for terminal data errors such as EOF, connection reset, and broken pipe.

The normal MORPC request/response path does not add locks, allocations, or RPCs.

Backport verification

  • Cherry-picked with -x from aa11c18f2a3d6a2609eaa425ae50b51ce72c321f.
  • Backport and main commits have the same stable patch ID.
  • No conflicts or manual semantic changes.
  • Focused MORPC liveness/generation tests: -count=30 passed.
  • TestTimedOutLivenessProbePreservesSlowDataResponse: race -count=100 passed.
  • go test ./pkg/common/morpc/... passed.
  • go test -race ./pkg/common/morpc passed.
  • go test ./pkg/lockservice/... passed.
  • MORPC and lockservice build and vet checks passed.

@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 →

@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.

Deep reviewed exact head 7ad71ac33b6175870800af03b52db6354a979836 against 4.2-dev base 43aa6ff892d7970110134b0167eaadca34d762bc.

Backport integrity:

  • Source commit: aa11c18f2a3d6a2609eaa425ae50b51ce72c321f from #26903.
  • Source and backport have the identical stable patch ID e5ca098d573ea36e9bc1a1446ccfdb68d5cbede7.
  • Both modified files have identical preimage/postimage blobs; no conflict resolution or semantic rewrite occurred.
  • The untouched MORPC client, GC, Future, types, and lockservice RPC/remote consumer blobs are also identical to the source commit's baseline, so the draining-generation protocol has the same consumers on 4.2-dev.

Lifecycle closure:

  • A data inactivity timeout seals admission under stateMu before the independent control probe, so new traffic cannot enter the old generation after publication.
  • Probe failure remains inconclusive and no longer schedules reset/fails all Futures; the old generation retains ownership until a late response, request deadline/Future close, terminal data error, explicit reset, or client/backend close.
  • EOF, connection reset, broken pipe, and other non-timeout data errors still bypass preservation and take the immediate reset/failure path.
  • New traffic uses a replacement generation. Pool growth remains bounded to maxBackendsPerHost + 1; when another generation drains, the oldest drain is retired before another replacement is admitted, and cleanup concurrency is separately bounded.

Unhappy-path audit:

  • Q1: Future/response/backend cleanup ownership remains exactly once across late response, timeout, reset, and close.
  • Q2: probe wait is bounded by min(readTimeout/5, internalTimeout) and is outside backend locks; cancellation and terminal data errors retain independent termination paths.
  • Q3: pending liveness IDs remain buffer-bounded, draining generations remain pool-bounded, and saturated cleanup keeps backends counted against capacity.

Performance: the normal request/response path is unchanged. The only reordered lock/CAS work is on the response-inactivity fault path; no per-request allocation, lock, RPC, or scan was added.

Fresh validation on the backport head:

  • Modified regression measured under race: T=0.03s, budget B=30s, adaptive N=100; passed.
  • Nine focused liveness/draining/generation tests: -count=30; passed.
  • Full pkg/common/morpc race: passed.
  • Full pkg/lockservice/...: passed (105.908s).
  • MORPC + lockservice build and vet: passed.
  • PR CI is green and the head is mergeable.

No blocking correctness, lifecycle, deadlock, boundedness, compatibility, or performance finding.

@mergify mergify Bot added the queued label Aug 10, 2026
@mergify

mergify Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-10 11:04 UTC · Rule: release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-10 11:05 UTC · at 7ad71ac33b6175870800af03b52db6354a979836 · squash

This pull request spent 43 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)

@mergify
mergify Bot merged commit b83878b into matrixorigin:4.2-dev Aug 10, 2026
24 of 25 checks passed
@mergify mergify Bot removed the queued label Aug 10, 2026

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.

3 participants