MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

Timeoutinseconds is in transactionalattributes of 4.6.5 but it was not in 3.6.5. So what is the defaulted value of timeoutinseconds now, as my application is showing timeout error now. Does it differs from the previous version. #671

Open ramanbansalfis opened 5 years ago

ramanbansalfis commented 5 years ago

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.

rockfordlhotka commented 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.

ramanbansalfis commented 5 years ago

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

ajj7060 commented 5 years ago

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.

rockfordlhotka commented 5 years ago

I do think we should follow Microsoft's lead. Feel free to submit a PR.