Skip to content

logservice,event: stop capturing tidb_ddl_history (#4766)#4905

Open
ti-chi-bot wants to merge 1 commit intopingcap:release-8.5from
ti-chi-bot:cherry-pick-4766-to-release-8.5
Open

logservice,event: stop capturing tidb_ddl_history (#4766)#4905
ti-chi-bot wants to merge 1 commit intopingcap:release-8.5from
ti-chi-bot:cherry-pick-4766-to-release-8.5

Conversation

@ti-chi-bot
Copy link
Copy Markdown
Member

This is an automated cherry-pick of #4766

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 handling to use only the main DDL job table and removed legacy history-table handling; parsing now focuses on completed jobs for a normalized DDL lifecycle.
  • Tests
    • Added unit tests validating the consolidated span discovery and the updated job-parsing behavior for various DDL job states.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Apr 24, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 24, 2026

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot
Copy link
Copy Markdown
Member Author

@wlwilliamx This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 24, 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 wlwilliamx 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
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 24, 2026

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 46860441-1a23-4456-9e6d-8a80e1b4c9e3

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 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 removes the logic for capturing and processing DDL jobs from the tidb_ddl_history table, simplifying the schema store to only subscribe to the tidb_ddl_job table. This change reflects TiDB's normalized DDL lifecycle in version 8.3+. Feedback highlights critical issues that must be addressed before merging: unresolved git merge conflict markers were found in ddl_job_fetcher.go and span_op.go, and a missing import in span_op.go will lead to compilation errors. Additionally, it is recommended to explicitly check for JobStateDone in the parseJob function to strictly adhere to the intended filtering logic.

Comment on lines +246 to +255
<<<<<<< HEAD
const (
// JobTableID is the id of `tidb_ddl_job`.
JobTableID = ddl.JobTableID
// JobHistoryID is the id of `tidb_ddl_history`
JobHistoryID = ddl.HistoryTableID
)

=======
>>>>>>> 895bb89bc (logservice,event: stop capturing tidb_ddl_history (#4766))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The code contains git merge conflict markers. These should be resolved before merging. Since common.JobTableID is now used in getAllDDLSpan, these local constants are redundant and can be removed.

Comment thread pkg/common/span_op.go
Comment on lines +35 to +41
<<<<<<< HEAD
JobTableID = ddl.JobTableID
// JobHistoryID is the id of `tidb_ddl_history`
JobHistoryID = ddl.HistoryTableID
=======
JobTableID = metadef.TiDBDDLJobTableID
>>>>>>> 895bb89bc (logservice,event: stop capturing tidb_ddl_history (#4766))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The code contains git merge conflict markers. Additionally, metadef is not imported in this file, so the second branch of the conflict would cause a compilation error. Please resolve this by keeping only the JobTableID = ddl.JobTableID definition and removing JobHistoryID.

	JobTableID = ddl.JobTableID

}
// We only replay DDL jobs that are already visible in the normalized Done
// state so schema store ordering stays aligned with the job table stream.
if !job.IsDone() {
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 PR description and the added test case ignores synced create table compatibility jobs indicate that only JobStateDone should be accepted. job.IsDone() is too broad as it typically includes JobStateSynced (and other terminal states like Cancelled). To strictly ignore JobStateSynced as intended, you should check for model.JobStateDone explicitly.

Suggested change
if !job.IsDone() {
if job.State != model.JobStateDone {

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

Labels

do-not-merge/cherry-pick-not-approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants