Skip to content

schemastore: mark tables deleted after dropping database - #5963

Open
lidezhu wants to merge 8 commits into
masterfrom
ldz/fix-drop-db0812
Open

schemastore: mark tables deleted after dropping database#5963
lidezhu wants to merge 8 commits into
masterfrom
ldz/fix-drop-db0812

Conversation

@lidezhu

@lidezhu lidezhu commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #5962

What is changed and how it works?

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

  • Bug Fixes

    • Improved schema change handling so affected tables and partitions are identified correctly during schema drops.
    • Historical table information now reports deleted tables accurately at the time of a schema drop.
    • Preserved correct behavior for partition, truncate, rename, create, exchange, and repartition operations.
  • Tests

    • Added coverage verifying table history before and after schema drops.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Aug 12, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 12, 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 the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 12, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 12, 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 hongyunyan 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

@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@lidezhu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f28ab1f5-a897-41e1-81bf-00007c4dde2c

📥 Commits

Reviewing files that changed from the base of the PR and between 563bad5 and 29aa916.

📒 Files selected for processing (3)
  • logservice/schemastore/persist_storage.go
  • logservice/schemastore/persist_storage_ddl_handlers.go
  • logservice/schemastore/persist_storage_test.go

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 425c402b-6cc4-4b69-8c59-84f7df19e74e

📥 Commits

Reviewing files that changed from the base of the PR and between 190987a and 563bad5.

📒 Files selected for processing (3)
  • logservice/schemastore/persist_storage.go
  • logservice/schemastore/persist_storage_ddl_handlers.go
  • logservice/schemastore/persist_storage_test.go

📝 Walkthrough

Walkthrough

Changes

Schema drop deletion propagation

Layer / File(s) Summary
Structured table iteration contract
logservice/schemastore/persist_storage_ddl_handlers.go
DDL iterators now receive iterateEventTablesFuncArgs. Existing table, partition, rename, create, exchange, and repartition calculations retain their behavior.
Drop-schema table deletion
logservice/schemastore/persist_storage_ddl_handlers.go
Drop-schema handling iterates all schema tables, expands partitioned tables, and marks affected physical tables as deleted.
DDL ordering and registration validation
logservice/schemastore/persist_storage.go, logservice/schemastore/persist_storage_test.go
Registered table stores receive DDL events before schema metadata updates. Tests verify deletion errors for registered, unregistered, and partitioned tables at the drop timestamp.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant handleDDLJob
  participant iterateEventTablesFunc
  participant versionedTableInfoStore
  handleDDLJob->>iterateEventTablesFunc: pass drop-schema event and pre-update metadata
  iterateEventTablesFunc->>versionedTableInfoStore: mark physical tables and partitions deleted
  handleDDLJob->>versionedTableInfoStore: update schema metadata
Loading

Possibly related PRs

  • pingcap/ticdc#5957: Both changes modify handleDDLJob and table-store registration behavior, but address different issues.

Suggested reviewers: 3aceshowhand, tenfyzhong

Poem

A rabbit hops through schemas wide,
And marks each table gone beside.
Partitions too receive the sign,
At drop time, stale reads decline.
DDL moves first, metadata follows—
Burrow-safe history now grows.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the issue reference and template sections, but it leaves the change summary, questions, test selection, and release note incomplete. Complete the change explanation, select applicable tests, answer both questions, and provide a release note or state None.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: marking tables deleted after a database drop.
Linked Issues check ✅ Passed The implementation marks affected tables and partitions deleted after DROP DATABASE and adds tests for historical and post-drop behavior required by issue #5962.
Out of Scope Changes check ✅ Passed The code and test changes are directly related to applying deletion versions after database drops and contain no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ldz/fix-drop-db0812

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.

@lidezhu
lidezhu marked this pull request as ready for review August 12, 2026 11:50
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

schemastore: DROP DATABASE does not mark table info as deleted

1 participant