Skip to content

cdc: add table routing feature #23097

Open
3AceShowHand wants to merge 1 commit into
pingcap:masterfrom
3AceShowHand:cdc-table-route-feature
Open

cdc: add table routing feature #23097
3AceShowHand wants to merge 1 commit into
pingcap:masterfrom
3AceShowHand:cdc-table-route-feature

Conversation

@3AceShowHand

Copy link
Copy Markdown
Contributor

First-time contributors' checklist

What is changed, added or deleted? (Required)

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)

What is the related PR or file link(s)?

  • This PR is translated from:
  • Other reference link(s):

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@ti-chi-bot

ti-chi-bot Bot commented Jun 17, 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 kissmydb 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 missing-translation-status This PR does not have translation status info. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 17, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a new documentation page for TiCDC Table Routing and updates the table of contents. The feedback primarily focuses on improving clarity and readability by replacing passive voice with active voice throughout the document, as well as addressing minor grammatical and phrasing issues to align with the style guide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

| Storage services | Storage paths, schema files, table definition files, and data files use the target schema and table names. |
| Redo log | Redo records preserve the target schema and table names. When you apply redo logs, events are replayed to the routed target objects. |

For MQ sinks, table routing does not change the topic or partition dispatch result. For example, if `topic = "{schema}_{table}"` and the source table is `sales.orders`, TiCDC still dispatches the event to the topic `sales_orders` even if the payload table name is routed to `archive.sales_orders`.

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.

medium

Use active voice to improve clarity and readability.

Suggested change
For MQ sinks, table routing does not change the topic or partition dispatch result. For example, if `topic = "{schema}_{table}"` and the source table is `sales.orders`, TiCDC still dispatches the event to the topic `sales_orders` even if the payload table name is routed to `archive.sales_orders`.
For MQ sinks, table routing does not change the topic or partition dispatch result. For example, if `topic = "{schema}_{table}"` and the source table is `sales.orders`, TiCDC still dispatches the event to the topic `sales_orders` even if TiCDC routes the payload table name to `archive.sales_orders`.
References
  1. Avoid passive voice overuse. Prefer active voice for clarity and readability. (link)

