Skip to content

logservice,event: stop capturing tidb_ddl_history#4766

Open
wlwilliamx wants to merge 1 commit intopingcap:masterfrom
wlwilliamx:remove-tidb-ddl-history
Open

logservice,event: stop capturing tidb_ddl_history#4766
wlwilliamx wants to merge 1 commit intopingcap:masterfrom
wlwilliamx:remove-tidb-ddl-history

Conversation

@wlwilliamx
Copy link
Copy Markdown
Collaborator

@wlwilliamx wlwilliamx commented Apr 8, 2026

What problem does this PR solve?

Issue Number: close #2272

What is changed and how it works?

This PR removes TiCDC's remaining upstream capture path for tidb_ddl_history.

  • stop subscribing to tidb_ddl_history in the schema-store DDL fetcher
  • stop initializing tidb_ddl_history metadata for DDL parsing
  • parse DDL jobs only from tidb_ddl_job
  • accept only JobStateDone jobs from tidb_ddl_job and drop the old JobStateSynced compatibility path
  • add regression tests for DDL span subscription and job parsing behavior

This aligns TiCDC with the TiDB v8.3+ / v8.5 GA behavior targeted by issue #2272, where CREATE TABLE no longer requires tidb_ddl_history capture.

Check List

Tests

  • Unit test
  • Manual test

Questions

Will it cause performance regression or break compatibility?

No performance regression is expected.

This intentionally drops compatibility with older TiDB behavior where CREATE TABLE could be emitted only through tidb_ddl_history. That is the behavior cleanup requested by issue #2272.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

TiCDC no longer captures DDLs from `tidb_ddl_history` and relies on `tidb_ddl_job` for accelerated table creation.

Summary by CodeRabbit

  • Refactor
    • Simplified DDL job processing by removing support for the legacy DDL history table. The system now exclusively uses the DDL job table for processing, reducing redundant operations.
    • Streamlined job parsing logic to focus on completed jobs, normalizing the DDL lifecycle handling.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Apr 8, 2026

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/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 Apr 8, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Apr 8, 2026

[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 flowbehappy 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
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4594011c-bc19-45b9-924a-19ed4f2b4b14

📥 Commits

Reviewing files that changed from the base of the PR and between 0a418b4 and 4e95396.

📒 Files selected for processing (5)
  • logservice/schemastore/ddl_job_fetcher.go
  • logservice/schemastore/ddl_job_fetcher_test.go
  • pkg/common/event/mounter.go
  • pkg/common/event/mounter_test.go
  • pkg/common/span_op.go
💤 Files with no reviewable changes (1)
  • pkg/common/span_op.go

📝 Walkthrough

Walkthrough

This PR removes support for capturing DDL changes from the tidb_ddl_history table, consolidating all DDL job fetching to the tidb_ddl_job table only. Related constants, metadata initialization, and conditional parsing logic are eliminated accordingly.

Changes

Cohort / File(s) Summary
DDL Job Fetcher
logservice/schemastore/ddl_job_fetcher.go, logservice/schemastore/ddl_job_fetcher_test.go
Removed metadef dependency and history table initialization. getAllDDLSpan now returns a single span for the job table instead of two. Added TestGetAllDDLSpan test to verify the updated behavior.
Event Mounter
pkg/common/event/mounter.go, pkg/common/event/mounter_test.go
Removed DDLHistoryTable and JobMetaColumnIDinHistoryTable fields from DDLTableInfo struct. Simplified ParseDDLJob logic by eliminating the history table branch. Updated parseJob signature to remove the fromHistoryTable parameter and changed filtering to replay only jobs where job.IsDone() is true. Added TestParseJobFromDDLJob test suite with multiple DDL job scenarios.
Span Operations
pkg/common/span_op.go
Removed the exported constant JobHistoryID that previously mapped to metadef.TiDBDDLHistoryTableID.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 One table's all we need, we've found—
No history hopping all around!
Fast creation's way is set,
DDL jobs, no backward debt,
Simpler paths, less complex dance!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% 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 clearly and concisely summarizes the main change: stopping capture of tidb_ddl_history in logservice and event packages.
Description check ✅ Passed The description follows the template with issue number, explanation of changes, test coverage, and release notes, though missing some minor details.
Linked Issues check ✅ Passed The PR fully addresses issue #2272 by removing tidb_ddl_history subscription, metadata initialization, legacy compatibility paths, and adding regression tests as required.
Out of Scope Changes check ✅ Passed All changes are directly scoped to removing tidb_ddl_history capture and supporting JobStateDone filtering across DDL fetcher, mounter, and span management modules.

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

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

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 8, 2026
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 simplifies DDL job fetching by removing support for the tidb_ddl_history table, as TiDB v8.3+ now emits all DDL jobs through tidb_ddl_job. The changes refactor the fetcher and mounter to subscribe to and parse only the job table. Feedback indicates that using job.IsDone() is incorrect because it accepts JobStateSynced jobs, which contradicts the goal of only accepting JobStateDone and would cause the new compatibility tests to fail.

Comment on lines +220 to 222
if !job.IsDone() {
return nil, nil
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The use of job.IsDone() here contradicts the PR description ("accept only JobStateDone jobs") and the new test case ignores synced create table compatibility jobs in mounter_test.go. Since IsDone() returns true for JobStateSynced, this implementation will still accept jobs in the Synced state, causing the test to fail. To align with the goal of dropping the JobStateSynced compatibility path, you should check for model.JobStateDone explicitly.

Suggested change
if !job.IsDone() {
return nil, nil
}
if job.State != model.JobStateDone {
return nil, nil
}

@wlwilliamx wlwilliamx marked this pull request as ready for review April 8, 2026 11:02
@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 Apr 8, 2026
@wlwilliamx
Copy link
Copy Markdown
Collaborator Author

/test all

@wlwilliamx
Copy link
Copy Markdown
Collaborator Author

/retest

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.

remove the capture of the tidb_ddl_history

1 participant