Skip to content

fix(frontend): keep connections alive after long-running requests - #27156

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
jiangxinmeng1:agent/diagnose-load-data-oom
Aug 14, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
jiangxinmeng1:agent/diagnose-load-data-oom

Conversation

@jiangxinmeng1

@jiangxinmeng1 jiangxinmeng1 commented Aug 14, 2026 •

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 #26720

What this PR does / why we need it:

Summary

Fix frontend connections being incorrectly closed after a successful long-running request.

Routine.handleRequest created a request observer context with a fixed 30-minute deadline and later
treated expiration of that child context as cancellation of the connection itself. As a result, SQL
requests running longer than 30 minutes could complete successfully but still trigger transaction
rollback and connection closure, causing clients to report Lost connection to MySQL server during query.

This PR:

  • determines connection termination only from the real routine/root context or explicit connection
    cancellation;
  • removes the obsolete per-request observer deadline;
  • preserves client disconnect, KILL CONNECTION, cancellation, rollback, and cleanup behavior;
  • adds a regression test proving that expiration of a request-scoped child context does not close a
    healthy connection;
  • completes explain node-name coverage for APPLY, POSTDML, and TABLE_CLONE, preventing long-
    query plan diagnostics from reporting Unsupported node type.

Validation

  • TestRoutineShouldCloseConnectionIgnoresRequestDeadline passed.
  • TestGetLabelOrTitle passed with exhaustive node-type name coverage.
  • Nightly IVF workflow validation used a temporary 10-minute observer deadline:
    • LOAD DATA ran for 28m52s;
    • no rollback the txn, lost connection, or request failure occurred;
    • the workflow successfully continued into IVFFlat index construction.

Validation workflow:
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31778171059/job/94700724247

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

Reviewed the connection lifecycle and cancellation paths at exact head fa8252c. The change correctly distinguishes the routine/root cancellation state from the retired request observer timeout, while preserving explicit KILL CONNECTION, disconnect cleanup, request cancellation, rollback, and protocol-close behavior. The explain node-name additions are complete for the currently supported enum values.

Focused frontend lifecycle tests and exhaustive explain name/title/label coverage pass with the required CGO/thirdparties setup.

Non-blocking metadata note: the PR body links #26720, but that issue describes the IVF pre-filter OOM rather than the long-request connection timeout; please correct the issue association when convenient.

@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 fa8252c. No blocking issues found.

The root-cause fix is sound: the former 30-minute child context never governed SQL execution, so it could not interrupt a hung query; it only caused rollback/connection close after a successful request exceeded the observer threshold. Query cancellation remains owned by SessionTimeout, KILL QUERY, KILL CONNECTION, and disconnect cleanup. The explain-name additions are complete and consistent with the existing title/label handlers.

Validated locally with go list/build/vet for both affected packages, focused frontend/explain tests, frontend lifecycle race tests, and full package tests.

Non-blocking metadata note: #26720 describes a ~21-second IVF concurrency OOM and was fixed by #26989, so it is not the issue this PR fixes. Please replace that reference with the actual long-request connection issue before merge. CI was still running when this review was submitted.

@mergify

mergify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-14 10:51 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-14 11:08 UTC · at add67fcc0a21db23cb8fa2e5f4d1f97526c8bc2f

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

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • 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)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • 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)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #27156 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.

Failing checks:

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 8448892 into matrixorigin:main Aug 14, 2026
24 of 25 checks passed
@mergify mergify Bot added dequeued and removed queued labels Aug 14, 2026
XuPeng-SH added a commit that referenced this pull request Aug 28, 2026
## 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 #26720

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

