Skip to content

schemastore: fix rename partition table#4446

Merged
ti-chi-bot[bot] merged 4 commits intomasterfrom
ldz/fix-rename-partition-table0312
Mar 12, 2026
Merged

schemastore: fix rename partition table#4446
ti-chi-bot[bot] merged 4 commits intomasterfrom
ldz/fix-rename-partition-table0312

Conversation

@lidezhu
Copy link
Copy Markdown
Collaborator

@lidezhu lidezhu commented Mar 12, 2026

What problem does this PR solve?

Issue Number: close #4447

What is changed and how it works?

This pull request aims to resolve a bug in the schemastore that affects the renaming of partition tables. It enhances the system's robustness by adding specific integration tests to cover scenarios where both normal and partitioned tables are renamed simultaneously, ensuring the schema changes are correctly propagated and managed.

Highlights

  • Bug Fix: Addressed an issue within the schemastore concerning the renaming of partition tables, ensuring correct handling of such operations.
  • Test Coverage: Expanded integration test coverage by introducing new test cases for mixed RENAME TABLE operations involving both normal and partitioned tables.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.

Summary by CodeRabbit

  • Tests
    • Expanded integration coverage for multi-table DDL: added scenarios mixing partitioned and non‑partitioned tables, renames, data migrations, and new downstream existence checks; updated test filters to include additional rename markers and finish checks; added a unit test validating rename handling for partitioned tables.
  • Bug Fixes
    • Improved rename/partition handling to more accurately track and update renamed partitioned tables during processing.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Mar 12, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to resolve a bug in the schemastore that affects the renaming of partition tables. It enhances the system's robustness by adding specific integration tests to cover scenarios where both normal and partitioned tables are renamed simultaneously, ensuring the schema changes are correctly propagated and managed.

Highlights

  • Bug Fix: Addressed an issue within the schemastore concerning the renaming of partition tables, ensuring correct handling of such operations.
  • Test Coverage: Expanded integration test coverage by introducing new test cases for mixed RENAME TABLE operations involving both normal and partitioned tables.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tests/integration_tests/consistent_partition_table/data/prepare.sql
    • Added new RENAME TABLE statements to test mixed operations involving normal and partitioned tables.
    • Included INSERT statements to verify data integrity after rename operations.
Activity
  • No specific activity (comments, reviews, or progress updates) has been reported for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ti-chi-bot ti-chi-bot bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 12, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

Fixes rename handling for partitioned tables in schemastore DDL processing and adds integration tests covering mixed renames of normal and partitioned tables; updates test configs, SQL fixtures, and run scripts to validate renamed-table downstream existence.

Changes

Cohort / File(s) Summary
Schemastore DDL handler
logservice/schemastore/persist_storage_ddl_handlers.go
Switch to per-entry tableInfo when checking partitions and resolving partition IDs; correctly populate BlockedTables, UpdatedSchemas, AddName/DropName and result queries when handling rename entries involving partitioned tables.
Schemastore tests
logservice/schemastore/persist_storage_test.go
Add TestBuildDDLEventForRenameTablesForPartitionTable with subtests for mixed normal/partition rename scenarios and helper constructors for partitioned/non-partitioned table infos.
CSV integration tests — configs
tests/integration_tests/csv_storage_multi_tables_ddl/conf/diff_config.toml, tests/integration_tests/csv_storage_multi_tables_ddl/conf/normal.toml
Expand target-check-tables and filter.rules to include four new renamed-table markers (rename_mix_normal_1_done, rename_mix_part_1_done, rename_mix_normal_2_done, rename_mix_part_2_done).
CSV integration tests — data & run
tests/integration_tests/csv_storage_multi_tables_ddl/data/test.sql, tests/integration_tests/csv_storage_multi_tables_ddl/run.sh
Add DDL/DML for two pairs of normal/partitioned tables with renames to *_done and follow-up inserts; add downstream existence checks for the new renamed tables.
Multi-tables DDL tests — configs
tests/integration_tests/multi_tables_ddl/conf/diff_config.toml, tests/integration_tests/multi_tables_ddl/conf/normal.toml
Same expansions to target-check-tables and filter.rules to include the four new renamed-table markers.
Multi-tables DDL tests — data & run
tests/integration_tests/multi_tables_ddl/data/test.sql, tests/integration_tests/multi_tables_ddl/run.sh
Add DDL/DML for two pairs of normal/partitioned tables with renames and inserts; add corresponding existence assertions in run script.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

lgtm, approved

Suggested reviewers

  • wk989898
  • wlwilliamx
  • hongyunyan

Poem

🐰 I hopped through schema rows and beams,
Swapped names of tables, chased my dreams.
Partitions and normals, now aligned,
Tests cheer softly — everything's signed. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'schemastore: fix rename partition table' is directly related to the main objective of fixing TiCDC's handling of renaming partition tables, as described in the linked issue #4447.
Linked Issues check ✅ Passed The code changes directly address the core issue #4447 by modifying buildDDLEventForRenameTables to use per-table information for partition handling instead of rawEvent.TableInfo, and adding comprehensive integration tests for rename operations involving both normal and partitioned tables.
Out of Scope Changes check ✅ Passed All changes are focused on fixing partition table rename handling in schemastore and adding corresponding integration tests. No unrelated modifications were introduced.
Description check ✅ Passed PR description follows the template with all required sections: Issue Number, clear explanation of changes, test checklist marked, and release note section included.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ldz/fix-rename-partition-table0312

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 and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds an integration test case to address an issue with renaming partitioned tables. The new test in prepare.sql covers RENAME TABLE with a mix of normal and partitioned tables, using different table orders in the DDL statement. This is intended to verify the correct processing of RENAME TABLES DDL events. The added test case is correct and covers the scenario described.

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 12, 2026
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 12, 2026
@lidezhu
Copy link
Copy Markdown
Collaborator Author

lidezhu commented Mar 12, 2026

/test all

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Mar 12, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Mar 12, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tenfyzhong, wk989898

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [tenfyzhong,wk989898]

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 12, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Mar 12, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-03-12 07:37:50.43347958 +0000 UTC m=+508501.945537241: ☑️ agreed by tenfyzhong.
  • 2026-03-12 07:47:07.802818752 +0000 UTC m=+509059.314876403: ☑️ agreed by wk989898.

@lidezhu
Copy link
Copy Markdown
Collaborator Author

lidezhu commented Mar 12, 2026

/test pull-cdc-storage-integration-heavy

@ti-chi-bot ti-chi-bot bot merged commit b94343e into master Mar 12, 2026
20 checks passed
@ti-chi-bot ti-chi-bot bot deleted the ldz/fix-rename-partition-table0312 branch March 12, 2026 09:30
lidezhu added a commit that referenced this pull request Mar 13, 2026
tenfyzhong pushed a commit that referenced this pull request Mar 18, 2026
close #4447

(cherry picked from commit b94343e)
Signed-off-by: tenfyzhong <tenfy@tenfy.cn>
tenfyzhong pushed a commit that referenced this pull request Mar 18, 2026
tenfyzhong pushed a commit that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Rename tables DDL may use wrong table info for partition tables

3 participants