How to suspend transactions in MySQL?

The Spring Framework manual states that for PROPAGATION_REQUIRES_NEW the current transaction will be paused.

What does this "suspended transaction" do? Does the timer for timeout stop counting on the current transaction? What are the actual consequences of such a suspension?

Thanks,

Asaf

+5
source share
1 answer

This does not mean anything special, a suspended transaction is just a transaction that is temporarily not used for inserts, updates, commit or rollback, since a new transaction must be created due to the specified distribution property, and only one transaction can be active at a time.

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

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

+4
source

Source: https://habr.com/ru/post/956505/


All Articles