Open ramanbansalfis opened 5 years ago
Before we added the ability to override the default, the default is whatever Microsoft was using as a default. It was the "default default" 😄
I don't know what Microsoft's default value was, but I'm sure you can find it via Google.
Hi Rockford, I was previously using version 3.6.5 in which I was using TransactionalAttribute as: [Transactional(TransactionalTypes.TransactionScope)] This calls TransactionScope tr = new TransactionScope() of Microsoft which sets Timeout parameter. I checked with Microsoft default value for timeout which was 10 minutes
Now I upgraded my application to 4.6.5 version.
Then application started crashing on some transactions. On checking the CSLA code for 4.6.5, I can see that now TransactionalAttribute set internally default values for 'TransactionIsolationLevel', and 'TimeoutInSeconds'.
The default value set by CSLA code for TimeoutInSeconds is 30 seconds. (since I am not setting this value in any config file)
See the code below in source\csla.shared\ApplicationContext.cs of version 4.6.5
public static int DefaultTransactionTimeoutInSeconds
{
get
{
var tmp = ConfigurationManager.AppSettings["CslaDefaultTransactionTimeoutInSeconds"];
return string.IsNullOrEmpty(tmp) ? 30 : int.Parse(tmp);
}
}
Now CSLA further pass these value to TransactionalScope class with this 30 seconds value in Timeout param See code in csla.shared\server\transactionaldataportal.cs: private TransactionScope CreateTransactionScope() { return new TransactionScope(TransactionScopeOption.Required, GetTransactionOptions()); }
private TransactionOptions GetTransactionOptions()
{
var option = new TransactionOptions
{
IsolationLevel = GetIsolaionLevel(_transactionalAttribute.TransactionIsolationLevel),
Timeout = TimeSpan.FromSeconds(_transactionalAttribute.TimeoutInSeconds)
};
return option;
}
Hence this 30 seconds timeout value was aborting my transaction i.e. application.
When I made this to 600 sec by passing as: [Transactional(TransactionalTypes.TransactionScope, TransactionIsolationLevel.Unspecified, 600)] It worked fine.
Why you have defaulted it to 30 seconds in 4.6.5, and why not same as what Microsoft does in TransactionalScope() i.e. 10 minutes
I can't comment on if the change in Csla was intentional or not, or why 30 seconds was picked, but a ten minute transaction timeout seems pretty unreasonable for a default. You'd normally want transactions to be as quick as possible as they are locking records and probably blocking other queries from reading the locked rows.
I do think we should follow Microsoft's lead. Feel free to submit a PR.
Question Your question goes here.
Version and Platform CSLA version: 4.7.100 OS: Windows, Linux, iOS, Android, etc. Platform: WinForms, WPF, ASP.NET Core, MVC, Xamarin, etc.