-
Notifications
You must be signed in to change notification settings - Fork 877
Open
Labels
Milestone
Description
Summary:
Transaction does not rollback if scope timeout has elapsed.
Detailed description:
Consider the following sample. We declare the TransactionScope with scopeTimeOut.
When execute command and the time is over as specified in scopeTimeout. The transaction aborts but the command does not rollback.
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 0, 5)))
{
using (conn1)
{
conn.Open();
NpgsqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "update test_ts set c2='sssss' where c1=1";
cmd.ExecuteNonQuery(); // the update operation is expected to rollback
System.Threading.Thread.Sleep(6000);
}
scope.Complete();
}Following is the error message and stack trace.
[Error Message]
The transaction has aborted.
[StackTrace]
at System.Transactions.TransactionStateAborted.BeginCommit(InternalTransactio
n tx, Boolean asyncCommit, AsyncCallback asyncCallback, Object asyncState)
at System.Transactions.CommittableTransaction.Commit()
at System.Transactions.TransactionScope.InternalDispose()
at System.Transactions.TransactionScope.Dispose()
Following is the patch to fix the above mentioned issue.
https://gist.github.com/smmansoor/d5cd7067bdb6a6d25183#file-transactionscope_timeout_invalid-patch
Reactions are currently unavailable