Backport the fixes missing from `4.2-dev` for
[#26720](#26720) and
  [#25114](#25114).

  Included PRs:

  - #26711: Fix pipeline remote batch backpressure
  - #26739: Retry COS multipart initialization on EOF
  - #26759: Fix IVF prefilter OOM
  - #26989: Reduce IVF prefilter scan memory copies
  - #27156: Keep connections alive after long-running requests

The changes address vector-index memory usage, file-service retry
behavior, remote pipeline backpressure, and
  frontend connection lifecycle on `4.2-dev`.

---------

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

## 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#26720 

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

 ## Summary

Fix frontend connections being incorrectly closed after a successful
long-running request.

`Routine.handleRequest` created a request observer context with a fixed
30-minute deadline and later
treated expiration of that child context as cancellation of the
connection itself. As a result, SQL
requests running longer than 30 minutes could complete successfully but
still trigger transaction
rollback and connection closure, causing clients to report `Lost
connection to MySQL server during
  query`.

  This PR:

- determines connection termination only from the real routine/root
context or explicit connection
  cancellation;
  - removes the obsolete per-request observer deadline;
- preserves client disconnect, `KILL CONNECTION`, cancellation,
rollback, and cleanup behavior;
- adds a regression test proving that expiration of a request-scoped
child context does not close a
  healthy connection;
- completes explain node-name coverage for `APPLY`, `POSTDML`, and
`TABLE_CLONE`, preventing long-
  query plan diagnostics from reporting `Unsupported node type`.

  ## Validation

  - `TestRoutineShouldCloseConnectionIgnoresRequestDeadline` passed.
- `TestGetLabelOrTitle` passed with exhaustive node-type name coverage.
- Nightly IVF workflow validation used a temporary 10-minute observer
deadline:
    - `LOAD DATA` ran for `28m52s`;
- no `rollback the txn`, lost connection, or request failure occurred;
- the workflow successfully continued into IVFFlat index construction.

  Validation workflow:

https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31778171059/job/94700724247

---------

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
…trixorigin#27156)

## 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#26720 

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

 ## Summary

Fix frontend connections being incorrectly closed after a successful
long-running request.

`Routine.handleRequest` created a request observer context with a fixed
30-minute deadline and later
treated expiration of that child context as cancellation of the
connection itself. As a result, SQL
requests running longer than 30 minutes could complete successfully but
still trigger transaction
rollback and connection closure, causing clients to report `Lost
connection to MySQL server during
  query`.

  This PR:

- determines connection termination only from the real routine/root
context or explicit connection
  cancellation;
  - removes the obsolete per-request observer deadline;
- preserves client disconnect, `KILL CONNECTION`, cancellation,
rollback, and cleanup behavior;
- adds a regression test proving that expiration of a request-scoped
child context does not close a
  healthy connection;
- completes explain node-name coverage for `APPLY`, `POSTDML`, and
`TABLE_CLONE`, preventing long-
  query plan diagnostics from reporting `Unsupported node type`.

  ## Validation

  - `TestRoutineShouldCloseConnectionIgnoresRequestDeadline` passed.
- `TestGetLabelOrTitle` passed with exhaustive node-type name coverage.
- Nightly IVF workflow validation used a temporary 10-minute observer
deadline:
    - `LOAD DATA` ran for `28m52s`;
- no `rollback the txn`, lost connection, or request failure occurred;
- the workflow successfully continued into IVFFlat index construction.

  Validation workflow:

https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31778171059/job/94700724247

---------

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
…trixorigin#27156)

## 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#26720 

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

 ## Summary

Fix frontend connections being incorrectly closed after a successful
long-running request.

`Routine.handleRequest` created a request observer context with a fixed
30-minute deadline and later
treated expiration of that child context as cancellation of the
connection itself. As a result, SQL
requests running longer than 30 minutes could complete successfully but
still trigger transaction
rollback and connection closure, causing clients to report `Lost
connection to MySQL server during
  query`.

  This PR:

- determines connection termination only from the real routine/root
context or explicit connection
  cancellation;
  - removes the obsolete per-request observer deadline;
- preserves client disconnect, `KILL CONNECTION`, cancellation,
rollback, and cleanup behavior;
- adds a regression test proving that expiration of a request-scoped
child context does not close a
  healthy connection;
- completes explain node-name coverage for `APPLY`, `POSTDML`, and
`TABLE_CLONE`, preventing long-
  query plan diagnostics from reporting `Unsupported node type`.

  ## Validation

  - `TestRoutineShouldCloseConnectionIgnoresRequestDeadline` passed.
- `TestGetLabelOrTitle` passed with exhaustive node-type name coverage.
- Nightly IVF workflow validation used a temporary 10-minute observer
deadline:
    - `LOAD DATA` ran for `28m52s`;
- no `rollback the txn`, lost connection, or request failure occurred;
- the workflow successfully continued into IVFFlat index construction.

  Validation workflow:

https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31778171059/job/94700724247

---------

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/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants