Skip to content

Conversation

hongyunyan
Copy link
Collaborator

What problem does this PR solve?

Issue Number: close #xxx

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

@ti-chi-bot ti-chi-bot bot added 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. labels Sep 5, 2025
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.

Summary of Changes

Hello @hongyunyan, 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 is a cherry-pick that primarily focuses on improving code organization and enhancing the changefeed scheduling capabilities. It centralizes sink scheme helper functions into a common configuration package and introduces a new EnableSplittableCheck option. This option refines how tables are distributed and split across nodes, with an automatic adjustment for MySQL-compatible sinks to maintain data integrity. The changes aim to make the system more robust and configurable regarding data distribution.

Highlights

  • Refactoring of Sink Scheme Helpers: All sink scheme-related constants and helper functions (e.g., IsMySQLCompatibleScheme, GetScheme) have been moved from downstreamadapter/sink/helper to pkg/config/sink_protocol.go for better organization and reusability across the codebase.
  • Introduction of EnableSplittableCheck Configuration: A new configuration option, EnableSplittableCheck, has been added to ChangefeedSchedulerConfig. This flag controls whether a table's splittability (presence of primary key/unique key) is checked before splitting it across nodes.
  • Automatic Adjustment for MySQL-Compatible Sinks: For MySQL-compatible downstream sinks, the EnableSplittableCheck option is now automatically set to true to ensure data consistency, overriding any user-defined values if necessary.
  • Updated Table Splitting Logic: The internal logic for splitting tables across nodes has been updated to incorporate the EnableSplittableCheck flag, allowing for more flexible or stricter splitting behavior based on the sink type and configuration.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 primarily refactors sink-related helper functions and constants by moving them from downstreamadapter/sink/helper to the pkg/config package, which improves code organization. It also introduces a new enable-splittable-check configuration to control table splitting behavior, which is now also enabled on single-node deployments. The changes are mostly clean, but a logic change related to table splitting could be made clearer to improve maintainability.

@@ -142,7 +145,7 @@ func (c *Controller) AddNewTable(table commonEvent.Table, startTs uint64) {
EndKey: span.EndKey,
}
tableSpans := []*heartbeatpb.TableSpan{tableSpan}
if c.enableTableAcrossNodes && table.Splitable && c.splitter != nil && c.nodeManager != nil && len(c.nodeManager.GetAliveNodes()) > 1 {
if c.enableTableAcrossNodes && c.splitter != nil && (table.Splitable || !c.enableSplittableCheck) {

Choose a reason for hiding this comment

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

medium

The condition for splitting tables has been changed to allow splitting on a single node by removing the len(c.nodeManager.GetAliveNodes()) > 1 check. While this enables a new capability, it also changes the behavior of the enableTableAcrossNodes flag, which now controls table splitting in general, not just across nodes. This could be confusing for future maintainers. Consider adding a comment to clarify that table splitting is now supported on a single node when this flag is enabled.

@ti-chi-bot ti-chi-bot bot added the lgtm label Sep 5, 2025
Copy link

ti-chi-bot bot commented Sep 5, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-09-05 13:52:21.446895638 +0000 UTC m=+23808.006777125: ☑️ agreed by lidezhu.

Copy link

ti-chi-bot bot commented Sep 5, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lidezhu
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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm 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.

2 participants