Skip to content

fix(data branch): honor table clear boundaries in DIFF and PICK - #33233

Merged
mergify[bot] merged 13 commits into
matrixorigin:mainfrom
VioletQwQ-0:fix/data-branch-issue-32003-post-merge
Nov 26, 2026
Merged

mergify[bot] merged 13 commits into
matrixorigin:mainfrom
VioletQwQ-0:fix/data-branch-issue-32003-post-merge

Conversation

@VioletQwQ-0

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

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

issue #32003

What this PR does / why we need it:

An unconditional DELETE can use the same physical table replacement path as TRUNCATE. Data Branch previously recorded that replacement as row-preserving ALTER lineage. Subsequent DIFF and PICK could retain changes from the cleared generation without seeing the implied deletions. In the reported sequence, PICK returned success without restoring the requested row.

Record clear boundaries in existing branch lineage metadata and reconstruct changes against the appropriate comparison snapshot. Keep COPY ALTER row-preserving; do not infer clear boundaries retroactively from legacy ALTER records or missing history.

  • Apply both halves of a mixed PICK batch: restore independently deleted keys and still update the surviving keys.
  • In bounded PICK across a clear, limit insert/update columns to the source layout at the upper snapshot. Preserve destination values for later columns on UPDATE and use destination defaults on INSERT.
  • Reject matching-row comparisons when a shared column's historical introduction value cannot be reconstructed, rather than silently treating it as unchanged.

Validation on f42550e540b (base dc204213996, including #32970 and #32971):

  • All three review cases reproduced on 8734ac51866 and were added to test/distributed/cases/git4data/branch/merge/merge_issue_32003.sql.
  • 295 focused unit tests and embedded SQL TestDataBranchAfterTableClear / TestDataBranchClearBoundaryAfterGC passed.
  • Exact-head local BVT: 385/385 statements, no skips. This covers merge_issue_32003, branch_rebuild_lifecycle, diff_older_ancestor_snapshot and diff_output_as_altered_columns.

Validation on ee35455eb5a:

  • The bounded PICK hydration regression checks both an upper snapshot before the ALTER and one at the ALTER. Both assert that the upper-snapshot relation supplies the renamed and newly added column values, while preserving the row ID and commit timestamp. Six related frontend tests passed in three consecutive local runs.
  • The previously failing Ubuntu unit and coverage jobs on 5f5b752c299 both stopped at the stale upper-snapshot mock expectation. CI for the new head is tracked separately.

QA required: yes. The fix changes persisted lineage interpretation and SQL-visible Data Branch behavior. Local SQL verifies final rows and error outcomes, including restart/GC coverage. Multi-CN/Proxy on the PR head remains pending.

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

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Addressed the bounded PICK review finding in 0245b168708b. Existing-row updates now explicitly retain omitted destination ON UPDATE columns in staged, native, and special-column apply paths. Inserts still use destination defaults. The canonical issue #32003 SQL fixture failed before the fix (only the newly inserted row retained the expected timestamp), then passed with the fix. Focused single-CN BVT: 565/565; focused frontend tests and static checks passed.

@XuPeng-SH

XuPeng-SH commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 0245b168708bafc630d62bc303af2afc69540952

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: 0245b168708bafc630d62bc303af2afc69540952

Assessment: request_changes

The prior ON UPDATE finding is resolved on the PR head, but the clean textual merge with the pinned target branch fails to compile. The clear-boundary design otherwise reuses the existing branch lineage and snapshot lifecycle; reconstructing visible state is needed to recover changes lost by a physical clear.

Model: gpt-6.1-terra / max

Session: 01a215d1-7203-74e1-813a-2513cddd0c27 · slot 0 · generation 15

  • P1 pkg/frontend/data_branch.go:2260: Merge this head into the pinned main target e5d6f92.
    Impact: The merged frontend package cannot compile, blocking the MatrixOne build and tests for the merge.
    Evidence: This PR changes constructChangeHandle's tables argument to *tableStuff. The target branch independently added currentBaseChangesHandle with a tableStuff value field and initializes it with tables. The files merge without a textual conflict, but a focused build using their merged contents fails with "cannot use tables (variable of type *tableStuff) as tableStuff value in struct literal"; see target-merge-build.log and checks/1795668272780576735-2.json. Reconcile the target wrapper when rebasing, for example by passing *tables. A temporary dereference made the focused build and three relevant tests pass.

Validation:

  • The prior ON UPDATE SQL reproducer passed on the assigned head, preserving the destination timestamp. The embedded merge_issue_32003 SQL fixture also passed; see on-update-probe.log and merge-fixture.log.

  • Twelve focused tests passed across frontend, databranchutils, and sql/compile. Isolation preflight, native-input provenance, and git diff --check passed.

  • The supplied patch matches the merge-base-to-head diff apart from its final newline. All 27 changed paths and six discussion keys are recorded; receipts and logs are reconciled in validation-audit.json.

Limitations:

  • The target integration build used an overlay of the two merged frontend production files, not a full build of the merged target tree.

  • A separate bounded PICK probe with no source clear overwrote a later destination column on both the PR head and the frozen merge base. It is preexisting and is not included as a PR finding.

  • The frozen CI snapshot includes a non-required Connector/J Pool Reset E2E failure; its failure details were not supplied.

@XuPeng-SH

XuPeng-SH commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: ee35455eb5a9df438c3ef81947e7ba262851e253

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: ee35455eb5a9df438c3ef81947e7ba262851e253

Assessment: approve

No actionable regressions found. The clear-boundary design reuses the existing lineage and snapshot lifecycle; reconstructing visible rows is necessary to recover changes lost by physical clears. The earlier ON UPDATE and target-merge compilation findings are resolved on this head.

Model: gpt-6.1-terra / max

Session: 01a216bc-adbc-7142-8f93-6b94a5827118 · slot 0 · generation 16

Validation:

  • Isolation preflight and native-input audit passed. Focused race tests passed for clear reconciliation, historical hydration, apply writers, lineage metadata and snapshot compaction; see focused-race-retry.log, lineage-race.log and validation-audit.json.

  • The embedded issue SQL fixture, merge and keyless-row cases passed. The clear-boundary test also passed after object reclamation and service restart; see embedded-sql.log and embedded-gc.log.

  • The discussion assessment covers all eight discussion keys. git diff --check passed. The frozen CI snapshot reports successful build, unit, coverage, proxy and pessimistic multi-CN checks.

Limitations:

  • A bounded PICK without a source clear can report a conflict when the only differing destination column was added after the upper snapshot. The same SQL probe reproduced this behavior on both the reviewed head and the merge base, so it is preexisting; see bounded-probe.log and baseline-probe.log.

  • Multi-CN, released-binary upgrade and backup/restore tests were not independently run. The frozen CI snapshot does not specify whether its multi-CN jobs exercised this fixture.

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 484af86 at 10:56 UTC

1 h 55 min in the queue, 1 h 52 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 09:01 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 10:56 · 484af86 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — c5fecdf5 Deployed Nov 26, 2026 by mergify[bot]
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/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants