Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/filter(ticdc): ignore ddl in ddl_manager #10518

Merged
merged 8 commits into from
Jan 24, 2024

Conversation

CharlesCheung96
Copy link
Contributor

@CharlesCheung96 CharlesCheung96 commented Jan 22, 2024

What problem does this PR solve?

Issue Number: close #10524

What is changed and how it works?

After this pr, the behavior of TiCDC in ignoring create/delete/truncate/alter DDL scenarios is as follows:

Case 1: After a table or partition is created, TiCDC synchronizes the new physical table.

[filter]
rules = ['test.*']

[[filter.event-filters]]
matcher = ["test.t1"] # matcher is an allow list, which means this rule only applies to the worker table in the test database.
ignore-event = ["create table, add table partition"] 

Case 2: After a table or partition is dropped, TiCDC does not synchronize the deleted physical table.

[filter]
rules = ['test.*']

[[filter.event-filters]]
matcher = ["test.t1"] # matcher is an allow list, which means this rule only applies to the worker table in the test database.
ignore-event = ["drop table, drop table partition"] 

Case 3: After a table or partition is truncated, TiCDC does not synchronize the deleted physical table, and synchronizes the new physical table.

[filter]
rules = ['test.*']

[[filter.event-filters]]
matcher = ["test.t1"] # matcher is an allow list, which means this rule only applies to the worker table in the test database.
ignore-event = ["truncate table, truncate table partition"] 

Case 4: After the Alter table or partition ddl, CDC uses the schma of the new table to parse data.

[filter]
rules = ['test.*']

[[filter.event-filters]]
matcher = ["test.t1"] # matcher is an allow list, which means this rule only applies to the worker table in the test database.
ignore-event = ["alter table, alter table partition"] 

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

`Fix the issue of cdc does not synchronize related tables after ddl was filtered`.

Copy link
Contributor

ti-chi-bot bot commented Jan 22, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 22, 2024
pkg/filter/filter.go Outdated Show resolved Hide resolved
@sre-bot
Copy link

sre-bot commented Jan 22, 2024

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 22, 2024
@CharlesCheung96
Copy link
Contributor Author

/test all

@CharlesCheung96
Copy link
Contributor Author

/test all

@CharlesCheung96 CharlesCheung96 marked this pull request as ready for review January 22, 2024 10:24
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 22, 2024
m.justSentDDL = m.executingDDL
m.executingDDL = nil
m.cleanCache()
skip, cleanMsg, err := m.shouldSkipDDL(m.executingDDL)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we decide whether to skip this ddl here, but not in where we append ddls into pendingDDLs in "ddlManager.tick"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because all ddls must be cached in pengingDDLs until m.checkpointTs == nextDDL.CommitTs. Otherwise, the changefeed's checkpoint cannot be guaranteed to be correct.

pkg/filter/filter.go Show resolved Hide resolved
@CharlesCheung96
Copy link
Contributor Author

/test all pd=7.6.0

@@ -597,13 +597,13 @@ LOOP2:
}
c.barriers.Update(finishBarrier, c.latestInfo.GetTargetTs())

f, err := filter.NewFilter(c.latestInfo.Config, "")
filter, err := filter.NewFilter(c.latestInfo.Config, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

filter is also the package name, so I renamed it to f. filter looks good to me, but report warning by the IDE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use the package alias pfilter, PTAL

// In a BDR mode cluster, TiCDC can receive DDLs from all roles of TiDB.
// However, CDC only executes the DDLs from the TiDB that has BDRRolePrimary role.
if m.BDRMode && ddl.BDRRole != string(ast.BDRRolePrimary) {
return true, "changefeed is in BDRMode and the DDL is not executed by Primary Cluster, skip it", nil
Copy link
Contributor

Choose a reason for hiding this comment

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

the second returned value looks used to print log, can we just print the log here, instead of return it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If redo is enabled, shouldSkipDDL will be called twice, so we use the return value to avoid printing duplicate logs.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 23, 2024
Copy link
Contributor

ti-chi-bot bot commented Jan 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3AceShowHand, hongyunyan, sdojjy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [3AceShowHand,sdojjy]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

ti-chi-bot bot commented Jan 23, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-01-23 02:57:22.064043991 +0000 UTC m=+843083.628341693: ☑️ agreed by 3AceShowHand.
  • 2024-01-23 13:56:24.822430829 +0000 UTC m=+882626.386728534: ☑️ agreed by sdojjy.

@CharlesCheung96
Copy link
Contributor Author

/retest

@CharlesCheung96
Copy link
Contributor Author

/test all

@CharlesCheung96
Copy link
Contributor Author

/retest

1 similar comment
@CharlesCheung96
Copy link
Contributor Author

/retest

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Merging #10518 (96c7b2a) into master (ea976f4) will decrease coverage by 0.0423%.
Report is 3 commits behind head on master.
The diff coverage is 66.2162%.

Additional details and impacted files
Components Coverage Δ
cdc 61.6866% <66.2162%> (-0.1201%) ⬇️
dm 51.2944% <ø> (+0.0587%) ⬆️
engine 63.4423% <ø> (+0.0212%) ⬆️
Flag Coverage Δ
unit 57.4569% <66.2162%> (-0.0423%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@               Coverage Diff                @@
##             master     #10518        +/-   ##
================================================
- Coverage   57.4992%   57.4569%   -0.0423%     
================================================
  Files           849        848         -1     
  Lines        126073     125795       -278     
================================================
- Hits          72491      72278       -213     
+ Misses        48174      48116        -58     
+ Partials       5408       5401         -7     

@ti-chi-bot ti-chi-bot bot merged commit 8d3e31b into pingcap:master Jan 24, 2024
27 of 28 checks passed
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Jan 24, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #10539.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #10540.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Jan 24, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #10541.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Jan 24, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
CharlesCheung96 added a commit to ti-chi-bot/tiflow that referenced this pull request Jan 24, 2024
CharlesCheung96 added a commit to ti-chi-bot/tiflow that referenced this pull request Jan 24, 2024
CharlesCheung96 added a commit to ti-chi-bot/tiflow that referenced this pull request Jan 24, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Jan 24, 2024
CharlesCheung96 added a commit to ti-chi-bot/tiflow that referenced this pull request Jan 24, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Jan 25, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ddl events should not be filtered in puller
7 participants