主从设计问题

发布于 2024-07-23 07:30:24 字数 248 浏览 14 评论 0原文

按照设计,所有读取都应该从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

农村范ル 2024-07-30 07:30:24

正如你所指出的,那是不安全的; 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;-).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文