Why is System.Transactions TransactionScope default Isolationlevel Serializable

后端 未结 3 1261
我在风中等你
我在风中等你 2020-11-28 22:22

I am just wondering what a good reason to use Serializable as the default Isolationlevel may be when creating a System.Transactions TransactionScope

3条回答
  •  离开以前
    2020-11-28 23:04

    Well, I guess this is one of those "only the designer would definitely know" type of questions. But here are my two cents anyhow:

    While Serializable is the most "limiting" isolation level (concerning locking, in a lock-based RDBMS, and thus concurrent access, deadlocks, etc.) it is also the most "safe" isolation level (concerning consistency of data).

    So while requiring extra work in scenarios like yours (been there done that ;-), it make sense to opt for the safest variant by default. SQL Server (T/SQL) chooses to use READ COMMITTED, obviously applying other reasons :-)

    Making it changeable by configuration, would then be a bad idea, because by fiddling with configuration you could render a perfectly working application to a broken one (because it might simply not be designed to work with anything else). Or to turn the argument around, by "hardcoding" the isolation level, you can make sure that your application works as expected. Arguably, the isolation level is not a good fit for a configuration option (while the transaction timeout indeed is).

提交回复
热议问题