Skip to content

fix: synchronize index builds with concurrent writes on 4.2-dev - #32346

Merged
XuPeng-SH merged 11 commits into
4.2-devfrom
codex/backport-29235-4.2-dev
Nov 11, 2026
Merged

XuPeng-SH merged 11 commits into
4.2-devfrom
codex/backport-29235-4.2-dev

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • Test and CI

Which issue(s) this PR fixes:

Fixes #32244

What this PR does / why we need it:

Backport the CREATE INDEX synchronization from #29235 to 4.2-dev and apply the corresponding snapshot handoff to in-place ALTER TABLE ... ADD INDEX. A writer that commits after index DDL planning must be visible to the backfill; a stale writer admitted after publication must replan and maintain the new index. The change takes the existing catalog and base-table definition locks, rebuilds on metadata conflicts, and advances the pessimistic-RC workspace snapshot through the TN's ordered logtail barrier before backfill.

For rolling upgrades, the CN checks the capability advertised by its actual logtail peer. If the TN does not advertise the barrier, or the CN protocol is below 11, index DDL keeps the earlier snapshot behavior without an additional HLC wait. Errors or interrupted negotiation do not select this fallback. The barrier-based handoff applies when the peer advertises support and protocol 11 is enabled; a manually pinned lower protocol continues legacy behavior. Existing behavior is accepted while legacy nodes or transactions remain, and an index corrupted before or during that interval needs separate detection and repair. This PR targets production pessimistic RC and does not claim to repair optimistic/SI behavior or partitioned tables.

The existing morpc activity test is also made deterministic by observing responses and using an isolated test socket.

Validation

  • Go 1.26.4, Linux/amd64: authenticated three-CN/one-TN pessimistic-RC regressions under -race cover concurrent index DDL, CREATE/ALTER, regular and unique indexes, stale UPDATE admission, same-transaction writes, rollback and cancellation. Physical hidden-index keys are compared with base rows.
  • Full -race -short owning packages: pkg/sql/compile, pkg/vm/engine/disttae, and pkg/vm/engine/tae/logtail/service; the changed morpc test passed under -race. A deterministic old-peer replacement test passed -race -count=100.
  • Actual official 4.2.6 and 4.2.7 binaries in both directions (new CN / old TN and old CN / new TN): fresh bootstrap, CREATE INDEX and ALTER ADD INDEX succeeded and hidden keys matched base rows. One CN also survived 4.2.6 → candidate TN → 4.2.6 reconnects with index-key checks at each step; after upgrading the TN, fault-gated CREATE/ALTER plans included an intervening committed writer. These are mixed-version smoke checks, not a guarantee for concurrent legacy transactions.
  • gofmt, incremental go vet, repository-pinned golangci-lint v2.6.2 (zero incremental issues), and pinned molint passed for the affected closure. molint also reports existing checkrecover positions outside the changed hunks. Generated logtail protobuf is byte-identical to regeneration.
  • With a 4.2.6 TN and a configured 500 ms clock offset, a local two-row CREATE INDEX microbenchmark measured median 515.63 ms with the earlier HLC fallback and 13.93 ms with this legacy path (six samples each, ABBA). This measures the upgrade path only. Earlier testing on the prior base measured 14.03 ms base versus 17.95 ms with this PR for a cold lock binding, and 12.55 ms versus 12.40 ms for a warm binding (40 tiny-table samples per arm); these single-host measurements do not establish general throughput or a broad regression bound.
  • CI test synchronization: the tenant-upgrade unit test observes completion of its mock transaction instead of relying on a 20 ms deadline. The cross-CN dropped-user test fences the committing CN, confirms deletion on the receiving CN, then retains the old-session denial check. This checks authorization after visibility; it does not claim instantaneous cross-CN revocation.
  • CI-specific checks: bootstrap regression under -race -count=50, the full authorization parent test under -race and coverage compilation, and incremental vet and golangci-lint v2.6.2 for both affected test packages passed. The issues package has no instrumented statements, so that local -cover run is not a full coverage measurement. New CI is pending.

@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner November 7, 2026 11:13
@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 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: d3e9fffa3dcc384cce3366cf9f2742cc3367fec5

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: d3e9fffa3dcc384cce3366cf9f2742cc3367fec5

Assessment: request_changes

