事务暂停在MySQL中如何工作? [英] How does transaction suspension work in MySQL?

查看:236
本文介绍了事务暂停在MySQL中如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Spring Framework手册中,他们声明对于PROPAGATION_REQUIRES_NEW,当前事务将被暂停.

In the Spring Framework manual they state that for a PROPAGATION_REQUIRES_NEW the current transaction will be suspended.

暂停交易"是什么? 超时计时器停止在当前事务上计数吗? 这种暂停的实际含义是什么?

What does that "suspended transaction"? The timer for the timeout stops counting on the current transaction? What are the actual implication of such suspension?

谢谢

Asaf

推荐答案

这并不意味着什么特别的东西,挂起的事务只是暂时不用于插入,更新,提交的事务或回滚,因为应根据指定的传播属性创建一个新事务,并且一次只能激活一个事务.

It doesn't mean anything special, a suspended transaction is just a transaction that is temporarily not used for inserts, updates, commit or rollback, because a new transaction should be created due to the specified propagation properties, and only one transaction can be active at the same time.

基本上有两种交易模型:嵌套和扁平模型.在嵌套模型中,如果您开始一个事务,并且需要另一个事务,则第一个事务将保持活动状态,也就是说,第二个事务将嵌套在其父事务中,依此类推.另一方面,在平面模型中,第一笔交易将被暂停,也就是说,在新交易完成之前,我们将不使用它.

Basically there are two transaction models: the nested and flat model. In the nested model, if you start a transaction, and you need an other one, the first one remains active, that is, the second one will be nested inside its parent, and so on. On the other hand, in the flat model, the first transaction will be suspended, that is, we won't use it until the new one has been completed.

AFAIK平面模型几乎只使用了(包括Spring和EJB规范),因为它很容易实现:在任何给定时间只有一个活动事务,因此很容易例如由于异常而决定在发生回滚的情况下该怎么做.更重要的是,如果您需要嵌套模型,则基础数据库必须支持它.因此,在这种情况下,平面模型只是公分母.

AFAIK the flat model is used almost exclusively (including Spring and the EJB spec as well), since it's much easier to implement: there is only one active transaction at any given time, so it's easy to decide what to do in case of a rollback, say, because of an exception. More importantly, the underlying database has to support it if you need the nested model, so the flat model is just the common denominator in this case.

这篇关于事务暂停在MySQL中如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