Skip to content

[4.2-dev] fix(disttae): preserve inherited deletes when rewriting cloned objects - #33406

Merged
XuPeng-SH merged 3 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/33079-clone-delete-visibility-42
Nov 28, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/33079-clone-delete-visibility-42

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Nov 27, 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 #33079 on 4.2-dev. The corresponding main fix is #33405.

What this PR does / why we need it:

Rewriting a CLONE object in the transaction that created the clone used to apply only the pending DELETE offsets. Inherited tombstones still pointed to old RowIDs, allowing deleted rows copied into a replacement to become visible.

Stream the union of the destination table's live tombstones and pending offsets through each rewritten block. Existing zone maps select candidate tombstone files. Reuse a block-sized scratch slice per worker and the existing bounded object registry for uploads. Once metadata is published in the workspace, it owns the replacement. The originals remain live until every rewrite succeeds.

The 4.2 workspace can have applied maintenance to earlier statements when a rewrite fails. Use the existing full transaction rollback path in that case. Preserve the storage error and old workspace marks until rollback. The object registry retains unadopted uploads and retries transient cleanup failures.

Review follow-up

The regression now uses the serialized pkg/embed.RunBaseClusterTests fixture. It connects directly to two distinct CNs over MySQL, flushes the source data and source delete, and creates and rewrites the clone in one transaction. After COMMIT, the test waits for each CN to apply the writer's commit and compares the complete ordered (id, a) rows in both tables on both CNs. Cleanup rolls back the writer and drops the test database on a separate session before the fixture unlocks. Shared fixture review · Cross-CN visibility review

Validation on 4de762f6107031e5def4ec53b0cdea15462d946a

  • Base 4.2-dev is 78fe31d619bd88b0e7638d6178fa904125b23533. Only the embedded regression changed relative to fb76588.
  • Built the exact pkg/embed test target with -tags matrixone_test. TestCloneRewriteKeepsPersistedDeletesAcrossCNs and TestCloneDatabaseForeignKeySourceInventory passed five repetitions in the same process. Five separate pre-COMMIT interruption probes also verified that both CNs saw no remaining test database after rollback and cleanup. Work returned EPERM for Unix socket creation, so the local embedded test runs selected the TCP listener in a temporary startup overlay.
  • Ran the checked-in clone_delete_ownership.sql and .result with mo-tester at 309a0ca650e0c55e90292767fd61e4976818d66d in normal comparison mode. All 68 statements passed with zero ignored.
  • The existing TestWorkspaceRewriteTombstoneOffsets and TestCloneRewriteFailureRequiresFullRollback each passed five repetitions on this source tree. Both injected failure paths retained the originals, reclaimed replacement objects, and exercised reclamation retry for the ambiguous upload.
  • git diff --check passed. Hosted CI on this head is pending.

Previous validation on fb76588

  • The original two-CN integration fixture passed four executions, including a repeat after fetching its published source tree. The rollback and reclamation tests each passed ten times. The SQL fixture passed 68 statements with zero ignored using ordinary mo-tester comparison.
  • The shared build, ARM64 SCA, x86 UT, proxy and pessimistic Compose BVT, Shanghai OSS/COS, and Coverage Group 0 passed on this previous head. Coverage Group 1 was cancelled. Previous-head CI · Shanghai coverage artifact

Earlier hosted CI

  • The ARM64 SCA setup, x86 UT setup, shared build, Shanghai OSS/COS setup, proxy Compose launch, and pessimistic Compose launch each stopped after repeated HTTP 504 responses downloading ONNX Runtime. The failures occurred before analysis or test execution in those jobs. The Compose coverage steps also lacked the outputs of the failed launch. The new base includes the ONNX download fallback from [4.2-dev] Fix ONNX Runtime downloads when the primary endpoint fails #33408. Previous CI run
  • Coverage Group 1's selector received HTTP 403 reading and revoking worker metadata. The worker also hit a separate assertion in TestIvfCreateStart_Error/Invalid_params_json, and the coverage aggregate stopped because a required profile was unavailable. The failing test and Sonic dependency match the base. A local decoder probe with the same malformed input returned Syntax error on Go 1.26.4 and unexpected EOF when Go 1.27.1, the worker version, selected Sonic's standard-library fallback. Selector · Worker · Coverage aggregate

Earlier validation on 3fbe98e

  • On two CNs, all 57 rows in the clone ownership fixture and 20 more transaction observations matched, including source and sibling isolation, a same-transaction source DELETE, rollback and an empty replacement.
  • The 32,768-row multi-block probe resurrected two rows on the base and zero on the candidate. In 18 timed samples per case, including actual rewrite at the next statement boundary, median latency was 0.651 → 0.569 ms for ordinary DELETE, 23.759 → 21.282 ms for a clean clone and 23.727 → 21.526 ms for a clone with inherited tombstones. These timings are from the same local setup.
  • Failure injection covered a missing tombstone and an upload that wrote its file but returned an error. Full rollback preserved the original objects and reclaimed the recorded replacement. The registry reclaimed the unadopted upload after an injected delete failure.
  • The full disttae package passed under -race. Incremental SCA reported zero issues. Hosted CI runs separately.

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

Copy link
Copy Markdown
Contributor

This pull request is merged.

@XuPeng-SH

XuPeng-SH commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 3fbe98e0db5d653a32b21ac1b0e10a74a0d670f5

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: 3fbe98e0db5d653a32b21ac1b0e10a74a0d670f5

Assessment: request_changes

The fix reuses the existing tombstone loader and upload registry, and an isolated two-CN probe returned the expected rows. The checked-in regression still lacks the cross-CN and post-commit source assertions required by issue #33079.

Model: gpt-6.1-terra / max

Session: 01a21cfb-5763-7232-b26f-34ae1dc76e89 · slot 2 · generation 11

  • P2 test/distributed/cases/pessimistic_transaction/clone/clone_delete_ownership.sql:67: After committing the inherited-delete clone rewrite, read the source and clone from both the writing CN and another CN.
    Impact: The maintained regression does not protect the required cross-CN visibility and post-commit source-isolation behavior. A future change that returns correct rows on the writing session but stale or incorrect rows elsewhere could pass this case.
    Evidence: Issue #33079 explicitly requests full source and clone row sets after commit from another CN. The added case uses one session and checks only the clone after commit. A temporary two-CN review probe passed, but it is not part of the regression suite. Add a maintained public SQL test that checks both row sets on distinct CNs after commit, using the existing cluster fixture and commit synchronization or an equivalent mechanism.

Validation:

  • Private /tmp and loopback preflight passed: checks/1795805123898146320-2.json.

  • The full disttae package passed under the race detector: package-race.log and checks/1795805741399477107-2.json.

  • The tombstone-offset test passed 100 race repetitions and the rollback-failure test passed 28: stress-offsets.log, stress-rollback.log, and their matching receipts.

  • An isolated embedded-cluster SQL probe checked source and clone row sets through two distinct CN endpoints after commit and passed under race: crosscn-probe.log and checks/1795805648395097508-2.json.

  • git diff --check passed: diff-check.log and checks/1795805625510587156-2.json. Native build inputs were matched to the frozen checkout in native-provenance.log.

Limitations:

  • The exact mo-tester case was not run locally because its runner is not present in the checkout.

  • The supplied hosted CI snapshot contains failed and pending checks without failure logs, so their causes could not be attributed.

@XuPeng-SH

XuPeng-SH commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: fb76588a223cdc4bb1c5c7ced10d03594a316a64

linked issue or PR description changed before publication

@XuPeng-SH

XuPeng-SH commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: fb76588a223cdc4bb1c5c7ced10d03594a316a64

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

Assessment: request_changes

The fix reuses the existing tombstone reader and object ownership mechanisms. The maintained two-CN regression resolves the earlier visibility finding, but it adds an avoidable separate cluster to the package test suite.

Model: gpt-6.1-terra / max

Session: 01a21e6c-c4d8-75c3-9991-d2d324134f67 · slot 0 · generation 26

  • P2 pkg/embed/clone_delete_ownership_test.go:32: Each execution starts a dedicated log service, TN and two CNs, although pkg/embed already has a serialized shared three-CN fixture used by other clone tests.
    Impact: The additional cluster incurs recurring test-suite startup and service costs. In retained runs, the dedicated-cluster test took 16.98 seconds on a warm run, while the same scenario took 1.09–1.13 seconds after the shared fixture was started.
    Evidence: A diagnostic overlay retained the SQL, commit fence and full source/clone assertions on two distinct CNs, added database cleanup, and passed twice with RunBaseClusterTests; see /mnt/nvme/mo-bot-55-live/state/jobs/ffeac77141f8382db9480533/attempt-1/go-reuse-repeat.log and checks/1795809317469324243-2.json. The repository testing contract requires a concrete reason for an additional embedded cluster, and no incompatible shared state is established here. Reuse the shared fixture with rollback and database cleanup, or establish the specific isolation requirement that prevents it.

