Skip to content

feat: unify column reads for schema evolution (PR 1) - #32989

Merged
XuPeng-SH merged 13 commits into
matrixorigin:mainfrom
VioletQwQ-0:feat/schema-evol-pr1-read-spec
Dec 1, 2026
Merged

XuPeng-SH merged 13 commits into
matrixorigin:mainfrom
VioletQwQ-0:feat/schema-evol-pr1-read-spec

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Nov 20, 2026 •

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:

Tracks #33035 (native schema evolution for restricted Instant ADD COLUMN; design record · revision 2). Related request: #12555.

This PR provides the read-layer and WAL recovery foundation for metadata-only NULL-default column addition with zero proto/ changes. ADD COLUMN and DROP COLUMN continue to use COPY in PR 1.

What this PR does / why we need it:

Old blocks and replayed batches can lack columns added after those rows were written. Use ColumnReadSpec (activated exclusively by features.IsSchemaEvolved on both CN and TN, and lazily cached per finalized TAE Schema) to give data reads, pruning, aggregates, ordered scans, Data Branch snapshot reads, replay, and statistics the same interpretation of absent columns.

  • Zero proto/ or pkg/pb/plan/ changes: initial implementation supports trailing nullable columns defaulting to NULL, resolving historical missing columns as typed NULL via features.SchemaEvolved and block MaxSeqnum.
  • Preserve persisted SchemaExtra metadata across catalog updates, keep sparse column sequences and the sequence high-water mark, reserve SEQNUM_ROWID in sparse layouts, use physical primarySeqnum for persisted PK ZoneMap checks (PKPersistedBetween), and map sparse column sequences to logical workspace positions in uncommitted read-your-writes scans and filters.
  • Use typed virtual vectors and metadata for missing columns (nullCnt = rows, ndv = 0, empty objects returning typed empty stats), and fail closed for missing columns within an object/batch layout across normal scans, committed logtail batches, and Data Branch snapshot scans.
  • Recover WAL column identity from the writer-visible historical schema (StartTS + catalog MVCC visibility), map renamed columns and primary keys by stable SeqNum, keep buffered workspace column names aligned across in-transaction RENAME COLUMN and PrepareCommit (preserving identity across checkpoints and same-type column name swaps), normalize known 4.2 built-in system-table legacy text charset metadata on WAL replay, validate source layouts fail-closed, and stage all fallible positional allocations (including in-range NULL bitmap expansion via nulls.TryExpand) before deleting overwritten primary-key entries.
  • Cover committed in-memory Bloom filters, delete rewrites, empty object metadata, and pool-free callers.
  • ADD COLUMN and DROP COLUMN continue to use COPY.

Follow-up fixes

  • Preserve the same hidden rowid sequence when rebuilding an ordinary system catalog schema repeatedly. A sparse or reordered schema uses the reserved rowid sequence.
  • Recover legacy named append WAL after a rename and an intervening checkpoint. For transactions that started before the checkpoint, recovery can restore column names by ordinal when the checkpoint retained a complete dense layout, the payload matches the full ordered format and column types, and the allocation watermark proves no sequence was retired. Other layouts still require the writer-visible schema. This uses the existing WAL and protobuf formats.
  • Project change-range inserts in the selected schema's logical order. In-memory logtail, CN-created objects, and appendable objects share the same typed-NULL and missing-interior-slot rules. The projected layout preserves row IDs and commit timestamps.

Checkpoint WAL replay follow-up

Checkpoint replay now rejects an older append when its column order differs from the checkpoint schema and the original mapping cannot be proved. This prevents same-typed columns from silently exchanging values, including the primary key. The error identifies the table and checkpoint schema version and stops recovery before the ambiguous payload is installed.

  • Added the retired-sequence name-swap regression to TestRecoverCheckpointAppendNames. It checks that the ambiguous mapping is rejected and the payload is unchanged.
  • Local validation on 9325ce38fdd9c3bd37d29c1d4509620065abb041: full tae/txn/txnimpl package, focused TAE restart and append tests, and git diff --check passed.
  • Stopped v4.2.9 TAE upgrade: both fixtures had a global checkpoint between the rename and the old writer's commit. The two-column control read key 1 and payload 42 after restart. A fixture with a previously dropped third column recovered key 42 and payload 1 on the previous PR head. The fixed head rejected the ambiguous append during recovery.
  • BVT: N/A for this follow-up. It requires opening a stopped older-version TN with a checkpoint and unflushed WAL containing this retained sequence history. PR 1's SQL ADD/DROP takes the COPY path. The stopped-upgrade probe exercises the recovery entry point directly.

