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

rename ddl引起no such dataMedia #57

Closed
agapple opened this issue Jul 3, 2014 · 1 comment
Closed

rename ddl引起no such dataMedia #57

agapple opened this issue Jul 3, 2014 · 1 comment
Assignees
Labels
Milestone

Comments

@agapple
Copy link
Member

agapple commented Jul 3, 2014

用户使用一些online ddl操作,大致步骤:
第一步:mytable 复制成 _mytable_new
第二部:mytable 改名 _mytable_old
第三部:_mytable_new 改名 mytable
第四部:删除 _mytable_old

同步映射关系配置中,目前只定义了mytable,因为canal进行表匹配,是将rename的源和目标表,只要其中一个满足映射规则条件,就会返回. 所以在第一步时,otter就会收到rename mytable to _mytable_new的sql,而为了保证表结构的正确性,otter会根据rename的目标库清空对应的表结构cache. 因为映射规则没配置_mytable_new,所以就出现了该问题

@agapple agapple added this to the 4.2.11 milestone Jul 3, 2014
@agapple agapple added the bug label Jul 3, 2014
@agapple agapple self-assigned this Jul 3, 2014
@agapple
Copy link
Member Author

agapple commented Jul 3, 2014

解决办法:otter在清空表结构时,检查下对应tablename是否存在映射关系中,如果不存在则忽略之.

针对以上online ddl的同步,几点建议:

  1. 新增列时,新加目标库,同时建议不加带默认值的列. 否则otter需要同步 _mytable_new的数据,才能保证数据不错
  2. 因为在第一步到第二步过程中,持续时间比较长,这时在mytable上的数据变更,也会通过trigger写到_mytable_new中,所以可以忽略_mytable_new同步,只关注mytable即可. 在整个ddl做完那瞬间,_mytable_new和_mytable_old表数据应该是一致的。

agapple added a commit that referenced this issue Jul 3, 2014
@agapple agapple closed this as completed Jul 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant