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

1

6

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

Jade answered 21/11, 2018 at 23:10 Comment(3)
But those are no isolation levels. Its rather what to do when there is/ there is no transaction at some particular point. Also I would say that since nested transaction are in scope of "parent" transaction, thus they share common scope. Never tested that.Dionysian
I always have in mind a Transactional method calling another Transactional method. So theres always a context of transaction. I expect even when both transactions had read_commited by default there was special rules of visibility of the changes but I dont find it in the documntationJade
read committed the default one almost at all databases with fewer exceptions, nested propagation type is not large supported btwWyckoff
B
2

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.

Bombay answered 27/11, 2018 at 6:19 Comment(1)
I appreciate the answer but I am not sure is focusing exactly on what I am asking, which is isolation beyond the Isolation.types. Maybe the edit makes it more clearJade

© 2022 - 2024 — McMap. All rights reserved.