Validation

  • Follow-up commit 1aa7525e91ab5e748d32158c826f437c5a5d6c27 passed targeted catalog, TAE replay and change-range regressions. Full local tests passed in catalog, objectio, disttae, disttae/logtailreplay, tae/catalog, and tae/txn/txnimpl during the follow-up, with targeted reruns after the final changes.

  • Two stopped v4.2.9 TAE directories with a global checkpoint between the rename commit and the old writer's commit reopened successfully. Both a one-column rename and a same-type name swap recovered PK 1 and payload 42 through point lookup.

  • Executed the checked-in auto_increment_no_pk_metadata.sql in an embedded two-CN cluster and compared all column names and rows with the checked-in expectations using the Go SQL driver. The local Java runner could not parse the expectation file. make err-check and git diff --check passed.

  • Local test suite passed on commit 45e8276758837b8c94be429f2de95069b351a67f (rebased onto main c90a2c4e579):

    • mo-cgo-test -count=1 across 17 affected packages (14 passed, 3 no test files);
    • Focused -race -count=1 regressions across tae/tables, tae/db/test, and disttae covering TestApplyAppendAtInRangeNullBitmapFailure, TestApplyAppendAtWALFillFailurePreservesRowsAndPrimaryKey, TestReplayAppendAcrossColumnRename, TestReplayAppendAcrossCheckpointColumnRename (rename / swap / swap_without_checkpoint), TestReplayAppendWithSameTxnColumnRename (5 same-txn orderings), TestReplayAppendLegacyCatalogWALTextType, TestWorkspaceReadsSparseColumnSequences, TestPrimaryKeysMayBeUpsertedSparsePrimaryKey, and TestScanSnapshotWithCurrentRangesColumnReadSpec (persisted & committed tail/hole);
    • Stopped-upgrade WAL replay verified from published v4.2.9 (6c05e42f9f660a207077b050b8ec285ccf3f8103) with unflushed committed append WAL (wal-1.rot, watermark=5, checkpointed LSN=0) for both an ordinary table and a renamed-column table: recovered original rows (1,101) and (11,201),(12,202) via scan and PK lookup, then committed and read back new rows (2,102) and (13,203);
    • make err-check, repo-wide go vet -mod=readonly ./..., repo-wide molint check -mod=readonly ./..., golangci-lint run --new-from-rev upstream/main (0 issues), git diff --check, and zero diff under proto/ and pkg/pb/plan/.
  • QA required: yes. CI on the updated head and multi-CN/performance qualification remain separate checks.

Validation after syncing main at 9bf005bfcd06

The eight top-level tests reported by the previous x86 UT job passed in focused local runs on Darwin ARM64. TestDataBranchFractionalTemporalPrimaryKey also passed with -race on both 9325ce38fdd9 and 524fe81d2a94. The CI artifact truncated the failing assertion, so its cause remains unconfirmed. Snapshot projection, checkpoint recovery and WAL replay regressions passed after adapting the replay fixture to the encoded batch API. Both changed packages passed molint and golangci-lint. The full local molint invocation stopped with 535 JSON results for 536 selected actions. Full Linux CI validation is pending.

Change-range prefetch cancellation

Addresses the P2 review on 84fbaca77b5e. CN object and appendable-window prefetch now cancel sibling reads at the first failure, then drain those jobs and preserve the original error for snapshot fallback.

The new regression reproduced the caller deadline on the previous commit for both CN read orders and the appendable-window path. On 67b345e930a8, the logtailreplay package suite passed. The new and existing cancellation regressions passed 20 repetitions each with -race. Scoped molint, golangci-lint, and git diff --check also passed. The regression uses a file-service stub to control read ordering and cancellation.

Rebase and string-width WAL recovery

Rebased the seven PR commits onto MatrixOne main 38c68d02ca62, including the maintainer's direct-vector fixture changes. The result uses the upstream positional TAE batch API and maps separately decoded WAL column names through the historical source schema.

Addresses the P1 WAL recovery review. A checkpoint can reconstruct a wider CHAR or VARCHAR schema while committed append WAL still contains vectors with the previous width. Replay accepts the old width when the type, storage size, scale, charset and collation match. The sequence and column-layout validation still applies.

For the API review, the edit is in the handwritten CloneExtra helper in pkg/pb/api/api.go. It copies FromPublication, which is already field 15 in proto/api.proto. The rebase has zero proto or generated protobuf changes.

Local verification at 262c6fc26244:

  • The previous implementation rejected the narrower CHAR and VARCHAR vector fixtures. The updated tests also verify rejection for non-compatible widths, charsets, and collations.
  • A checkpoint/WAL fixture produced from the v4.2.9 source tag through the TAE API recovered the original row from an unflushed object on this head. The recovered schema accepted and read back a new value longer than the original width.
  • Seven affected packages passed targeted tests. The complete tables, txnimpl and logtailreplay package suites passed. make err-check and git diff --check passed.

