In SQL What is the default maximum transaction interval

What is the default value in machine.config for maxTimeout (see example) if there is no "system.transactions" element in the machine.config file?

 <system.transactions> <machineSettings maxTimeout="??:??:??" /> </system.transactions> 

I ask this because the code crashes due to the following exception and it seems to be associated with a transaction that exceeds the timeout, it crashes during the SaveChanges method, and the exception that I get is the following

 The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements. 

This is a piece of code that crashes:

 using (TransactionScope transaction = TransactionHelper.CreateTransactionScope()) { using (EFContext efDBContext = new EFContext()) { try { efDBContext.Connection.Open(); foreach (MyEntity currentEntity in myEntities) { //Insertion } transaction.Complete(); } catch (Exception ex) { //Inspect current entity //Get Total Time of the run //Number of entities processed } finally { if (esfDBContext.Connection.State == ConnectionState.Open) esfDBContext.Connection.Close(); } } } 

This is how I create a TransactionScope :

 public static TransactionScope CreateTransactionScope(TransactionScopeOption option = TransactionScopeOption.Required, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted) { var transactionOptions = new TransactionOptions() { Timeout = TimeSpan.MaxValue, IsolationLevel = isolationLevel }; return new TransactionScope(option, transactionOptions); } 
+6
source share
2 answers

Default = 10 minutes. Max = Infinity

+13
source

No time on the server side - this is MS SQL.

The client always throws an exception after the specified duration.

http://blogs.msdn.com/b/khen1234/archive/2005/10/20/483015.aspx

Are you sure you want to see the timeout of the team.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx

The default value is 30 seconds.

+6
source

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


All Articles