开发者

What happens if network is lost while rolling back transaction with TransactionScope in .Net

开发者 https://www.devze.com 2023-02-18 12:03 出处:网络
I have this following code:- using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required))

I have this following code:-

 using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required))
        {
            bool IsCreated=false;
            context.CommandTimeout = 120;
            if(IsCreated)
              transactionScope.Complete();                             
        }

Now If transactionScope.Complete() is not called, Transaction is rolled back once scope of using is Complete. However IF before this there is a network outage, how will this transaction be rolled back. It is rolled back as i tried removing the network cable but i dont understand how is it getting rolled back. According to my开发者_开发技巧 understanding if Transaction is not commited within the commandtimeout it is rolled back by sql server. Please validate.


The CommandTimeout only impacts commands issued - not the overall transaction. DTC has a timeout (also available via some constructor overloads), but that is mainly intended for distributed deadlock scenarios.

In this scenario, I suspect it is more a case that the controller is keeping tabs on all the systems involved, and reporting failure if any of them fail to respond / keep in touch.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号