The implementation reuses existing lock, barrier and workspace owners. The backport leaves a test helper undefined and omits coverage of stale UPDATE admission after index publication.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

  • P1 pkg/tests/issues/issue_28928_28931_test.go:222: Compiling the pkg/tests/issues test package.
    Impact: issue27487DSN is called here and at line 224 but has no declaration in the frozen package. This prevents both new regressions and existing package tests from compiling.
    Evidence: The declaration probe inspected all 45 package Go files and found only these two references (helper-probe.log; checks/1794051401068239892-2.json, exit 1). Reuse an existing connection helper, such as openIssue29715DB, or include the missing dependency, then compile and run the package.

  • P2 pkg/tests/issues/issue_28928_28931_test.go:151: An UPDATE compiled against the old definition is admitted after CREATE INDEX publishes its new write target.
    Impact: This side of the definition-fence contract remains uncovered. Both new UPDATE cases pause CREATE INDEX, commit UPDATE first, then resume backfill; they cannot establish that a later stale writer rebuilds and maintains the new index.
    Evidence: Closing issue #32244 requires both admission orders and base/hidden-key consistency. Existing issue_29715 tests cover index removal. Add a deterministic two-CN stale-UPDATE schedule crossing index publication, verify hidden-key consistency and UNIQUE rejection, and execute the affected tests with the required concurrency/race validation. No matching completed SQL execution is supplied.

Validation:

  • Reviewed the complete five-file delta, affected owners and consumers, closing issue and both discussion entries; saved review-plan.md and discussion-assessment.json.

  • Isolation preflight passed: preflight.log; checks/1794051224789684495-2.json, exit 0.

  • Isolated AST probe confirmed the absent helper; existing-helper control passed. This was a declaration check, not a MatrixOne package build.

  • Source audit confirmed the assigned HEAD, clean checkout and passing git diff --check: source-audit.json/log; checks/1794051689759201485-2.json, exit 0. gofmt reports compile2.go.

Limitations:

  • No MatrixOne package, SQL or race tests were executed locally. Supplied local_validation is empty and relevant CI remains in progress.

  • No older-release binary validation was supplied for the legacy logtail fallback; supported mixed-version combinations were not inferred from protocol numbers.

@matrix-meow matrix-meow added size/XL Denotes a PR that changes [1000, 1999] lines and removed size/L Denotes a PR that changes [500,999] lines labels Nov 8, 2026
@XuPeng-SH
XuPeng-SH marked this pull request as draft November 8, 2026 04:29
@XuPeng-SH
XuPeng-SH force-pushed the codex/backport-29235-4.2-dev branch from 0018a18 to b6db5ab Compare November 8, 2026 18:48
@XuPeng-SH

XuPeng-SH commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 71e8377fb743a74a90ade8c608d0ad6218efd341

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 71e8377fb743a74a90ade8c608d0ad6218efd341

Assessment: request_changes

The pessimistic-RC repair appropriately reuses existing locks, barriers and workspace handling, but the CN-local capability gate still breaks index DDL against an old TN during supported rolling coexistence. Earlier approvals are superseded by the controlled mixed-version evidence; the earlier helper and stale-writer test concerns are resolved.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

  • P1 pkg/sql/compile/ddl.go:2666: A new CN starts at default protocol 11 against a v4.2.6/v4.2.7 TN and runs non-temporary pessimistic-RC CREATE INDEX or ALTER ADD INDEX.
    Impact: The CN sends an unsupported ReadBarrier request and propagates failure instead of using the legacy path, breaking index-DDL availability during the accepted rolling-upgrade interval. Select the barrier using relevant TN capability or a compatible floor guaranteed before admission across startup/restart, and add old-TN/new-CN CREATE/ALTER regression coverage.
    Evidence: runtime.go:60-61 defaults the CN to protocol 11; role_grant_graph.go:106-113 checks only that local value. ddl.go:2673-2679 propagates barrier errors. The current logtail client sends field 4 without peer selection; pinned v4.2.6/v4.2.7 schemas and dispatch lack it. Discussion 4509717802 reports old-TN failure with passing base and floor-10 controls; all six changed files match its original fa2469e head. Source audit and release fingerprints: source-evidence-audit.json, checks/1794272109633270824-3.json.

Validation:

  • Read the complete six-file delta, affected owners/consumers, linked issue #32244 and all 17 discussion entries; ledger covers each key once.

  • Bounded static source/evidence audit passed (checks/1794272109633270824-3.json); logs, commands, fingerprints and exits reconciled in validation-ledger.json. Source remains unchanged.

  • Compared pinned v4.2.6/v4.2.7 unsupported TN dispatch with the v4.2.8 capability control and the current CN startup/request/error path.

Limitations:

  • No fresh Go, SQL, race or mixed-binary execution. Supplied historical test and mixed-binary reports lack raw logs; they are attributed, not claimed as local passes.

  • Dependent index implementation polishing and execution stopped at the compatibility blocker. SI/optimistic and mixed-mode failures reported on baseline, partition exclusions and historical baseline package failures are not introduced findings.

  • Frozen UT, SCA, build, coverage and Go analysis remain in progress; upgrade checks are skipped.

@XuPeng-SH

XuPeng-SH commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: ce0bf0eb9a9ae6d61a92a3e3271d21c71cd58494

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: ce0bf0eb9a9ae6d61a92a3e3271d21c71cd58494

Assessment: request_changes

The existing mixed-version DDL regression remains. The repair reuses existing owners appropriately, but its CN-local protocol gate does not establish TN capability.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

  • P1 pkg/sql/compile/ddl.go:2666: A default protocol-11 CN executes non-temporary pessimistic-RC CREATE INDEX or ALTER ADD INDEX against a v4.2.6/v4.2.7 TN during supported rolling coexistence.
    Impact: The unsupported ReadBarrier request fails without selecting the legacy path, breaking index-DDL availability. Select using relevant TN capability or a compatible floor guaranteed before admission across startup/restart, and add old-TN/new-CN CREATE/ALTER coverage.
    Evidence: runtime.go:60-61 defaults the CN to protocol 11; role_grant_graph.go:106-113 checks only that local value. ddl.go:2673-2679 propagates barrier errors. Pinned v4.2.6/v4.2.7 TN schemas and dispatch lack ReadBarrier. Discussion 4509717802 reports failure with passing base and floor-10 controls. Relevant source remains unchanged; current audit: checks/1794276793573377480-3.json.

Validation:

  • Verified the complete six-file patch and relevant source are unchanged; only an unrelated spill-test assertion changed upstream. Reconciled all 19 discussion entries and linked issue #32244.

  • Current source/context/released-capability audit passed. Receipts, retained logs and qualified prior evidence are reconciled in validation-ledger.json. Source remains unchanged.

Limitations:

  • No fresh Go, SQL, race or mixed-binary execution; historical execution reports lack supplied raw product logs. Dependent polishing stopped at the compatibility blocker.

  • Baseline SI/optimistic limitations are not introduced findings; partitioned tables remain outside this repair.

  • Frozen build, UT/SCA, coverage and Go analysis remain in progress; upgrade checks are skipped.

@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@XuPeng-SH

XuPeng-SH commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 25da0f607efa7f0aff2991843b1aa5f5c58a5917

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 25da0f607efa7f0aff2991843b1aa5f5c58a5917

Assessment: approve

Per-stream capability negotiation resolves the prior old-TN DDL regression. The scoped pessimistic-RC repair coherently reuses existing locks, ordered barriers and workspace refresh.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • All 14 focused race tests and adaptive exact-test stress runs passed (N=1–100), including three-CN SQL regressions.

  • Full -race -short packages: morpc 422 passing cases/one skip, disttae 849 passes, logtail service 79 passes, issues 186 passes.

  • Compiler package: 1,339 passing cases; three Parquet failures reproduced at identical assertions with the exact merge-base build overlay.

  • Six production owners passed race build and vet. Frozen source, native provenance, all 22 discussion keys, receipts and retained logs reconciled in validation-ledger.json; final audit receipt: checks/1794338720082812029-2.json.

Limitations:

  • Official mixed-binary/reconnect and benchmark claims lack raw artifacts here; no fresh old-binary or performance execution.

  • Frozen CI remains pending. Legacy peers/protocol below 11 retain prior behavior; SI/optimistic, mixed-mode and partition guarantees remain outside this repair.

@XuPeng-SH

XuPeng-SH commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: ed4a41e987e40d87b009c227143451f9da297fde

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: ed4a41e987e40d87b009c227143451f9da297fde

Assessment: approve

Per-stream capability negotiation resolves the prior old-TN regression while reusing existing lock, barrier and workspace owners. The later CI test fixes preserve their behavioral assertions.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete delta, affected consumers, linked issue and all 24 discussion entries.

  • Fresh race checks passed: bootstrap regression ×100, full bootstrap package (47 cases), authorization test (11 cases).

  • Both affected test packages passed go vet; formatting and generated-descriptor checks passed.

  • Qualified prior race/build/vet reports reused for unchanged paths. Current receipts and logs reconciled in validation-ledger.json; source unchanged.

Limitations:

  • Historical raw execution artifacts were unavailable; no fresh release-binary or performance runs.

  • Legacy peers retain previous behavior; SI/optimistic and partition guarantees remain outside this repair.

  • Relevant frozen CI remains pending; upgrade checks were skipped.

This branch was previously deployed

1 inactive deployment
ci — ed4a41e9 Deployed Nov 11, 2026 by XuPeng-SH
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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants