How does transaction suspension work in MySQL?
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?
Th开发者_JAVA技巧ank you,
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 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.
精彩评论