Skip to content

fix(disttae): preserve table ownership for clone deletes - #32555

Merged
XuPeng-SH merged 8 commits into
mainfrom
codex/fix-32500-clone-delete
Nov 13, 2026
Merged

XuPeng-SH merged 8 commits into
mainfrom
codex/fix-32500-clone-delete

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Fixes #32500

What this PR does / why we need it:

Transaction-local original -> a -> b clones can share CN objects and blocks. The workspace previously keyed object summaries only by object ID and pending deletes only by block ID, so one table's DELETE/UPDATE could be applied to another logical table during reads and compaction.

  • Key CN object summaries and deleted blocks by logical table ID plus physical object/block ID.
  • Keep table identity through tombstone filtering, raw-row deletes, compaction table/batch ownership, dirty-object tracking, and rewrite application.
  • Preserve physical object sharing; this changes only logical DML ownership.
  • Add focused unit coverage and a pessimistic READ-COMMITTED SQL regression covering original/clone isolation, UPDATE, indexes, COMMIT, and ROLLBACK.

Verification:

  • The new object-ownership unit test reproduced the bug before the fix: two tables sharing one object produced only one summary entry.
  • mo-cgo-test -count=1 -timeout=300s ./pkg/vm/engine/disttae — passed (ok ... 47.280s).
  • Focused adaptive race runs for the new ownership tests and directly affected compaction/read tests — passed (30-100 repetitions per exact test).
  • mo-cgo-test -race -count=1 -timeout=600s ./pkg/vm/engine/disttae — passed (ok ... 56.605s).
  • go build and go vet for ./pkg/vm/engine/disttae/... — passed with worktree-local CGo flags.
  • Standalone mo-service + MySQL execution of the new SQL case — passed: original and b kept 3 rows, a kept 2, indexes stayed consistent, and rollback restored deleted data.

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

Copy link
Copy Markdown
Contributor

This pull request is merged.

@matrix-meow matrix-meow added size/L Denotes a PR that changes [500,999] lines and removed size/M Denotes a PR that changes [100,499] lines labels Nov 11, 2026

@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: 92c38f1758712e7be357ca57bb8027b88d041453

Assessment: approve

Table-qualified workspace state preserves clone isolation through existing compaction and GC owners. Bounded preallocation and pass-local lookups avoid unnecessary map overhead. No actionable findings remain.

Model: gpt-6.1-sol / max

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

Validation:

  • Reviewed all 18 changed files, linked issue #32500 and all 10 discussion entries; saved both required review records.

  • Go 1.27.1: 762 disttae tests passed normally and under race; 10 focused tests, 867 adaptive race repetitions, two engine recovery tests and go vet passed.

  • Patch, formatting and 11 independent SQL result/metadata oracles passed. Source remains unchanged.

  • Isolation preflight and native prerequisite builds passed; 198 inputs verified. Commands, source fingerprints, exits and logs matched in receipt-reconciliation.json; final audit receipt: checks/1794452932465870978-3.json.

Limitations:

  • Public SQL execution and performance measurements remain author-reported; no local service or benchmark run.

  • Queued/skipped frozen CI checks were not counted as product passes.

@XuPeng-SH
XuPeng-SH merged commit a626dd0 into main Nov 13, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/fix-32500-clone-delete branch November 13, 2026 02:39
XuPeng-SH added a commit that referenced this pull request Nov 21, 2026
## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes:

Fixes #32500

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

CLONE can share a physical CN object across multiple logical tables. The
4.2 workspace keyed pending deletes and object metadata by physical ID
alone. A DELETE against a source or a clone could therefore be hidden on
the target and applied to a sibling clone after commit.

Adapt #32555 to the 4.2 workspace. Include the logical table ID in
object lookups, deleted-row collections, and compaction jobs. Use the
existing workspace entry lifecycle to track file-backed tombstones per
table as well. This also fixes a related case where cloning a table with
a persisted delete could hide the same row on the original table inside
the clone transaction.

### Validation

- Reproduced the issue on both CNs of an unmodified 4.2-dev cluster
using pessimistic READ COMMITTED.
- Validated the original repro, two-target DELETE, indexed-column
UPDATE, rollback, and cross-CN reads after commit on a patched two-CN
cluster.
- Ran every statement in the new SQL regression against the patched
service and compared its results with the checked-in fixture, including
the persisted tombstone case.
- Passed disttae unit tests with and without race, two focused engine
regressions, and incremental lint.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
XuPeng-SH added a commit that referenced this pull request Nov 21, 2026
## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes:

Related to #32500

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

Follow up on #32555 and #33043. When a transaction clones a table that
already contains a persisted delete, the clone's file-backed tombstone
can also hide the row on another table that shares the same physical
data block.

Scope the existing flushed workspace tombstone index by logical table
and update it through workspace-entry accounting. Both local scans and
tombstone collection now read only their table's records, with duplicate
live entries tracked until the final reference is released. Staged
publication and physical-file cleanup keep their existing owners.

Validation on Go 1.27.1, Darwin arm64:

- Reproduced on unmodified `main` at `f1ffbaaff35d`: the original table
lost `id=1` in the transaction after the second clone was created.
- Verified the extended clone SQL regression, including rollback, a
fresh clone, and commit, on both CNs in a local pessimistic READ
COMMITTED cluster.
- Ran `disttae` unit tests, race tests, focused engine tests and
incremental lint.


Additional validation on Go 1.27.1, Linux amd64:

- Published a real tombstone through the workspace write path. With two
tables sharing a data block, both tombstone collection and local row
filtering respected table ownership. Releasing one duplicate
registration kept the delete visible, and releasing the last removed it
from both read paths.
- The full `disttae` package passed under `-race`. Incremental
formatting, vet, molint and golangci-lint checks passed.

This branch was successfully deployed

No deployments
ci — 424dc4b3 Deployed Nov 13, 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 size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DELETE on a transaction-local CLONE can delete rows from a different clone

2 participants