Skip to content

docs: add physical storage UUID RFC#69924

Draft
bb7133 wants to merge 1 commit into
pingcap:masterfrom
bb7133:bb7133/rfc-physical-storage-uuid
Draft

docs: add physical storage UUID RFC#69924
bb7133 wants to merge 1 commit into
pingcap:masterfrom
bb7133:bb7133/rfc-physical-storage-uuid

Conversation

@bb7133

@bb7133 bb7133 commented Jul 19, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: ref #69923

Problem Summary:

This PR adds an RFC for introducing a globally restorable physical storage identity for TiDB tables and partitions. The goal is to enable supported BR restore and TiDB-X tenant migration flows to preserve physical data key prefixes instead of rewriting source physical table IDs to target-local physical table IDs.

What changed and how does it work?

This PR adds a new design document under docs/design/:

  • docs/design/2026-07-19-physical-storage-uuid.md

The RFC describes:

  • why logical UUID metadata alone cannot remove BR table ID key rewrite;
  • the proposed PhysicalStorageUUID metadata for tables and partitions;
  • UUIDv7 generation semantics for new physical data spaces;
  • a possible UUID-based tablecodec v2 key prefix;
  • DDL, BR restore, and TiDB-X tenant migration semantics;
  • rollout, testing, compatibility, and open questions.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot

ti-chi-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jul 19, 2026
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fd6fa7d1-5e42-4e80-8100-79cd8ae40936

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 19, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xiongjiwei for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pingcap-cla-assistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


CodexM5 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@bb7133
bb7133 force-pushed the bb7133/rfc-physical-storage-uuid branch from 95b35fd to 129ca13 Compare July 19, 2026 05:42
@ti-chi-bot

ti-chi-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-tests-checked label, please finished the tests then check the finished items in description.

For example:

Tests <!-- At least one of them must be included. -->

- [x] Unit test
- [ ] Integration test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No code

‼️ Must keep the HTML comments <!-- At least one of them must be included. -->

📖 For more info, you can check the "Contribute Code" section in the development guide.

Generation timing:

* `CREATE TABLE`: generate one physical storage UUID for a non-partitioned table.
* `CREATE TABLE` with partitions: generate one physical storage UUID per physical partition.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we also need a storage UUID for the global index 🤔 .

```

The new layout may keep the `t` table-key family for locality and compatibility with table-key scanning, but the byte after `t` or an equivalent field must identify the key format before decoding the physical identity.
This is required because existing tablecodec logic assumes `t + 8-byte int64` in many places, including fixed offsets for record/index separators and table range boundaries.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how the format_marker can make it better.

A decoder still cannot tell whether it's an old key or a new key, because the prefix of int64_physical_table_id can also be a format_marker.

* `ADD PARTITION`: generate one physical storage UUID for each new partition.
* `REORGANIZE PARTITION`: generate UUIDs for newly created physical partitions.
* `TRUNCATE TABLE`: generate a new physical storage UUID for the new physical data space.
* `TRUNCATE PARTITION`: generate a new physical storage UUID for the truncated partition.

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.

Do we need to rewrite the whole table for MODIFY COLUMN if it's still using the old format?


// PhysicalStorageUUID identifies this physical partition data space
// when the partition uses the UUID-based physical key format.
PhysicalStorageUUID []byte

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.

Should we store PhysicalStorageKeyFormat for each partition?

@D3Hunter

D3Hunter commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

see #69923 (comment), before we proceed with writing an RFC, maybe we should eval the gain/cost first


Even though random collision is practically negligible, metadata mutation must still enforce uniqueness within a keyspace.
If a newly generated UUID conflicts, DDL can retry generation.
If restore or migration sees an existing target object with the same preserved UUID, it must report a conflict unless the requested mode explicitly drops or replaces that object.

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.

Do not reuse UUIDs until asynchronous delete-range cleanup completes; it may delete newly restored data.

* For new-format tables, BR preserves source physical storage UUIDs and can ingest KV data without rewriting the physical table key prefix.
* If the target cluster already has the same physical storage UUID, restore reports a conflict unless the user requested a mode that drops/replaces the target object.
* Restore must advance or reconcile metadata ID allocators as needed, but this does not require rewriting UUID-based data key prefixes.
* Log restore should use physical storage UUID as the stable physical object identity for UUID-format tables.

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.

Existing UUIDs owned by the same BR checkpoint should be resumable, not conflicting.

2. **Experimental key format**
* Add UUID-based tablecodec helpers.
* Enable the new format only behind an experimental switch for newly created tables.
* Keep old-format table behavior unchanged.

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.

Require cluster-wide UUID-key support during upgrades, otherwise older TiDB nodes may read or write incompatible keys.

1. **Metadata preparation**
* Add physical storage UUID metadata fields.
* Generate UUIDs for new tables and partitions but keep old key format as default.
* Add uniqueness checks and diagnostic display.

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.

Line 289 generates UUIDs for legacy-format tables, contradicting the empty-UUID invariant at lines 125–126.

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

Labels

do-not-merge/needs-tests-checked do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants