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

能给解释一下这句话的含义吗? #2

Open
shizenghua opened this issue May 11, 2017 · 1 comment
Open

能给解释一下这句话的含义吗? #2

shizenghua opened this issue May 11, 2017 · 1 comment

Comments

@shizenghua
Copy link

shizenghua commented May 11, 2017

3.为了避免多进程对MQ消费速度的时序先后不可控,建议binlog数据只作为触发条件(使用id从mysql获取最新数据)作为数据使用,而不作为具体数据使用。

# 不太清楚是什么意思。

@liukelin
Copy link
Owner

canal将有序的binlog推送出来,写入到MQ,到这里为止binlog都是有序的。
但是 我们的消费脚本(案例里是用python将binlog写入redis)是多进程的消费MQ的,多个消费端从MQ取binlog 也是有序的。
但是无法保证每个进程处理时间有序,这样的话就会发生有序的binlog,最终写入redis的时间会有乱序。

MQ ->【d, c ,b ,a 】
----消费进程1 消费a
----消费进程2 消费b
我们无法保证消费进程1一定比2先执行完。如果a、b是同一条数据,a是insert,b是delete,最终结果应该是数据被删除了。但如果乱序了,数据还是存在的。
所以不能直接使用binlog里面的值,而是需要重新从mysql获取当前的最新数据。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants