主从设计问题
按照设计,所有读取都应该从slave上进行,并在master上进行更新,
但请考虑以下情况:
table_a中有一个列water_mark,
我需要从table_b读取,其列time_mark大于
table_a的列water_mark,
如果我读取从slave,然后将master中的water_mark列更新为“now()”,
如果slave和master之间有很大的延迟怎么办?
By design,all read should be from slave,and update on master,
but consider the following situation:
there is a column water_mark in table_a,
and I need to read from table_b whose column time_mark is larger than column water_mark of
table_a,
If I read from slave,then update the column water_mark to "now()" in master,
what if there is a big delay between slave and master?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如你所指出的,那是不安全的;
SELECT ... FOR UPDATE
和其他“读取以便写入”事务必须在同一台服务器上进行读取和写入操作(当然,在 InnoDB 表上) ;-)。As you indicate, that would be unsafe;
SELECT ... FOR UPDATE
and other "read in order to then write" transactions must have the read and write on the same server (and, on InnoDB tables, of course;-).