Skip to content

fix: encode clone object keys losslessly - #26230

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-26118
Jul 27, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-26118

Conversation

@VioletQwQ-0

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:

Fixes #26118

What this PR does / why we need it:

Database clone dependency maps encoded object identity as database#relation and decoded it with an unrestricted split. A legal # in either identifier truncated the key, causing foreign-key tables and dependent views to fail or be silently omitted.

This change uses a versioned byte-length representation only when an identifier contains #. Ordinary and legacy keys keep their existing database#relation bytes and SplitN behavior, including literal backslashes. The encoded form is reversible when either or both components contain arbitrary # sequences and UTF-8 text.

Regression coverage verifies:

  • codec round trips for # on either side, both sides, adjacent/boundary runs, backslashes, UTF-8, and empty components;
  • database Data Branch and ordinary database CLONE both preserve FK tables, rows, FK metadata, and two dependent views when database/table/view names contain #.

Validation:

  • go test ./pkg/frontend -run '^TestObjectKeyRoundTrip$' -count=1
  • go test ./pkg/tests/issues -run '^TestIssue26118DatabaseCopiesPreserveHashIdentifiers$' -count=1
  • go test ./pkg/frontend -count=1
  • schema v4 exact-head preflight: PASS review=PASS

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

Blocking finding — pkg/tests/issues/issue_26118_test.go:46

prefixDB = "\x001" is a Go hex escape, so this creates a database whose name contains a NUL byte; it is not a literal \x001 name and it no longer exercises the current ## codec prefix. On exact head 9982e178, the deferred DROP DATABASE hits panic delete table failed, while execSQLMaybe discards the error. Since RunBaseClusterTests reuses one global cluster, the database remains behind: -count=2 makes iteration 1 pass and iteration 2 fail with database \x001 already exists.

Please use a printable name that covers the intended boundary (for example a name beginning with ## for the current prefix, or a raw string if the intent is a literal backslash) and ensure the created database is actually removable / cleanup failure is visible. The production codec and clone producer/consumer paths otherwise looked closed in this review.

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

Re-reviewed on 3c0a54a. The previous blocker is resolved: the regression now uses a printable ##-prefixed database, setup/cleanup errors are surfaced, and the exact embedded-cluster test passes with -count=2 without leaking state. I also rechecked codec unambiguity, UTF-8 byte lengths, legacy ordinary keys/backslashes, and producer/consumer consistency across clone, FK, snapshot/PITR, dependency sorting, and view privilege parsing. Full objectkey/frontend/plan tests, build, vet, and all current CI checks pass.

@mergify mergify Bot added the queued label Jul 27, 2026
@mergify

mergify Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-27 11:10 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-27 14:56 UTC · at 9b1c5bcc20601780a9351eab5359b5e1fa3741ea · squash

This pull request spent 3 hours 46 minutes 29 seconds in the queue, including 33 minutes 39 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

@mergify
mergify Bot merged commit c6d7a11 into matrixorigin:main Jul 27, 2026
25 of 26 checks passed
@mergify mergify Bot removed the queued label Jul 27, 2026
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Database clone dependency maps encoded object identity as `database#relation` and decoded it with an unrestricted split. A legal `#` in either identifier truncated the key, causing foreign-key tables and dependent views to fail or be silently omitted.

This change uses a versioned byte-length representation only when an identifier contains `#`. Ordinary and legacy keys keep their existing `database#relation` bytes and `SplitN` behavior, including literal backslashes. The encoded form is reversible when either or both components contain arbitrary `#` sequences and UTF-8 text.

Regression coverage verifies:

- codec round trips for `#` on either side, both sides, adjacent/boundary runs, backslashes, UTF-8, and empty components;
- database Data Branch and ordinary database CLONE both preserve FK tables, rows, FK metadata, and two dependent views when database/table/view names contain `#`.

Validation:

- `go test ./pkg/frontend -run '^TestObjectKeyRoundTrip$' -count=1`
- `go test ./pkg/tests/issues -run '^TestIssue26118DatabaseCopiesPreserveHashIdentifiers$' -count=1`
- `go test ./pkg/frontend -count=1`
- schema v4 exact-head preflight: `PASS review=PASS`

Approved by: @XuPeng-SH
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Database clone dependency maps encoded object identity as `database#relation` and decoded it with an unrestricted split. A legal `#` in either identifier truncated the key, causing foreign-key tables and dependent views to fail or be silently omitted.

This change uses a versioned byte-length representation only when an identifier contains `#`. Ordinary and legacy keys keep their existing `database#relation` bytes and `SplitN` behavior, including literal backslashes. The encoded form is reversible when either or both components contain arbitrary `#` sequences and UTF-8 text.

Regression coverage verifies:

- codec round trips for `#` on either side, both sides, adjacent/boundary runs, backslashes, UTF-8, and empty components;
- database Data Branch and ordinary database CLONE both preserve FK tables, rows, FK metadata, and two dependent views when database/table/view names contain `#`.

Validation:

- `go test ./pkg/frontend -run '^TestObjectKeyRoundTrip$' -count=1`
- `go test ./pkg/tests/issues -run '^TestIssue26118DatabaseCopiesPreserveHashIdentifiers$' -count=1`
- `go test ./pkg/frontend -count=1`
- schema v4 exact-head preflight: `PASS review=PASS`

Approved by: @XuPeng-SH
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Database clone dependency maps encoded object identity as `database#relation` and decoded it with an unrestricted split. A legal `#` in either identifier truncated the key, causing foreign-key tables and dependent views to fail or be silently omitted.

This change uses a versioned byte-length representation only when an identifier contains `#`. Ordinary and legacy keys keep their existing `database#relation` bytes and `SplitN` behavior, including literal backslashes. The encoded form is reversible when either or both components contain arbitrary `#` sequences and UTF-8 text.

Regression coverage verifies:

- codec round trips for `#` on either side, both sides, adjacent/boundary runs, backslashes, UTF-8, and empty components;
- database Data Branch and ordinary database CLONE both preserve FK tables, rows, FK metadata, and two dependent views when database/table/view names contain `#`.

Validation:

- `go test ./pkg/frontend -run '^TestObjectKeyRoundTrip$' -count=1`
- `go test ./pkg/tests/issues -run '^TestIssue26118DatabaseCopiesPreserveHashIdentifiers$' -count=1`
- `go test ./pkg/frontend -count=1`
- schema v4 exact-head preflight: `PASS review=PASS`

Approved by: @XuPeng-SH
@VioletQwQ-0
VioletQwQ-0 deleted the codex/issue-26118 branch December 1, 2026 03:47

This branch was previously deployed

1 inactive 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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Database CLONE and DATA BRANCH mishandle object identifiers containing #

3 participants