Validation:

  • Reused two passing exact-head executions of TestCloneRewriteKeepsPersistedDeletesAcrossCNs, including both CN subtests. Logs and receipts are in /mnt/nvme/mo-bot-55-live/state/jobs/ffeac77141f8382db9480533/attempt-1: go-crosscn.log, go-crosscn-repeat.log, checks/1795808969932662483-2.json and checks/1795809219889276233-2.json. The matching private-environment preflight passed in checks/1795808669544290217-3.json.

  • The shared-fixture diagnostic passed twice with the same SQL and row assertions; see go-reuse-repeat.log and checks/1795809317469324243-2.json in the same prior review directory.

  • The full disttae package passed under the race detector on 3fbe98e, and the focused tombstone-offset and rollback-failure tests passed 100 and 28 race repetitions respectively. The relevant disttae files are unchanged at this head. Logs and receipts are in /mnt/nvme/mo-bot-55-live/state/jobs/923cedffaffb80208e21426a/attempt-1.

  • Exact-head git diff --check passed: /mnt/nvme/mo-bot-55-live/state/jobs/ffeac77141f8382db9480533/attempt-1/checks/1795809005677650067-2.json.

Limitations:

  • The PR reports a successful normal mo-tester comparison of the changed SQL fixture, but its execution log was not supplied and the case was not independently rerun.

  • The supplied hosted CI snapshot includes five jobs still in progress; the Shanghai OSS/COS job completed successfully.

@XuPeng-SH

XuPeng-SH commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 4de762f6107031e5def4ec53b0cdea15462d946a

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: 4de762f6107031e5def4ec53b0cdea15462d946a

Assessment: approve

The fix applies the existing snapshot-aware tombstone reader before rewriting cloned objects and uses the existing object registry and transaction rollback path to manage partial failures. The maintained regression now checks source and clone results on two CNs using the shared fixture, resolving both prior review concerns. No actionable defects remain.

Model: gpt-6.1-terra / max

Session: 01a21ea1-c772-7b90-b7f9-8f6ec1038a49 · slot 2 · generation 12

Validation:

  • On the assigned head, the cross-CN regression and an existing clone test passed twice in the same process without overlays. Log: /mnt/nvme/mo-bot-55-live/state/jobs/9385dd12ca91e49da9e99f50/attempt-1/embed-current.log; receipt: /mnt/nvme/mo-bot-55-live/state/jobs/9385dd12ca91e49da9e99f50/attempt-1/checks/1795813822640553123-2.json.

  • Reused focused race results from 3fbe98e for the unchanged tombstone-offset and rollback-failure paths: 100 and 28 repetitions passed. Logs and matching receipts are in /mnt/nvme/mo-bot-55-live/state/jobs/923cedffaffb80208e21426a/attempt-1, with receipts checks/1795805690577787789-2.json and checks/1795805718665050527-2.json.

  • The full disttae package also passed under the race detector at 3fbe98e. Log: /mnt/nvme/mo-bot-55-live/state/jobs/923cedffaffb80208e21426a/attempt-1/package-race.log; receipt: /mnt/nvme/mo-bot-55-live/state/jobs/923cedffaffb80208e21426a/attempt-1/checks/1795805741399477107-2.json.

  • Private-environment preflight, native-input verification, and exact-range git diff --check passed. Their logs and receipts are retained in the diagnostic directory.

Limitations:

  • The earlier race run predates an unrelated fulltext search change that is a transitive dependency of the disttae test binary; the focused results are reused for the unchanged clone rewrite paths, not claimed as an exact-head whole-package run.

  • The reported mo-tester SQL comparison was not independently rerun and its log was not supplied. The current two-CN embedded test independently covers the issue's row-set contract. Hosted CI was pending in the supplied snapshot.

@XuPeng-SH
XuPeng-SH merged commit 785b8ae into matrixorigin:4.2-dev Nov 28, 2026
32 of 36 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/33079-clone-delete-visibility-42 branch November 28, 2026 00:28

This branch had an error being deployed

1 failed 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/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants