Skip to content

fix: make persisted view protocol activation durable - #28940

Closed
XuPeng-SH wants to merge 0 commit into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28883-main-20260915
Closed

XuPeng-SH wants to merge 0 commit into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28883-main-20260915

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

Fixes #28883

What this PR does / why we need it:

Make persisted-view expression protocol activation a durable, one-way admission
boundary during rolling upgrades and restarts. The leader now checks the
capability of every current HAKeeper voting and non-voting member, even when a
heartbeat is expired; historical store records that are no longer members do
not block activation. While an enabled admission transition is still pending,
the checker first sends the legacy reconciliation entry so old-generation
targets can expire. Only after durable Pending=false may the protocol-bearing
entry raise the persisted-expression floor and start a new admission epoch.

The changes preserve the existing tag-22/V3 fail-closed RSM gate, monotonic
floor, generation fencing, snapshot envelope, and protobuf compatibility.

Test plan

  • TestViewMetadataAdmissionLogStoresReadyWithProtocolChecksCurrentMembers:
    expired current voting/non-voting members still block V3; upgraded members
    pass; missing capability/record blocks; an expired historical non-member does
    not block.
  • TestServiceViewMetadataAdmissionReconcilesPendingBeforeProtocolRaise:
    deterministic same-UUID generation 10→11 restart with logical ticks proves
    legacy drain at floor 0, then V3 floor raise and new-epoch admission.
  • TestRegenerateViewDefinitionRejectsInvalidPersistedDefinitions now derives
    futureVersion := defines.MORPCLatestVersion + 1, so the protocol-rejection-
    before-parser oracle remains valid when the latest protocol advances.
  • Focused normal and -race -count=1 runs for the dynamic test pass; the
    prior protocol focused/full-package normal/race and incremental SCA evidence
    remains valid because this follow-up changes only a test.
  • No remote CI wait was used.

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

@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Sep 15, 2026
@mergify mergify Bot added the kind/bug Something isn't working label Sep 15, 2026
@XuPeng-SH
XuPeng-SH force-pushed the codex/issue-28883-main-20260915 branch from 031bdb3 to 40c2064 Compare September 15, 2026 12:12
@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main at 1d7d425f6c and force-updated the personal-fork feature ref (default branch untouched). After rebase, the affected normal and race suites for hakeeper, cnservice, logservice, plan, compile, and frontend all passed. No remote CI wait.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

CI triage/fix update (2026-09-15):

  • The arm64 SCA failure was PR-owned: the PR introduced an unreferenced viewMetadataAdmissionLogStoresReady wrapper in pkg/logservice/store.go:970; SCA reported unused.
  • Removed only that dead wrapper. The protocol-aware helper and both requireProtocolV3=true admission gates remain unchanged.
  • Rebased onto current main 1d7d425f6cd955d670cbd04b5b49ab7b682206d6 without conflicts and force-with-lease updated the author branch. New head: 93199873651514dc4fa86c9550357b2cd5fbb077.
  • Validation: focused TestServiceViewMetadataAdmissionActivation, go vet ./pkg/logservice, and incremental golangci-lint from current main all pass; git diff --check/gofmt pass. No BVT or full slow UT added/run.
  • GPT-6 medium final overall review: PASS, no actionable findings.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Follow-up correction pushed in 37c89392f288ed777e0ff8926840561707124e98: TestRegenerateViewDefinitionRejectsInvalidPersistedDefinitions now derives futureVersion := defines.MORPCLatestVersion + 1 and formats both persisted marker and expected diagnostic. Main now has latest protocol 73, so the old literal 73 was no longer future and the test reached the intentional SQL parser error. This is test-only; focused normal and race runs pass. No remote CI wait.

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

Blocking: CREATE/ALTER VIEW plans can outlive the authoring admission state and are not revalidated at execution. The exact-head focused HAKeeper, LogService, CNService, planner, compiler, frontend, and race tests otherwise passed. The exact-head CI UT failure is the unrelated TestIcebergSQLEngineEmbeddedHarness connection timeout.

Comment thread pkg/sql/plan/build_ddl.go
}
if viewRequiredProtocol > 0 {
if forAuthoring {
err = RequirePersistedProtocolVersionForAuthoring(

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.

[P1] Recheck the authoring floor at CREATE/ALTER VIEW execution. This check runs only while building the plan. Scope.CreateView (pkg/sql/compile/ddl.go:2682-2772) writes qry.TableDef without revalidating its required_protocol_version, unlike the CreateTable and AlterTable execution paths. Repro: PREPARE CREATE VIEW v AS SELECT inet_ntoa(1) while the authoring floor is 72; let a new admission epoch clear PersistedExpressionProtocolAuthoringFloor to 0; then EXECUTE the stored plan. It still reaches dbSource.Create and publishes a view marked required_protocol_version=72 during the closed authoring window. A local exact-head counterexample that set the floor to 0 and invoked Scope.CreateView with this stored plan expected a protocol-version rejection, but got nil and created v. Please validate the persisted marker with RequirePersistedProtocolVersionForAuthoring at the catalog mutation boundary, and cover prepared CREATE/ALTER VIEW.

XuPeng-SH added a commit that referenced this pull request Sep 16, 2026
#28915)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue #28904
issue #28908
issue #28909

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

This is the string-compatibility successor to #28885 and is delivered
with #28940 as a real protocol-admission prerequisite. The branch keeps
the aggregate protocol allocation from #28885 (v75-v78), the durable
persisted-expression read/authoring/generation fence from #28940, and
adds the disjoint v79 string-numeric result contract. The prerequisite
commits are kept as separate ancestry so the PR is safe before either
predecessor is merged; after they land, the review diff collapses to the
v79 adaptation.

- Accept one-argument `CONCAT` while retaining zero-argument rejection
and correct NULL/value behavior.
- Preserve the execution-bound occurrence when rebinding prepared `ELT`
indexes. Runtime decimal rounding, numeric prefixes, NULL, out-of-range
values, and explicit `DOUBLE` casts keep their intended results without
mutating the cached plan.
- Correct result metadata and execution domains for `FIND_IN_SET`,
`STRCMP`, `CHAR_LENGTH`/`LENGTH_UTF8`, `UNCOMPRESSED_LENGTH`, and
`CRC32`, while retaining legacy wrappers for older protocol consumers.
- Gate sender placement, receiver validation, persisted expression
admission, VIEW authoring/read/regeneration/restore, and
generation/pending transitions at MORPC v79 so an older CN cannot decode
or rebind the new result domain.

## Test plan

- Combined affected-package normal tests: `pkg/sql/plan`,
`pkg/sql/plan/function`, `pkg/sql/compile`, `pkg/frontend`,
`pkg/hakeeper`, `pkg/cnservice`, and `pkg/logservice`.
- Focused protocol/admission `-race -count=1` tests, including HAKeeper
member capability/pending reconciliation, VIEW restore, sender/receiver
placement, prepared `ELT`, wrappers, and one-argument `CONCAT`.
- `go list -mod=readonly`, CGo-aware `go vet`, `git diff --check`, and
`make build-with-prebuilt-native` all pass on the combined candidate.
- On 10.222.1.55 using the combined candidate binary,
`func_bounded_result_metadata` passed `63/63` statements, `0` failures
in 0.462s. It covers direct/prepared `CONCAT`, prepared `ELT`
decimal/prefix/NULL/out-of-range/`DOUBLE`, VIEW/CTAS metadata, and the
corrected legacy metadata cells.
- No new row-execution hot-path cache or unbounded state is introduced;
version detection runs at plan/DDL/metadata boundaries. Official
repository CI remains authoritative and is intentionally not awaited
here.
@XuPeng-SH XuPeng-SH closed this Sep 16, 2026
@XuPeng-SH
XuPeng-SH force-pushed the codex/issue-28883-main-20260915 branch from 37c8939 to 5159b99 Compare September 16, 2026 13:39
@matrix-meow matrix-meow added size/XS Denotes a PR that changes [1, 9] lines and removed size/XXL Denotes a PR that changes 2000+ lines labels Sep 16, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
matrixorigin#28915)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#28904
issue matrixorigin#28908
issue matrixorigin#28909

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

This is the string-compatibility successor to matrixorigin#28885 and is delivered
with matrixorigin#28940 as a real protocol-admission prerequisite. The branch keeps
the aggregate protocol allocation from matrixorigin#28885 (v75-v78), the durable
persisted-expression read/authoring/generation fence from matrixorigin#28940, and
adds the disjoint v79 string-numeric result contract. The prerequisite
commits are kept as separate ancestry so the PR is safe before either
predecessor is merged; after they land, the review diff collapses to the
v79 adaptation.

- Accept one-argument `CONCAT` while retaining zero-argument rejection
and correct NULL/value behavior.
- Preserve the execution-bound occurrence when rebinding prepared `ELT`
indexes. Runtime decimal rounding, numeric prefixes, NULL, out-of-range
values, and explicit `DOUBLE` casts keep their intended results without
mutating the cached plan.
- Correct result metadata and execution domains for `FIND_IN_SET`,
`STRCMP`, `CHAR_LENGTH`/`LENGTH_UTF8`, `UNCOMPRESSED_LENGTH`, and
`CRC32`, while retaining legacy wrappers for older protocol consumers.
- Gate sender placement, receiver validation, persisted expression
admission, VIEW authoring/read/regeneration/restore, and
generation/pending transitions at MORPC v79 so an older CN cannot decode
or rebind the new result domain.

## Test plan

- Combined affected-package normal tests: `pkg/sql/plan`,
`pkg/sql/plan/function`, `pkg/sql/compile`, `pkg/frontend`,
`pkg/hakeeper`, `pkg/cnservice`, and `pkg/logservice`.
- Focused protocol/admission `-race -count=1` tests, including HAKeeper
member capability/pending reconciliation, VIEW restore, sender/receiver
placement, prepared `ELT`, wrappers, and one-argument `CONCAT`.
- `go list -mod=readonly`, CGo-aware `go vet`, `git diff --check`, and
`make build-with-prebuilt-native` all pass on the combined candidate.
- On 10.222.1.55 using the combined candidate binary,
`func_bounded_result_metadata` passed `63/63` statements, `0` failures
in 0.462s. It covers direct/prepared `CONCAT`, prepared `ELT`
decimal/prefix/NULL/out-of-range/`DOUBLE`, VIEW/CTAS metadata, and the
corrected legacy metadata cells.
- No new row-execution hot-path cache or unbounded state is introduced;
version detection runs at plan/DDL/metadata boundaries. Official
repository CI remains authoritative and is intentionally not awaited
here.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
matrixorigin#28915)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#28904
issue matrixorigin#28908
issue matrixorigin#28909

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

This is the string-compatibility successor to matrixorigin#28885 and is delivered
with matrixorigin#28940 as a real protocol-admission prerequisite. The branch keeps
the aggregate protocol allocation from matrixorigin#28885 (v75-v78), the durable
persisted-expression read/authoring/generation fence from matrixorigin#28940, and
adds the disjoint v79 string-numeric result contract. The prerequisite
commits are kept as separate ancestry so the PR is safe before either
predecessor is merged; after they land, the review diff collapses to the
v79 adaptation.

- Accept one-argument `CONCAT` while retaining zero-argument rejection
and correct NULL/value behavior.
- Preserve the execution-bound occurrence when rebinding prepared `ELT`
indexes. Runtime decimal rounding, numeric prefixes, NULL, out-of-range
values, and explicit `DOUBLE` casts keep their intended results without
mutating the cached plan.
- Correct result metadata and execution domains for `FIND_IN_SET`,
`STRCMP`, `CHAR_LENGTH`/`LENGTH_UTF8`, `UNCOMPRESSED_LENGTH`, and
`CRC32`, while retaining legacy wrappers for older protocol consumers.
- Gate sender placement, receiver validation, persisted expression
admission, VIEW authoring/read/regeneration/restore, and
generation/pending transitions at MORPC v79 so an older CN cannot decode
or rebind the new result domain.

## Test plan

- Combined affected-package normal tests: `pkg/sql/plan`,
`pkg/sql/plan/function`, `pkg/sql/compile`, `pkg/frontend`,
`pkg/hakeeper`, `pkg/cnservice`, and `pkg/logservice`.
- Focused protocol/admission `-race -count=1` tests, including HAKeeper
member capability/pending reconciliation, VIEW restore, sender/receiver
placement, prepared `ELT`, wrappers, and one-argument `CONCAT`.
- `go list -mod=readonly`, CGo-aware `go vet`, `git diff --check`, and
`make build-with-prebuilt-native` all pass on the combined candidate.
- On 10.222.1.55 using the combined candidate binary,
`func_bounded_result_metadata` passed `63/63` statements, `0` failures
in 0.462s. It covers direct/prepared `CONCAT`, prepared `ELT`
decimal/prefix/NULL/out-of-range/`DOUBLE`, VIEW/CTAS metadata, and the
corrected legacy metadata cells.
- No new row-execution hot-path cache or unbounded state is introduced;
version detection runs at plan/DDL/metadata boundaries. Official
repository CI remains authoritative and is intentionally not awaited
here.

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/XS Denotes a PR that changes [1, 9] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: guard persisted SQL and expressions across rolling protocol downgrade

4 participants