Skip to content

api(ticdc): add ineligibleTables/eligible tables info when creating/updating changefeed#12500

Open
wk989898 wants to merge 4 commits intopingcap:masterfrom
wk989898:changefeed-info
Open

api(ticdc): add ineligibleTables/eligible tables info when creating/updating changefeed#12500
wk989898 wants to merge 4 commits intopingcap:masterfrom
wk989898:changefeed-info

Conversation

@wk989898
Copy link
Collaborator

@wk989898 wk989898 commented Jan 28, 2026

What problem does this PR solve?

Issue Number: close #12501

What is changed and how it works?

It introduces a new API endpoint /api/v2/get_all_tables and updates the corresponding CLI commands to display this information, including a new --verbose flag. However, I've found a critical bug related to variable shadowing in the resume command, an error handling issue in a new API handler, and several instances of code duplication and misleading CLI output that should be addressed.

Check List

Tests

  • Unit test
  • Integration test

Questions

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

Release note

add tables info when creating/updating changefeed

Signed-off-by: wk989898 <nhsmwk@gmail.com>
@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 Jan 28, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jan 28, 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 benmeadowcroft, wk989898 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 the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 28, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @wk989898, 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 significantly improves the transparency and user experience for managing TiCDC changefeeds by exposing more detailed table information through both a new API endpoint and enhanced CLI commands. It allows users to easily inspect which tables are considered, eligible, or ineligible for replication, and provides verbose output options for in-depth analysis during changefeed creation, resumption, and updates. This addresses previous limitations regarding visibility into table filtering and eligibility.

Highlights

  • New API Endpoint: Introduced /api/v2/get_all_tables to retrieve comprehensive table information for changefeeds, including eligible, ineligible, and all tables.
  • Enhanced CLI Output: The cdc cli changefeed create, resume, and update commands now display counts for ineligible, eligible, and all tables, providing a clearer overview of replication scope.
  • Verbose Table Listing: A new --verbose flag has been added to the create, resume, and update CLI commands, allowing users to optionally list all eligible, ineligible, and total tables for detailed inspection.
  • Table Verification Logic Update: The core VerifyTables function in cdc/entry/validator.go has been modified to return an additional list of allTables, which is now propagated through API helpers and interfaces.
  • Ineligible Table Warnings in CLI: The resume and update CLI commands now proactively fetch and display warnings for ineligible tables, prompting user confirmation if ForceReplicate is not set, improving data integrity awareness.

🧠 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.

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.

Copy link

@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 introduces a new API endpoint /api/v2/get_all_tables and updates the CLI to display more detailed table information when creating or updating a changefeed. The changes are generally well-implemented. However, I've identified a few areas for improvement regarding code duplication, error handling in the new API handler, and user-facing output in the CLI commands. Addressing these points will enhance the maintainability and user experience of the new features.

Comment on lines +352 to +369
var kvStore tidbkv.Storage
// if PDAddrs is empty, use the default upstream
if len(cfg.PDAddrs) == 0 {
up, err := getCaptureDefaultUpstream(h.capture)
if err != nil {
_ = c.Error(err)
return
}
kvStore = up.KVStorage
} else {
credential := cfg.PDConfig.toCredential()
var err error
kvStore, err = h.helpers.createTiStore(ctx, cfg.PDAddrs, credential)
if err != nil {
_ = c.Error(errors.Trace(err))
return
}
}

Choose a reason for hiding this comment

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

medium

This block of code for acquiring kvStore is duplicated in the verifyTable function. To improve maintainability and reduce redundancy, consider extracting this logic into a private helper method on OpenAPIV2.