RENAME TABLE `archive`.`temp_table_routed` TO `archive`.`renamed_table_routed`;
```

If a DDL statement contains table references, TiCDC also rewrites the referenced table names when they match table routing rules. For example, table references in `CREATE VIEW` statements and foreign key references in `ALTER TABLE` statements can be routed.

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.

medium

Use active voice to improve clarity and readability.

Suggested change
If a DDL statement contains table references, TiCDC also rewrites the referenced table names when they match table routing rules. For example, table references in `CREATE VIEW` statements and foreign key references in `ALTER TABLE` statements can be routed.
If a DDL statement contains table references, TiCDC also rewrites the referenced table names when they match table routing rules. For example, TiCDC can route table references in `CREATE VIEW` statements and foreign key references in `ALTER TABLE` statements.
References
  1. Avoid passive voice overuse. Prefer active voice for clarity and readability. (link)

Comment on lines +63 to +64
| `target-schema` | Specifies the downstream schema name. If this field is not set, TiCDC keeps the upstream schema name. |
| `target-table` | Specifies the downstream table name. If this field is not set, TiCDC keeps the upstream table name. |

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.

medium

Use active voice to improve clarity and readability. Avoid passive phrasing like 'is not set'.

Suggested change
| `target-schema` | Specifies the downstream schema name. If this field is not set, TiCDC keeps the upstream schema name. |
| `target-table` | Specifies the downstream table name. If this field is not set, TiCDC keeps the upstream table name. |
| `target-schema` | Specifies the downstream schema name. If you do not set this field, TiCDC keeps the upstream schema name. |
| `target-table` | Specifies the downstream table name. If you do not set this field, TiCDC keeps the upstream table name. |
References
  1. Avoid passive voice overuse. Prefer active voice for clarity and readability. (link)


## DDL behavior

When table routing is enabled, TiCDC rewrites parser-supported DDL statements so that the structured DDL fields and the SQL text use the same target names.

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.

medium

Use active voice to improve clarity and readability.

Suggested change
When table routing is enabled, TiCDC rewrites parser-supported DDL statements so that the structured DDL fields and the SQL text use the same target names.
When you enable table routing, TiCDC rewrites parser-supported DDL statements so that the structured DDL fields and the SQL text use the same target names.
References
  1. Avoid passive voice overuse. Prefer active voice for clarity and readability. (link)

Comment on lines +112 to +113
- `sales.orders` is routed to `archive.orders_bak`.
- `sales.order_items` is routed to `archive.order_items_bak`.

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.

medium

Use active voice to improve clarity and readability.

Suggested change
- `sales.orders` is routed to `archive.orders_bak`.
- `sales.order_items` is routed to `archive.order_items_bak`.
- TiCDC routes `sales.orders` to `archive.orders_bak`.
- TiCDC routes `sales.order_items` to `archive.order_items_bak`.
References
  1. Avoid passive voice overuse. Prefer active voice for clarity and readability. (link)

- Table routing does not transform row values, column names, column types, or table schemas.
- `filter.rules`, `matcher`, `topic`, `partition`, and `columns` continue to use upstream schema and table names.
- Removing table routing configuration or rolling back TiCDC does not rename downstream tables, move storage files, rewrite MQ messages, or clean up redo logs that have already been generated with target names.
- If the source and target are in the same database instance, make sure that the routed target schemas are not included in the same changefeed replication scope. Otherwise, the changefeed might replicate its own downstream writes.

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.

medium

Use active voice to improve clarity and readability.

Suggested change
- If the source and target are in the same database instance, make sure that the routed target schemas are not included in the same changefeed replication scope. Otherwise, the changefeed might replicate its own downstream writes.
- If the source and target are in the same database instance, make sure that you do not include the routed target schemas in the same changefeed replication scope. Otherwise, the changefeed might replicate its own downstream writes.
References
  1. Avoid passive voice overuse. Prefer active voice for clarity and readability. (link)

- Table routing supports one-to-one table name mapping only. It does not support merging multiple upstream tables into one downstream table.
- Table routing does not transform row values, column names, column types, or table schemas.
- `filter.rules`, `matcher`, `topic`, `partition`, and `columns` continue to use upstream schema and table names.
- Removing table routing configuration or rolling back TiCDC does not rename downstream tables, move storage files, rewrite MQ messages, or clean up redo logs that have already been generated with target names.

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.

medium

Use active voice to improve clarity and readability.

Suggested change
- Removing table routing configuration or rolling back TiCDC does not rename downstream tables, move storage files, rewrite MQ messages, or clean up redo logs that have already been generated with target names.
- Removing table routing configuration or rolling back TiCDC does not rename downstream tables, move storage files, rewrite MQ messages, or clean up redo logs that TiCDC has already generated with target names.
References
  1. Avoid passive voice overuse. Prefer active voice for clarity and readability. (link)


## Limitations

- Table routing supports one-to-one table name mapping only. It does not support merging multiple upstream tables into one downstream table.

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.

low

Improve word order for better flow and clarity.

Suggested change
- Table routing supports one-to-one table name mapping only. It does not support merging multiple upstream tables into one downstream table.
- Table routing supports only one-to-one table name mapping. It does not support merging multiple upstream tables into one downstream table.


If both `sales.orders` and `crm.orders` are in the replication scope, both tables are routed to `archive.orders`. TiCDC rejects the changefeed create or update operation and returns the `CDC:ErrTableRouteConflict` error.

TiCDC also detects conflicts that appear after a changefeed starts. For example, if a wildcard rule starts replicating a newly created table, or a `RENAME TABLE` statement changes a source table name, and the new route result conflicts with an existing target table, the changefeed enters the failed state with `CDC:ErrTableRouteConflict`.

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.

low

Simplify 'newly created table' to 'new table' to avoid unnecessary words, as per the style guide.

Suggested change
TiCDC also detects conflicts that appear after a changefeed starts. For example, if a wildcard rule starts replicating a newly created table, or a `RENAME TABLE` statement changes a source table name, and the new route result conflicts with an existing target table, the changefeed enters the failed state with `CDC:ErrTableRouteConflict`.
TiCDC also detects conflicts that appear after a changefeed starts. For example, if a wildcard rule starts replicating a new table, or a `RENAME TABLE` statement changes a source table name, and the new route result conflicts with an existing target table, the changefeed enters the failed state with `CDC:ErrTableRouteConflict`.
References
  1. Avoid unnecessary words and repetition. (link)

| `{schema}` | The upstream schema name. |
| `{table}` | The upstream table name. |

The value of `target-schema` and `target-table` can contain only literal text, `{schema}`, and `{table}`. If you use an unknown placeholder such as `{db}`, TiCDC rejects the changefeed configuration and returns the `CDC:ErrInvalidTableRoutingRule` error.

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.

low

Use plural 'values' since it refers to two fields: target-schema and target-table.

Suggested change
The value of `target-schema` and `target-table` can contain only literal text, `{schema}`, and `{table}`. If you use an unknown placeholder such as `{db}`, TiCDC rejects the changefeed configuration and returns the `CDC:ErrInvalidTableRoutingRule` error.
The values of `target-schema` and `target-table` can contain only literal text, `{schema}`, and `{table}`. If you use an unknown placeholder such as `{db}`, TiCDC rejects the changefeed configuration and returns the `CDC:ErrInvalidTableRoutingRule` error.

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

Labels

missing-translation-status This PR does not have translation status info. 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.

1 participant