mysql 隔离级别

发布于 2024-08-07 06:50:25 字数 575 浏览 1 评论 0原文

我对这里的文档有点困惑。我有一个事务,该

  1. 事务启动事务
  2. 执行一些更新
  3. 执行一些选择
  4. 执行更多更新
  5. 提交

我希望我在步骤3中的选择看到步骤2中的更新结果,但是我希望能够回滚整个事情。

已提交读取似乎意味着选择仅显示已提交的数据,而可重复读取似乎意味着所有后续选择将看到与提交时存在的相同数据第一次选择 - 因此忽略我的更新。 读取未提交似乎做了正确的事情,但是:“但是可能会使用行的可能早期版本”——这也是不可接受的,因为我的选择必须看到我的更新结果。

可序列化真的是我唯一的希望吗?

我正在处理文档这里< /a>

I'm a bit confused by the documentation here. I have a transaction, which

  1. start transaction
  2. does some updates
  3. does some selects
  4. does some more updates
  5. commit

I want my selects at step 3 to see the results of updates in step 2 but I want to be able to roll back the whole thing.

read committed seems to imply that selects only show data that's been committed, and repeatable read seems to imply that all subsequent selects will see the same data as existed at the time of the 1st select - thus ignoring my updates. read uncommitted seems to do the right thing, but: "but a possible earlier version of a row might be used" -- this is also not acceptable, as my selects MUST see the result of my updates.

is serializable really my only hope here?

I'm working off the documentation here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

转瞬即逝 2024-08-14 06:50:25

事务隔离级别仅描述并发事务之间的交互。对于任何隔离级别,您在同一事务中更新的内容将在您从该事务中重新选择它们时更新。

在您的情况下,正确的隔离级别似乎是读已提交,因此您可以在任何时候回滚,并且未提交的数据在其他事务中不可见。

Transaction isolation levels describe only the interaction between concurrent transactions. With any isolation level, stuff that you have updated within the same transaction will be updated when you re-select them from that transaction.

The right isolation level in your case seems to be read commited, so you can rollback at any point and uncommited data is not visible in other transactions.

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