Read-test fixture update

At ddb744d844d5, adapted the ObjectIO and reader regression fixtures to the current batch, vector, and row-bitmap APIs. The tests cover typed NULLs for absent columns, selected-row and TopN reads, and tombstone reads with the data schema disabled. The bitmap selection checks distinct rows in physical order.

The complete pkg/objectio and pkg/vm/engine/readutil suites passed locally on Darwin ARM64 with -race -count=1. Scoped go vet, molint, and git diff --check passed. The previous Linux run failed to compile these fixtures in the unit, static-analysis, and coverage jobs. Linux CI for this commit is pending.

Checkpoint WAL recovery after rename and widening

Addresses the P1 review on ddb744d844d5. A transaction can start with a VARCHAR(8) column and commit its append after a checkpoint records that column under a new name with width 32. The checkpoint fallback now uses the same CHAR/VARCHAR compatibility rule as WAL installation. The fallback still requires a provable dense column layout and rejects ambiguous column identities.

  • TestReplayAppendAfterCheckpointStringWidening covers both widening alone and rename plus widening. The combined case reproduced a restart panic at WAL column resolution on the previous PR head. Both cases pass on 3a22f67b30ce and verify the recovered old row and a new write exceeding the old width.
  • A separate stopped checkpoint/WAL fixture produced through the v4.2.9 TAE API reopened on 3a22f67b30ce. The probe verified the old row, the renamed column, and a longer new value. This validates the TAE recovery path. SQL-level upgrade validation remains outside this run.
  • Merged main at 6674873fdfde and resolved conflicts against the direct-vector API. Full tae/tables and tae/txn/txnimpl suites, focused regressions across five affected packages, scoped molint and golangci-lint, make err-check, and git diff --check passed locally on the updated head.

Change-range reads after string widening

Addresses the change-range review. Evolved-table change ranges now reuse the WAL type-compatibility rule when projecting historical logtail rows and persisted blocks. A narrower stored CHAR or VARCHAR is read at the current schema width when the storage type, charset, and collation match. The existing checks for incompatible types and missing interior columns still apply.

  • On Linux/amd64, the new regression reproduced the type error on the previous head for logtail, CN-created objects, and appendable objects. The repaired code read the original payloads at the current width and rejected wider stored types and interior gaps.
  • Focused tests with Go vet enabled passed across ObjectIO, disttae, logtailreplay, TAE tables, txnimpl, and TAE restart tests. Focused change-range and prefetch-cancellation tests passed with the race detector. git diff --check passed.
  • BVT: N/A for this regression. This PR keeps SQL ADD/DROP on the COPY path, so the evolved-table flag needed by this scenario is supplied by a test fixture at the production change-range entry point.

Validated source commit: b0d7fe96ddee1a29c7cb3774d94e43006b5feacc.

@mergify mergify Bot added the kind/refactor Code refactor label Nov 20, 2026
@VioletQwQ-0
VioletQwQ-0 marked this pull request as ready for review November 20, 2026 07:56
@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 →

@mergify

mergify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

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

Codex automated review

This PR adds the read-layer foundation for metadata-only column addition, and I found no blocking defect. The new ColumnReadSpec machinery (virtual column metadata, frozen-default materialization, prune/aggregate/statistic integration) is gated behind the SchemaEvolved feature bit and the HasOriginDefault proto field, neither of which any production DDL in this PR sets — ADD/DROP still use COPY and buildCopyTableDef clears the flag — so all existing dense-table behavior is unchanged, which I verified path by path: MustGetColumn replaces unguarded ColumnMeta reads safely, ForeachVisibleObjects is called with a nil executor so the removed mutex in MaxAndMinValues/GetColumMetadataScanInfo was vestigial, MergeZM no-ops on uninited zone maps, the seek/filter error plumbing fails loud only for genuinely corrupt layouts, and primarySeqnum/NextColSeqnum computations are equivalent for dense layouts while fixing sparse rebuilds (rowid now reserved at SEQNUM_ROWID). The proto change is append-only and unknown-field tolerant in both directions. WAL replay fills roll back on allocation failure via append checkpoints, and tombstone reads correctly strip the data spec. There were no prior reviews or inline comments to deduplicate. Caveats: I could not execute the test suite here because this worktree lacks the built cgo/thirdparties prerequisites (the documented mo-cgo-test runner refused primary-worktree artifact reuse, plain go test fails compiling matrixone/cgo headers, and CGO_ENABLED=0 fails on mpool's C allocator); per the review constraints I did not build them, so test results are limited to the author's report of the focused suite passing on this same tree plus my gofmt/whitespace checks. Two non-blocking notes follow; the author's stated remaining multi-CN/upgrade/SQL-level QA stands as the main residual risk for the series.

P2 - Schema.ColumnReadSpec re-decodes every column default on each scan window and replay fill (pkg/vm/engine/tae/tables/mnode.go:257)

mnode.getDataWindowLocked calls readSchema.ColumnReadSpec() for every windowed memory-node scan, and missingWALColumns calls schema.ColumnReadSpec() for every replayed append batch that lacks a column. Each call unmarshals the plan.Default bytes of every column and rebuilds the bySeqnum map. Catalog schema versions are immutable per version, so the decoded spec could be memoized on the Schema (with the error returned once) to avoid repeated per-window decodes once schema-evolved tables go live in the next PR. Behavior is correct today and the cost only appears for feature-flagged tables, so this is non-blocking.

P2 - Unsupported frozen literals surface only as query-time internal errors (pkg/objectio/column_read_spec.go:414)

decodeReadDefault rejects scalar float16/bf16/float8/float4 literals (explicitly awaiting plan.Literal support) and mismatched literal/type combinations, and newColumnReadEntry stores the error to be raised only when a read materializes the value. Consequently a table whose frozen default is one of these forms will fail every scan with 'unsupported origin default' rather than failing at schema-definition time. Since no production DDL in this PR sets HasOriginDefault, exposure is limited to tests, but when PR 2 introduces the write path, validating origin defaults eagerly at ALTER/CREATE time would turn these into DDL errors instead of runtime query failures.

@XuPeng-SH

XuPeng-SH commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 4fd9920cc0beb63b7da5bb66e789d7b3c134cdc1

Review completed. Read the assessment.

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

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

Commit: 4fd9920cc0beb63b7da5bb66e789d7b3c134cdc1

Assessment: request_changes

ColumnReadSpec gives readers a shared representation for physically absent columns. CN and TN still activate it differently, and positional WAL replay can leave the primary-key index out of sync with the row vectors when a default fill fails. The cross-subsystem refactor also needs the repository-required design record.

Model: gpt-6.2-sol / xhigh

Session: 01a1ee80-0d82-7030-a965-b51f496c3054 · slot 2 · generation 1

  • P2 pkg/vm/engine/tae/tables/appender.go:206: A positional WAL payload overwrites an existing row in a schema-evolved table, and filling a missing column returns an allocation or decoding error.
    Impact: The old row survives in the vectors, but its primary-key index entry has already been removed. The failed operation leaves data and index state inconsistent.
    Evidence: ApplyAppendAt deletes the old key before calling ApplyAppendAtLocked. The new fill code at mnode.go:400 stages and rolls back vector changes only. Stage the fallible fill before deleting keys, or restore the keys when the fill fails. Exercise the appender entry point in the failure test.

  • P2 pkg/objectio/column_read_spec.go:68: A column definition carries HasOriginDefault before the table carries SchemaEvolved. TestColumnReadSpecTypes explicitly exercises this state.
    Impact: CN resolves a missing physical column to the frozen value, while TN resolves the same schema and row to NULL. If this state reaches compaction, TN can materialize a different value from the one CN reads.
    Evidence: NewColumnReadSpecFromTableDef accepts the annotation alone. Schema.ColumnReadSpec at pkg/vm/engine/tae/catalog/schema.go:192 returns nil until the feature bit is set. Use one activation rule for both readers, or enforce that annotation-only definitions cannot reach execution. This phase has no SQL DDL writer for that state.

  • P2 pkg/objectio/column_read_spec.go:46: The schema-evolution series changes persisted metadata interpretation across catalog, object I/O, WAL replay, CN and TN reads, and query execution.
    Impact: The required design record is missing from the frozen inputs. The PR description leaves the activation invariant, replay failure boundary, and validation against supported release artifacts open.
    Evidence: The pinned .agents/skills/mo-dev/references/feature-design-review.md, sections 1 and 2, requires an accessible revisioned design for this scope, including split PRs. Link or extend a design record covering those decisions and how the staged rollout will verify them.

Validation:

  • Isolation preflight, frozen head and patch verification, tree identity, and git diff --check passed. See preflight.log, scope.log, and receipts 1795229174201929541-3 and 1795229174534621688-3.

  • The generated Go audit and descriptor comparison confirmed that the protobuf schema changes add only Default fields 4 and 5. See receipts 1795229735591414069-3 and 1795229785182633893-3.

  • The selected catalog and objectio tests reported terminal package passes on Go 1.27.1 before the broader command timed out. See focused-retry.jsonl and receipt 1795229800363450588-2.

Limitations:

  • The remaining package checks and the replay overlay reached foreground limits before test execution. The final diagnostic trace stopped at linking. See receipts 1795230185853198722-2, 1795230412688055571-2, and 1795230524813703445-2.

  • The findings rely on source flow and the completed objectio tests. The frozen upgrade CI jobs were skipped, and the review has no release-produced upgrade artifact or live multi-CN run with an evolved schema.

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

I found that you, or your AI buddy, really like to make changes to proto/api etc. Are these change really necessary? Why do you need that? Most likely all these changes are not the right places.

@XuPeng-SH

XuPeng-SH commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 4fd9920cc0beb63b7da5bb66e789d7b3c134cdc1

Review completed. Read the assessment.

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

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

Commit: 4fd9920cc0beb63b7da5bb66e789d7b3c134cdc1

Assessment: request_changes

Historical defaults belong in persisted column metadata because insert defaults can change later. The existing plan.Default envelope can carry that distinction, but the current target branch's catalog projections discard both new fields. This adds a finding to the prior same-head assessment.

Model: gpt-6.2-sol / xhigh

Session: 01a1ed86-9b09-7303-8d78-76024e7bf652 · slot 3 · generation 0

  • P2 proto/plan.proto:494: A CN rebuilds its catalog schema on the current target after a column definition carries a frozen default.
    Impact: The published schema loses the historical default. A non-NULL frozen value can become NULL in CN reads while TN still reads the persisted value.
    Evidence: At target cc2c82d, CatalogZeroDefault classifies a frozen NULL as an ordinary empty default, and CopyDefaultInto drops both new fields from nonzero defaults. Both paths feed newCandidateSchema in pkg/vm/engine/disttae/cache/schema_candidate.go:66. Update the existing sharing and copy helpers to preserve the distinction, with a catalog projection test.

  • P2 pkg/objectio/column_read_spec.go:68: A column has HasOriginDefault while its table lacks SchemaEvolved.
    Impact: CN can read the frozen value while TN reads NULL for the same missing column. Compaction can materialize that difference.
    Evidence: The CN constructor accepts the annotation alone. Schema.ColumnReadSpec at pkg/vm/engine/tae/catalog/schema.go:192 requires the feature bit. Use one activation rule or enforce the invariant before either reader can receive the definition.

  • P2 pkg/vm/engine/tae/tables/appender.go:206: A positional WAL append replaces an existing row and default filling fails.
    Impact: The appender returns with the old row still in its vectors and its primary-key index entry removed.
    Evidence: ApplyAppendAt deletes the key before the new fallible fill at mnode.go:400. Stage the fill before changing keys or restore the keys on failure. Exercise the appender entry point in the failure test.

  • P2 pkg/objectio/column_read_spec.go:46: The schema-evolution series changes persisted metadata interpretation across catalog publication, CN and TN reads, and WAL replay.
    Impact: The required design record leaves the activation invariant, replay failure boundary, and release-artifact validation open.
    Evidence: Sections 1 and 2 of the pinned feature-design-review.md apply to the full series. Issue #33035 outlines the rollout, and the target's catalog-ownership design covers schema projection. Extend either design record to settle the missing contracts.

Validation:

  • Verified the frozen checkout, patch, whitespace, identical pinned policy, and all seven discussion entries. See scope.log and receipts 1795366899950304923-5 and 1795366951156923204-5.

  • An isolated probe using the candidate's generated Default declaration and the target's two helper bodies reproduced both field losses. The legacy control passed. See default-projection.jsonl and receipt 1795366852912061279-5.

  • Reused the same-head descriptor audit and terminal catalog and objectio package passes. The broader Go invocation timed out. See evidence-audit.log.

Limitations:

  • The projection probe exercised the helper bodies. No merged-cluster run or release-produced upgrade artifact was available.

  • PR 1 retains COPY for SQL ADD and DROP. The frozen-default failures affect the staged read contract when the new metadata is supplied. Ordinary WAL recovery aborts on the appender error, and persisted index corruption was not demonstrated.

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

Need to go back to drawing board and redesign.

Comment thread proto/plan.proto Resolved
@XuPeng-SH

XuPeng-SH commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 4fd9920cc0beb63b7da5bb66e789d7b3c134cdc1

discussion changed before publication

@XuPeng-SH

XuPeng-SH commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 4fd9920cc0beb63b7da5bb66e789d7b3c134cdc1

New discussion was assessed; the previous review remains unchanged.

@XuPeng-SH

XuPeng-SH commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 4fd9920cc0beb63b7da5bb66e789d7b3c134cdc1

New discussion was assessed; the previous review remains unchanged.

@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 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 84fbaca77b5e881ac537cca0333b2bd8a50736e6

Review completed. Read the assessment.

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

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

Commit: 84fbaca77b5e881ac537cca0333b2bd8a50736e6

Assessment: request_changes

The shared, feature-gated NULL read specification reuses existing schema metadata, and the prior sparse-read, snapshot and replay concerns have corresponding fixes. One new cleanup path can block ordinary change-range recovery after a recoverable object-read failure.

Model: gpt-6.1-terra / max

Session: 01a21456-006d-7b41-b150-908a3e9d9152 · slot 3 · generation 6

  • P2 pkg/vm/engine/disttae/logtailreplay/change_handle.go:1322: An unbounded change-range read prefetches multiple CN-created blocks; one returns a missing-file error while another read remains stalled.
    Impact: The deferred cleanup waits for the other read without cancelling it. The missing-file error can be delayed until the caller’s deadline, or indefinitely without one, preventing Data Branch from starting its snapshot fallback. Ordinary tables are affected.
    Evidence: The jobs receive the parent context at lines 1339–1342, while releasePrefetchedChangeBlocks waits in GetResult at line 4560 without cancelling sibling work. The isolated candidate probe in focused-tests-seeded.log received the missing-file error immediately but did not return until its 750 ms context expired; the existing appendable-object cancellation control passed. A temporary cancellation overlay made the CN probe pass. Cancel outstanding reads when a job fails, preserve the original error, and then drain their results for cleanup.

Validation:

  • Isolation preflight passed; receipt checks/1795772280079032978-3.json.

  • Targeted TAE restart, sparse-workspace, snapshot and pruning tests passed; receipt checks/1795773292730369001-2.json and remaining-tests.log.

  • The focused candidate run exited 1 because the new CN prefetch probe failed as described; the existing cancellation control and selected WAL, bitmap and column-spec tests passed. See checks/1795772965763899438-2.json and focused-tests-seeded.log.

  • The temporary modified-source cancellation control passed; receipt checks/1795773391759568388-2.json and prefetch-cancel-control.log.

  • The frozen CI snapshot reports successful x86 unit and two multi-CN BVT jobs. Both upgrade compatibility jobs were skipped.

  • The discussion audit accounted for all 23 indexed keys, and git diff --check passed.

Limitations:

  • The author’s stopped v4.2.9 retired-sequence fixture uses the TAE API directly and was not independently rerun. Its rejection is reflected in the source and unit test, but a supported SQL route to the same checkpoint state was not established.

  • The prefetch probe uses an isolated filesystem stub; it does not exercise a live remote object store or an end-to-end Data Branch recovery.

  • No local performance comparison or full production upgrade was run.

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

You do not edit pb/api/api.go by hand. Where is the proto file change?

@XuPeng-SH

XuPeng-SH commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: f0a84b5323c4e2454fefb4cb5541fae73879e16f

Review completed. Read the assessment.

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

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

Commit: f0a84b5323c4e2454fefb4cb5541fae73879e16f

Assessment: request_changes

The shared, feature-gated read specification reuses existing schema metadata, and the earlier sparse-read, snapshot, and allocation-failure concerns have fixes. A supported in-place VARCHAR widening exposes a released-WAL recovery failure that the reported upgrade controls did not cover. The latest protobuf concern is disputed: the changed api.go is handwritten and copies a field already declared in api.proto.

Model: gpt-6.1-terra / max

Session: 01a21ea6-2de2-71f3-b7d7-f3fe6df56dd8 · slot 0 · generation 27

  • P1 pkg/vm/engine/tae/tables/mnode.go:395: On v4.2.9, widen a VARCHAR column in place, checkpoint the updated catalog, then commit a small insert whose append WAL remains unflushed before restart or upgrade.
    Impact: Recovery rejects the valid append and panics, preventing the TN from starting and the committed row from being recovered.
    Evidence: The released planner permits in-place VARCHAR widening, while ReplaceDef is applied only on the CN; the TN continues to write append vectors using its original schema width. Checkpoint replay reconstructs the widened type from the catalog, but Type.Eq compares widths, so the new validation rejects the old-width WAL vector. The author's released-WAL controls cover ordinary and renamed columns, not this widening sequence. Preserve compatible widened storage types while retaining identity and collation checks, and add a release-produced checkpoint/WAL restart regression that verifies reads and a new write.

Validation:

  • Isolation preflight passed: preflight.log and checks/1795812837021235027-3.json.

  • git diff --check passed: diff-check.log and checks/1795813200394941110-3.json.

  • The released-source and replay-flow audits passed: source-audit.log, wal-width-source-audit.log, and checks/1795813413860818869-3.json and checks/1795813705757542226-3.json.

  • All 26 discussion entries were accounted for: discussion-assessment.json, discussion-audit-final.log, and checks/1795813673607490920-3.json.

  • The frozen CI snapshot reports successful x86 unit tests and proxy and pessimistic multi-CN BVT jobs; both upgrade compatibility jobs were skipped.

Limitations:

  • The widening failure is established by cross-version source tracing; no product binary or release artifact was executed locally for this case.

  • The author's reported v4.2.9 recovery checks used an earlier candidate and did not exercise in-place width changes across a checkpoint.

VioletQwQ-0 and others added 9 commits December 1, 2026 10:52
Resolve historical columns as typed NULL using the existing table feature
flag and physical layout across reads and metadata consumers.

Bind named WAL to the writer-visible schema and map renamed columns by
physical sequence. Keep buffered names aligned through rename and
checkpoint recovery. Stage positional writes that require allocation
before replacing rows or primary-key entries.

Resolve sparse workspace column positions for projections and filters.
Preserve dropped-slot checks for logtail and Data Branch snapshots.
Accept the released catalog text metadata when replaying 4.2 WAL.
@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: ddb744d844d5ba582c42d5679e6d90a8fb439ddb

Review completed. Read the assessment.

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

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

Commit: ddb744d844d5ba582c42d5679e6d90a8fb439ddb

Assessment: request_changes

The shared read specification reuses existing schema metadata without changing the wire format. The earlier width-only WAL recovery issue is addressed, but recovery still rejects a valid combination of column rename and string widening across a checkpoint. The separate concern about editing generated protobuf code is disputed: api.go is handwritten and copies an existing field.

Model: gpt-6.1-terra / max

Session: 01a22b07-00b6-7e32-b0a1-3099d0b867c7 · slot 1 · generation 39

  • P1 pkg/vm/engine/tae/txn/txnimpl/replaystore.go:292: A v4.2.9 writer starts with a column named value of type VARCHAR(8); the column is renamed and widened to VARCHAR(32), a checkpoint captures the new catalog schema, and the old writer commits an unflushed append afterward.
    Impact: On restart or shutdown upgrade, replay rejects the committed append and panics, preventing the TN from starting and recovering the row.
    Evidence: The released planner permits in-place rename and CHAR/VARCHAR widening. When the checkpoint has discarded the writer's schema, replay enters recoverCheckpointAppendNames, whose exact Type.Eq check rejects width 8 against width 32. The later installer explicitly accepts that safe widening in appendTypeCompatible. An isolated probe using the frozen helper bodies reproduced the rejection; same-width rename and the installer width predicate were controls. Apply compatible-width handling during checkpoint layout inference while retaining identity, charset and collation checks, and add a release-produced restart regression covering the combined case and subsequent writes.

Validation:

  • Isolation preflight passed; receipt checks/1796106872619610858-3.json.

  • The isolated Go 1.27.1 probe confirmed the combined rejection and its controls; receipt checks/1796107939838201041-3.json and wal-width-rename-go127.log. The copied function bodies were matched to the frozen checkout by checks/1796107618657786431-3.json.

  • git diff --check passed; receipt checks/1796107733682083962-3.json. The discussion assessment accounts for all 28 indexed entries.

  • The frozen CI snapshot reports successful shared build, x86 unit tests, and proxy and pessimistic multi-CN BVT jobs. Both release-compatibility jobs were skipped.

Limitations:

  • The combined rename-and-widening case was not executed locally through a full released SQL or TAE restart. The diagnostic probe uses copied helper bodies and stubs; the supplied release-produced fixtures are author-reported and cover rename and widening separately.

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 3a22f67b30ce63e94a6629f16b52ec97bb07e262

Review completed. Read the assessment.

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

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

Commit: 3a22f67b30ce63e94a6629f16b52ec97bb07e262

Assessment: request_changes

The shared NULL read specification and historical WAL handling reuse existing schema metadata. The earlier rename-and-widen replay concern is addressed, but change-range projection rejects valid older-width string values in an evolved table. The SQL writer that sets the evolved flag is planned for a later PR; this finding concerns the read foundation delivered here. The discussion about pkg/pb/api/api.go concerns a handwritten helper copying an existing protobuf field, so it does not require a proto change.

Model: gpt-6.1-terra / max

Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45

  • P2 pkg/vm/engine/disttae/logtailreplay/change_handle.go:4828: An evolved table is read through a change range after a CHAR or VARCHAR column was widened in place, while an older object or committed logtail batch still carries the narrower type.
    Impact: Data Branch and other change-range consumers receive an internal type error instead of the existing row. This affects the staged evolved-table reader once the feature flag is supplied; SQL ADD and DROP remain on COPY in this PR.
    Evidence: This comparison requires exact types.Type.Eq equality, including width; appendProjectedInsert has the same check at line 4493. Existing in-place ALTER permits string widening, and TAE WAL replay accepts a narrower compatible string type. A focused test overlay against the candidate reproduced errors for VARCHAR(8) logtail and persisted-object values under a VARCHAR(32) read schema, while both equal-width controls passed. Applying the replay compatibility rule in a temporary production overlay made all four cases pass. Use a shared compatible-width rule for both projection paths, retain the other type and collation checks, and cover both storage representations.

Validation:

  • Isolation preflight and git diff --check passed; receipts 1796120363021827992-3 and 1796120843996517342-3.

  • Built native prerequisites in a diagnostic clone using make cgo and verified their provenance against the frozen head; receipts 1796121305336467953-3 and 1796121334783346980-3.

  • The candidate's TestSnapshotStateChangeRangeProjectsEvolvedColumns and TestReplayAppendAfterCheckpointStringWidening passed with the isolated executor; focused-product-tests.log, receipt 1796121844214000156-4.

  • The temporary test overlay reproduced both width failures on the candidate; receipt 1796121724025546053-4. A temporary compatibility-rule overlay passed the same four cases; receipt 1796121798673898760-4.

  • The supplied exact-head CI snapshot reports successful unit and two multi-CN BVT jobs.

Limitations:

  • The width reproduction exercises the internal change-range entry point with an evolved-schema fixture; this PR does not expose SQL Instant ADD.

  • The supplied release-upgrade CI jobs were skipped. The author's reported v4.2.9 TAE upgrade fixture was not independently rerun.

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: b0d7fe96ddee1a29c7cb3774d94e43006b5feacc

Review completed. Read the assessment.

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

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

Commit: b0d7fe96ddee1a29c7cb3774d94e43006b5feacc

Assessment: approve

The NULL-only read foundation reuses schema sequence metadata and a shared read specification across CN and TN. WAL staging protects row and primary-key state on allocation failure. The latest change resolves the prior string-width finding for both logtail and persisted change-range reads. SQL ADD and DROP remain on the COPY path. The disputed protobuf edit is a handwritten helper copying an existing field.

Model: gpt-6.1-terra / max

Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45

Validation:

  • Isolation preflight and native provenance verification passed; receipts 1796129823496053519-3 and 1796129846734979483-3.

  • Focused change-range and checkpoint replay tests passed, including narrower and incompatible string widths; receipt 1796130079203368201-3 and focused-tests.log.

  • Sparse workspace and snapshot reads, cancellation, allocation-failure handling, catalog caching, and checkpoint-name recovery tests passed; receipt 1796130256912978601-3 and regression-tests.log.

  • Reader, pruning, aggregate, rename-replay, in-memory and persisted-node tests passed; receipts 1796130653637198680-3 and 1796130941465536109-3, with consumer-tests.log and tae-node-tests.log.

  • git diff --check passed; receipt 1796130734254582570-3. The supplied CI snapshot reports successful x86 unit tests and multi-CN proxy and pessimistic BVT jobs.

Limitations:

  • The author reports stopped v4.2.9 TAE/WAL upgrade runs using identified release artifacts; their raw logs were not supplied. Release-upgrade CI was skipped, and a full service upgrade was not independently run.

  • The author reports checking the changed SQL fixture in an embedded two-CN cluster. This review did not independently run mo-tester or verify that fixture's selection in the supplied BVT job logs.

  • Checks ran against the frozen PR head, not a synthesized merge with the newer target. Broader distributed rollout and performance qualification are assigned to the later PR in the series.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

合并后验证交接(表结构演进入读取和恢复基础)

本 PR 已合入 main(32ffdd4ac2722972be184af63906c8f23901e323,合并前 PR 提交 f5573e0a895fc0c045d3ec9ae41205efa7750b2b)。这一阶段统一了历史列的读取和日志回放规则,SQL 的 ADD/DROP 仍走 COPY。即时加列入口和完整验收继续由 #33035 跟踪。

  • 已有证据:PR 正文记录了旧版本停机目录的恢复验证和针对读取、重启与并发取消的回归。最新一轮 PR CI 中,共享构建完成,单测、静态检查、覆盖率以及两项多计算节点端到端检查被取消,必需检查未通过。
  • 合入版本待验证:用 v4.2.9 停机目录升级并回放跨重命名或扩宽的未刷盘追加。重启后分别全表扫描和按主键读取,确认主键和原值一致,并确认可成功写入、读回超过旧列宽的新值。有歧义的列映射应停止恢复并报错,避免值落到错误列。
  • 系列后续验收:即时加列入口接通后,在多计算节点上检查旧行的新增尾列为 NULL、新写入值正确,并比对快照、变更读取与重启后的结果。性能资格按 [Feature Request]: Native schema evolution for restricted Instant ADD COLUMN #33035 的后续阶段验证。

本留言记录第 1 阶段的验证范围与缺口,当前没有 QA 验收结果。

This branch was successfully deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor Code refactor size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants