在SQL中什么是默认的最大事务超时

Bon*_*arp 9 .net sql sql-server timeout transactions

maxTimeout如果machine.config上没有"system.transactions"元素,则machine.config中的默认值是什么(参见示例)?

<system.transactions>
   <machineSettings maxTimeout="??:??:??" />
</system.transactions>
Run Code Online (Sandbox Code Playgroud)

我问这个是因为代码因以下异常而崩溃,似乎它与超时超时的事务有关,它在SaveChanges方法期间崩溃,我收到的异常如下:

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.
Run Code Online (Sandbox Code Playgroud)

这是崩溃的代码片段:

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();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这就是我创建的方式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);
}
Run Code Online (Sandbox Code Playgroud)

gbn*_*gbn 16

默认= 10分钟.最大= 无限


iai*_*ain 8

服务器端没有超时是MS SQL.

始终是客户端在设置的持续时间后抛出异常.

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

你真的想看看命令超时.

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

此处的默认值为30秒.