sink(ticdc): retry later when meet unexpected DDL state#12483
sink(ticdc): retry later when meet unexpected DDL state#12483ti-chi-bot[bot] merged 6 commits intopingcap:masterfrom
Conversation
Summary of ChangesHello @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 enhances the robustness of the TiCDC DDL sink by modifying its error handling for unexpected DDL states. Instead of immediately failing, the system will now attempt to retry the operation, treating such states as transient issues. This change aims to prevent potential data inconsistencies or interruptions in DDL replication. Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request modifies the DDL sink logic to retry when an unexpected DDL state is encountered. Specifically, when a DDL job is not found in the downstream TiDB after a connection error, instead of failing immediately, it now triggers a retry of the DDL execution. This is achieved by wrapping the ErrDDLStateNotFound with mysql.ErrInvalidConn to make it retryable. While this works, I've suggested a cleaner implementation for better long-term maintainability by making ErrDDLStateNotFound inherently retryable, which would make the code's intent clearer.
| log.Warn("Unexpected DDL state, may not be found downstream", zap.String("ddl", ddl.Query), zap.String("ddlCreateTime", ddlCreateTime), zap.Any("ddlState", state)) | ||
| return errors.ErrDDLStateNotFound.GenWithStackByArgs(state) | ||
| log.Warn("Unexpected DDL state, may not be found downstream, retry later", zap.String("ddl", ddl.Query), zap.String("ddlCreateTime", ddlCreateTime), zap.Any("ddlState", state)) | ||
| return errors.WrapError(errors.ErrDDLStateNotFound, mysql.ErrInvalidConn, state) |
There was a problem hiding this comment.
While wrapping the error with mysql.ErrInvalidConn does make it retryable by the outer retry.Do loop, this approach is a bit misleading as the underlying issue is not a connection error. This could make debugging more difficult in the future.
A cleaner approach would be to make errors.ErrDDLStateNotFound itself retryable. This could be achieved by modifying errorutil.IsRetryableDDLError to recognize errors.ErrDDLStateNotFound.
For example, in pkg/errorutil/util.go:
func IsRetryableDDLError(err error) bool {
if errors.Is(err, cerror.ErrDDLStateNotFound) {
return true
}
// ... existing code
}This would make the intent clearer and avoid misrepresenting the error. If changing errorutil is out of scope for this PR, the current change is acceptable as a workaround, but consider refactoring this in the future.
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: asddongmen, hongyunyan The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/retest |
|
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
What problem does this PR solve?
Issue Number: close #12482
What is changed and how it works?
When meeting the unexpected DDL state, instead of immediately failing, CDC now attempts to retry the DDL. This change aims to avoid CDC restart.
Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note