Refine the initialization of schema snapshots. #11109
Labels
area/ticdc
Issues or PRs related to TiCDC.
type/enhancement
The issue or PR belongs to an enhancement.
Is your feature request related to a problem?
Currently, during initialization, a changefeed retrieves all table schemas from upstream and then applies filter rules to these schemas to determine which tables will be replicated. This process can be time-consuming if there are a large number of tables upstream. However, only a few tables may need to be replicated, making the rest of the schemas unnecessary.
Consider a changefeed with the following filter rules as an example.
This changefeed only wants to copy the
db.t1
table. But, it needs to get the schema of all tables in thedb
database at the start. Ifdb
has thousands of tables, this can take a lot of time.We recently saw a problem where this caused about a 10 minute delay in the CDC. We saw this when there were hundreds of changefeeds and thousands of tables in a CDC failover situation.
Efforts have been made to resolve the lag increase problem, but further improvement is still needed.
So, we need to find a way to make getting the schemas quicker.
We have two ideas to fix this problem.
Solution 1
TableNameInfo
. This only includes the name and ID of a table, making it smaller thanTableInfo
.TableNameInfos
to locate the tables of interest.This approach can reduce time costs by minimizing the amount of data that needs to be loaded. However, in the worst-case scenario (where the changefeed is interested in all upstream tables), it could result in additional network costs.
Solution 2
Add a new method to https://github.com/pingcap/tidb/blob/63cf3e54aeaaa2cfdee8d6587064d62ba3ad2a52/pkg/meta/meta.go#L993 as below:
This method lets the caller use a function to pick the right tableInfos, which cuts down on extra network costs. But it means changing the code in the TiDB repository and updating the TiDB dependency in the TiFlow repository. This might bring about unforeseen issues and need extra work.
So, I suggest we put solution 1 in place for version ≤ v8.1.0, and bring in solution 2 in the next release of TiCDC.
This way, we'll save time in most situations and keep changes small.
Describe the feature you'd like
as above.
Describe alternatives you've considered
No response
Teachability, Documentation, Adoption, Migration Strategy
No response
The text was updated successfully, but these errors were encountered: