Skip to content

fix: snapshot async execution plans - #26177

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/26175-async-plan-snapshot
Jul 26, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/26175-async-plan-snapshot

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Jul 25, 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:

Fixes #26175

What this PR does / why we need it:

The asynchronous JSON-plan exporter previously retained references into a completed execution generation. A prepared-plan reset/reuse could mutate those references before the asynchronous sanitizer or serializer consumed them, resulting in stale data, data races, or a panic.

This PR snapshots PhyPlan synchronously before reuse. The clone preserves intentional physical-plan DAG sharing while detaching all mutable execution-owned state: scopes, receivers, sources, operators, operator-stat maps, and background-query protobufs.

To prevent future fields from reopening the bug class, the tests now:

  • assert the reference-bearing schema of every cloned type explicitly;
  • populate every mutable fixture field;
  • prove that a shallow copy is detected as aliased while CloneForExport has no mutable aliases;
  • cover prepared reset/reuse and sanitizer isolation.

Verification:

  • targeted -race -count=10 tests for the snapshot/reset/sanitizer paths;
  • complete UT for pkg/sql/models, pkg/vm/process, and pkg/frontend;
  • go vet and go build for the affected packages;
  • clone benchmark: a 1000-operator plan completes in about 0.34 ms locally.

@XuPeng-SH
XuPeng-SH requested review from aptend and aunjgr as code owners July 25, 2026 16:24
@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

Copy link
Copy Markdown
Contributor Author

@LeftHandCold @gouhongshen please help to review

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

这轮按 correctness / 功能闭环 / unhappy path 做了复核,当前没有看到阻塞合入的问题。

重点看了异步 exec plan 导出链路:本次改动在保留 ExplainData 前先把 PhyPlan、OperatorStats 和 BackgroundQueries 从可变执行态里 detach 出来,能够覆盖 prepared reset / source reuse / sanitize 不应反写 source 这几个关键场景;新增测试也把 shared-node alias、引用断开和快照稳定性补齐了。

补充说明:当前账号是该 PR 作者账号,GitHub 不允许对自己的 PR 执行 approve,所以这里只能留下 comment 结论。

@XuPeng-SH
XuPeng-SH merged commit e5fffff into matrixorigin:main Jul 26, 2026
24 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/26175-async-plan-snapshot branch July 26, 2026 00:01
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26175

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

The asynchronous JSON-plan exporter previously retained references into
a completed execution generation. A prepared-plan reset/reuse could
mutate those references before the asynchronous sanitizer or serializer
consumed them, resulting in stale data, data races, or a panic.

This PR snapshots `PhyPlan` synchronously before reuse. The clone
preserves intentional physical-plan DAG sharing while detaching all
mutable execution-owned state: scopes, receivers, sources, operators,
operator-stat maps, and background-query protobufs.

To prevent future fields from reopening the bug class, the tests now:

- assert the reference-bearing schema of every cloned type explicitly;
- populate every mutable fixture field;
- prove that a shallow copy is detected as aliased while
`CloneForExport` has no mutable aliases;
- cover prepared reset/reuse and sanitizer isolation.

Verification:

- targeted `-race -count=10` tests for the snapshot/reset/sanitizer
paths;
- complete UT for `pkg/sql/models`, `pkg/vm/process`, and
`pkg/frontend`;
- `go vet` and `go build` for the affected packages;
- clone benchmark: a 1000-operator plan completes in about 0.34 ms
locally.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26175

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

The asynchronous JSON-plan exporter previously retained references into
a completed execution generation. A prepared-plan reset/reuse could
mutate those references before the asynchronous sanitizer or serializer
consumed them, resulting in stale data, data races, or a panic.

This PR snapshots `PhyPlan` synchronously before reuse. The clone
preserves intentional physical-plan DAG sharing while detaching all
mutable execution-owned state: scopes, receivers, sources, operators,
operator-stat maps, and background-query protobufs.

To prevent future fields from reopening the bug class, the tests now:

- assert the reference-bearing schema of every cloned type explicitly;
- populate every mutable fixture field;
- prove that a shallow copy is detected as aliased while
`CloneForExport` has no mutable aliases;
- cover prepared reset/reuse and sanitizer isolation.

Verification:

- targeted `-race -count=10` tests for the snapshot/reset/sanitizer
paths;
- complete UT for `pkg/sql/models`, `pkg/vm/process`, and
`pkg/frontend`;
- `go vet` and `go build` for the affected packages;
- clone benchmark: a 1000-operator plan completes in about 0.34 ms
locally.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26175

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

The asynchronous JSON-plan exporter previously retained references into
a completed execution generation. A prepared-plan reset/reuse could
mutate those references before the asynchronous sanitizer or serializer
consumed them, resulting in stale data, data races, or a panic.

This PR snapshots `PhyPlan` synchronously before reuse. The clone
preserves intentional physical-plan DAG sharing while detaching all
mutable execution-owned state: scopes, receivers, sources, operators,
operator-stat maps, and background-query protobufs.

To prevent future fields from reopening the bug class, the tests now:

- assert the reference-bearing schema of every cloned type explicitly;
- populate every mutable fixture field;
- prove that a shallow copy is detected as aliased while
`CloneForExport` has no mutable aliases;
- cover prepared reset/reuse and sanitizer isolation.

Verification:

- targeted `-race -count=10` tests for the snapshot/reset/sanitizer
paths;
- complete UT for `pkg/sql/models`, `pkg/vm/process`, and
`pkg/frontend`;
- `go vet` and `go build` for the affected packages;
- clone benchmark: a 1000-operator plan completes in about 0.34 ms
locally.

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 kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] panic: assignment to entry in nil map in sanitizeNonFiniteFloatValue (TPCC warehouse=1000)

2 participants