Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default isolation level across nested transactions (instead of concurrent ones)?

Spring has 3 typical nested transactions propagations: REQUIRED, NEW and NESTED. Isolation level types are always described in terms of concurrent transactions. But what about nested case? What is the default visibility from inner to outer and the other way around and how does setting isolation level on either affect?

Is there perhaps any rule of thumb like 'an outer transaction always sees changes from an inner unregarding isolation or propagation types' or 'an inner can only see outer's changes when its set as read_uncommited. Or its set as required, etc..?

EDIT: I am not talking of actual sql queries, but the persistence context. I mean, if I create a resource and read it in another part of a nested transaction model, will I see the change regardless of whether it was actually persisted? A good example is a transactional workflow that executes transactional methods that use repository.save, repository.find ... etc

like image 695
Whimusical Avatar asked Nov 21 '18 23:11

Whimusical


1 Answers

There is no isolation between inner and outer transaction. The only reason why it exists is save points. That thing just let you to roll back the inner transaction without rolling back the outer transaction. Documentation says:

PROPAGATION_NESTED uses a single physical transaction with multiple savepoints that it can roll back to. Such partial rollbacks let an inner transaction scope trigger a rollback for its scope, with the outer transaction being able to continue the physical transaction despite some operations having been rolled back. This setting is typically mapped onto JDBC savepoints, so it works only with JDBC resource transactions. See Spring’s DataSourceTransactionManager.

UPD: You can also find:

Transaction isolation level. Only applicable to propagation settings of REQUIRED or REQUIRES_NEW.

like image 70
Aleksandr Semyannikov Avatar answered Oct 25 '22 06:10

Aleksandr Semyannikov