Skip to content

schemastore: update TableInfo for surviving partitions - #5964

Open
lidezhu wants to merge 2 commits into
masterfrom
ldz/fix-schema-store081202
Open

schemastore: update TableInfo for surviving partitions#5964
lidezhu wants to merge 2 commits into
masterfrom
ldz/fix-schema-store081202

Conversation

@lidezhu

@lidezhu lidezhu commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #5965

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 partition DDL handling for add, drop, truncate, and reorganize operations.
    • Ensured surviving partitions retain updated table information after partition changes.
    • Correctly reports dropped partitions as deleted while preserving information for active partitions.

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

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Partition DDL handlers now propagate updated TableInfo to surviving partitions for add, drop, truncate, and reorganize operations. New tests validate online application, history replay, and deletion reporting.

Changes

Partition DDL propagation

Layer / File(s) Summary
Update partition DDL handlers
logservice/schemastore/persist_storage_ddl_handlers.go
Live and persisted partition-event handling now processes current physical partition IDs. Removed partitions remain marked as deleted.
Validate surviving partition updates
logservice/schemastore/multi_version_test.go
Tests cover add, drop, reorganize, and truncate partition events through online and persisted-history paths. Drop scenarios also verify deletion reporting.

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

Sequence Diagram(s)

sequenceDiagram
  participant applyDDL
  participant applyDDLFromPersistStorage
  participant extractTableInfoFunc
  participant versionedTableInfoStore
  applyDDL->>versionedTableInfoStore: Apply updated TableInfo to current partition IDs
  applyDDLFromPersistStorage->>extractTableInfoFunc: Extract TableInfo for current partition IDs
  extractTableInfoFunc->>versionedTableInfoStore: Return updated or deleted partition state
Loading

Poem

A rabbit hops through partitions bright,
Updating timestamps left and right.
Dropped ones fade from the table’s view,
History and live paths agree anew.
“Nibble the tests!” the rabbit sings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the issue number but leaves the change summary, test selection, questions, and release note incomplete. Describe the implementation, select applicable tests, answer both questions, and provide a release note or explicitly state None.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: updating TableInfo for surviving partitions.
Linked Issues check ✅ Passed The implementation updates all post-DDL partitions, marks removed partitions deleted, and covers equivalent live and history paths for issue #5965.
Out of Scope Changes check ✅ Passed The code and test changes are limited to SchemaStore partition DDL handling and directly support issue #5965.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 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-schema-store081202

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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 12, 2026
@lidezhu
lidezhu marked this pull request as ready for review August 12, 2026 14:15
@ti-chi-bot ti-chi-bot Bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-linked-issue labels Aug 12, 2026

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@logservice/schemastore/multi_version_test.go`:
- Around line 327-351: Expand the test around iterateEventTablesFunc and
updateDDLHistoryFunc to validate every post-DDL partition, not only survivorID.
Collect all table IDs passed to iterateEventTablesFunc and assert they match the
expected set of 201, 203, 204, and 205; also assert tablesDDLHistory contains
ddlFinishedTS for each expected ID before continuing with the store assertions.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6abb1a96-e3a3-486d-b286-035382680ddd

📥 Commits

Reviewing files that changed from the base of the PR and between 1ec8fe4 and b26ad25.

📒 Files selected for processing (2)
  • logservice/schemastore/multi_version_test.go
  • logservice/schemastore/persist_storage_ddl_handlers.go

Comment on lines +327 to +351
// Verify that the online path applies the DDL to a registered surviving partition.
liveStore := newStore(true)
applied := false
handler.iterateEventTablesFunc(event, func(tableIDs ...int64) {
for _, tableID := range tableIDs {
if tableID == survivorID {
liveStore.applyDDL(event)
applied = true
}
}
})
require.True(t, applied)
assertUpdated(liveStore)

// Verify that the history path records and extracts the same update.
tablesDDLHistory := make(map[int64][]uint64)
handler.updateDDLHistoryFunc(updateDDLHistoryFuncArgs{
ddlEvent: event,
tablesDDLHistory: tablesDDLHistory,
})
require.Equal(t, []uint64{ddlFinishedTS}, tablesDDLHistory[survivorID])
historyStore := newStore(false)
historyStore.applyDDLFromPersistStorage(event)
historyStore.setTableInfoInitialized()
assertUpdated(historyStore)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert every affected partition ID.

The test validates only survivorID 201. It does not validate new partition IDs 203, 204, and 205.

A handler that skips newly created partitions can pass this test. Collect all IDs passed to iterateEventTablesFunc and assert the expected affected-ID set. Also assert tablesDDLHistory for each expected ID.

The PR objective requires updates for all post-DDL partitions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@logservice/schemastore/multi_version_test.go` around lines 327 - 351, Expand
the test around iterateEventTablesFunc and updateDDLHistoryFunc to validate
every post-DDL partition, not only survivorID. Collect all table IDs passed to
iterateEventTablesFunc and assert they match the expected set of 201, 203, 204,
and 205; also assert tablesDDLHistory contains ddlFinishedTS for each expected
ID before continuing with the store assertions.

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: partition DDLs do not update TableInfo for surviving partitions

1 participant