Repository navigation
fix: make MySQL structure sync idempotent for already-existing indexes and constraints - #600
Open
The-king-king wants to merge 2 commits into
Open
The-king-king wants to merge 2 commits into
The-king-king wants to merge 2 commits into
Conversation
…nstraints Structure sync only had IF NOT EXISTS on the table DDL. On a re-run against a non-empty destination, ADD INDEX / ADD CONSTRAINT fail with 1061 / 1826, and the default conflict_policy=interrupt then fails the whole task. Classify MySQL 1050/1061/1826 as a dedicated ObjectAlreadyExists (MD003) code and skip such DDL in the structure sinker, consistent with CREATE TABLE IF NOT EXISTS. Other errors still follow conflict_policy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
Collaborator
|
结构可以先用 sinker.conflict_policy=ignore 来忽略冲突的行为。 这个pr里的实现有些粗暴了,对象存在时忽略我们不希望成为一种默认行为,而是一种针对具体问题可配置的策略。main中新引入的errorcode其实就是期望用来迭代一些基于errorcode的策略行为,比如指定code时重试、忽略、报错。但这是个大工程,比如对象存在忽略的行为,不止是struct sinker会碰到,数据sinker回放ddl时一样会碰到这类问题 btw,使用的话可以先以我们最新的release分支(目前最新的是release-2.0.26.1)代码为基准,main上的有很多alpha的功能代码,在release前可能会有breaking change |
Contributor
Author
好的,感谢 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
ErrorCode::ObjectAlreadyExists(MD003) and map MySQL1050/1061/1826to itObjectAlreadyExistsinstead of failing the task, matching
CREATE TABLE IF NOT EXISTS; other errorsstill follow
conflict_policydocs/en/error_codes.mdanddocs/zh/error_codes.mdFixes #599
Why
Structure sync is meant to be re-runnable, but only the table DDL had
IF NOT EXISTS. On a re-run against a non-empty destination the index DDL(
ALTER TABLE ... ADD INDEX) fails with1061, and with the defaultconflict_policy=interruptthe whole task fails.Notes
Test plan
cargo test -p dt-common --lib(213 passed)cargo test -p dt-connector(131 passed)cargo clippy -p dt-common -p dt-connector --all-targets(no new warnings)cargo fmt --all -- --check