D
deja
hi,
I am trying to use TransactionScope and multiple async calls but get
Transaction aborted - transaction in doubt errors.
My program goes like this
using (TransactionScope ts = new TransactionScope())
{
do an insert on Table1 (Connection1 = new SqlConnection)
foreach table to read from aList
{
doSyncRead using Connection1
}
foreach table to insert from bList
{
do AsyncInsert passing in
DependentTransaction(BlockCommitUntilComplete) using new
SqlConnection(same connection string as Connection1)
}
Wait for all Inserts to Complete (using WaitHandle.WaitAll)
do a couple more inserts using Connection1
ts.Complete()
}
Each AsyncInsert create their own TransactionScopes using the
dependent transaction and call complete when finished.
Using Profiler I can see it gets to the TM Commit and seems to bail
out at this stage. But if I change the AsyncInserts to Synchronous
Inserts it works fine. All the inserts seem to complete - it is only
at the Commit stage that it fails with TransactionInDoubt.
The TransactionScope is in a web service. The error gets returned to
the client but then there still seems to be a TM REQUEST Command on
the SQL Server which then blocks other database requests until I
restart the DTC.
Can anyone tell me what I'm doing wrong? Is there another service I
need to enable or something?
thanks
Phil
BTW I also get a Promote Tran on Connection1 (seen via Profiler) -
starts and completes.
I am trying to use TransactionScope and multiple async calls but get
Transaction aborted - transaction in doubt errors.
My program goes like this
using (TransactionScope ts = new TransactionScope())
{
do an insert on Table1 (Connection1 = new SqlConnection)
foreach table to read from aList
{
doSyncRead using Connection1
}
foreach table to insert from bList
{
do AsyncInsert passing in
DependentTransaction(BlockCommitUntilComplete) using new
SqlConnection(same connection string as Connection1)
}
Wait for all Inserts to Complete (using WaitHandle.WaitAll)
do a couple more inserts using Connection1
ts.Complete()
}
Each AsyncInsert create their own TransactionScopes using the
dependent transaction and call complete when finished.
Using Profiler I can see it gets to the TM Commit and seems to bail
out at this stage. But if I change the AsyncInserts to Synchronous
Inserts it works fine. All the inserts seem to complete - it is only
at the Commit stage that it fails with TransactionInDoubt.
The TransactionScope is in a web service. The error gets returned to
the client but then there still seems to be a TM REQUEST Command on
the SQL Server which then blocks other database requests until I
restart the DTC.
Can anyone tell me what I'm doing wrong? Is there another service I
need to enable or something?
thanks
Phil
BTW I also get a Promote Tran on Connection1 (seen via Profiler) -
starts and completes.