Comment on lines +373 to +382
f, err := filter.NewFilter(replicaCfg, "")
if err != nil {
_ = c.Error(err)
return
}
_, ineligibleTables, eligibleTables, allTables, err := entry.
VerifyTables(f, kvStore, cfg.StartTs)
if err != nil {
_ = c.Error(err)
return

Choose a reason for hiding this comment

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

medium

The errors from filter.NewFilter and entry.VerifyTables are passed to c.Error without being wrapped. This can lead to a loss of context, making debugging more difficult. It's recommended to wrap these errors, for example, using cerror.WrapError(cerror.ErrInternalServerError, err), to provide more information about where the error originated.

Suggested change
f, err := filter.NewFilter(replicaCfg, "")
if err != nil {
_ = c.Error(err)
return
}
_, ineligibleTables, eligibleTables, allTables, err := entry.
VerifyTables(f, kvStore, cfg.StartTs)
if err != nil {
_ = c.Error(err)
return
f, err := filter.NewFilter(replicaCfg, "")
if err != nil {
_ = c.Error(cerror.WrapError(cerror.ErrInternalServerError, err))
return
}
_, ineligibleTables, eligibleTables, allTables, err := entry.
VerifyTables(f, kvStore, cfg.StartTs)
if err != nil {
_ = c.Error(cerror.WrapError(cerror.ErrInternalServerError, err))
return
}

Comment on lines +227 to +235
cmd.Printf("[WARN] Force to replicate some ineligible tables, "+
"these tables do not have a primary key or a not-null unique key: %#v\n"+
"[WARN] This may cause data redundancy, "+
"please refer to the official documentation for details.\n",
tables.IneligibleTables)
} else {
cmd.Printf("[WARN] Some tables are not eligible to replicate, "+
"because they do not have a primary key or a not-null unique key: %#v\n",
tables.IneligibleTables)

Choose a reason for hiding this comment

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

medium

The warning messages for ineligible tables use %#v to print the table list. This format is not user-friendly as it prints the Go struct representation. Please use the formatTableNames helper function for a cleaner, more readable output, similar to how it's used for the --verbose output.

if cf.Config.ForceReplicate {
				cmd.Printf("[WARN] Force to replicate some ineligible tables, "+
					"these tables do not have a primary key or a not-null unique key: %s\n"+
					"[WARN] This may cause data redundancy, "+
					"please refer to the official documentation for details.\n",
					formatTableNames(tables.IneligibleTables))
			} else {
				cmd.Printf("[WARN] Some tables are not eligible to replicate, "+
					"because they do not have a primary key or a not-null unique key: %s\n",
					formatTableNames(tables.IneligibleTables))

cmd.Printf("IneligibleTables: %s\n", formatTableNames(tables.IneligibleTables))
cmd.Printf("AllTables: %s\n", formatTableNames(tables.AllTables))
}
return err

Choose a reason for hiding this comment

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

medium

Returning err here is slightly confusing because at this point, err is guaranteed to be nil due to the preceding error check. For better clarity, it's recommended to explicitly return nil.

return nil

Comment on lines +169 to +177
cmd.Printf("[WARN] Force to replicate some ineligible tables, "+
"these tables do not have a primary key or a not-null unique key: %#v\n"+
"[WARN] This may cause data redundancy, "+
"please refer to the official documentation for details.\n",
tables.IneligibleTables)
} else {
cmd.Printf("[WARN] Some tables are not eligible to replicate, "+
"because they do not have a primary key or a not-null unique key: %#v\n",
tables.IneligibleTables)

Choose a reason for hiding this comment

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

medium

The warning messages for ineligible tables use %#v to print the table list. This format is not user-friendly as it prints the Go struct representation. Please use the formatTableNames helper function for a cleaner, more readable output, similar to how it's used for the --verbose output.

Suggested change
cmd.Printf("[WARN] Force to replicate some ineligible tables, "+
"these tables do not have a primary key or a not-null unique key: %#v\n"+
"[WARN] This may cause data redundancy, "+
"please refer to the official documentation for details.\n",
tables.IneligibleTables)
} else {
cmd.Printf("[WARN] Some tables are not eligible to replicate, "+
"because they do not have a primary key or a not-null unique key: %#v\n",
tables.IneligibleTables)
if newInfo.Config.ForceReplicate {
cmd.Printf("[WARN] Force to replicate some ineligible tables, "+
"these tables do not have a primary key or a not-null unique key: %s\n"+
"[WARN] This may cause data redundancy, "+
"please refer to the official documentation for details.\n",
formatTableNames(tables.IneligibleTables))
} else {
cmd.Printf("[WARN] Some tables are not eligible to replicate, "+
"because they do not have a primary key or a not-null unique key: %s\n",
formatTableNames(tables.IneligibleTables))

Signed-off-by: wk989898 <nhsmwk@gmail.com>
Signed-off-by: wk989898 <nhsmwk@gmail.com>
.
Signed-off-by: wk989898 <nhsmwk@gmail.com>
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 16, 2026

@wk989898: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-verify ec3daac link true /test pull-verify
pull-cdc-integration-kafka-test ec3daac link true /test pull-cdc-integration-kafka-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

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/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.

Add more details when creating changefeed

1 participant