Enlisting in distributed transaction raises COM error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a webservice that uses an ADO.NET application. MSDTC is used to
manage the distributed transactions. When I open and close the database
multiple times within one single distributed transaction, then the 11th time
fails when the database is closed. I receive the
System.Runtime.InteropServices.COMException exception with HRESULT=0x80040201
and the message "An event was unable to invoke any of the subscribers".

After some investigation and discussions I found out that the SqlClient
tries to Advise to the distributed transaction's connection point when it
closes the connection. This is probably required to be informed about the
verdict of the distributed transaction. The connection point is hard-coded to
allow up to 10 connections (MSDTC limitation). I uses the normal connection
string, so connection pooling is enabled.

I guess this is a bug in the SqlClient. The same connection is used and it
is not I have created a sample application to reproduce the bug. It fails on
all environments that I have tested (Win2000 SP4, WinXP SP2 and Win2K3). All
have .NET Framework v1.1 SP1 installed and connect to a SQL Server 2000 SP3a
database.

Does anyone have more information about this problem? I am looking for a
fix, but PSS cannot help me without a KB article. I searched everywhere, but
I cannot find any information about this problem. I can send the sample
application that reproduces the problem on request.

Greetings,
Ramon de Klein
 
Hi,

If you're opening and closing the connection we should be re-using it if
pooling is enabled. Are you always using the same connection string? Same NT
user identity?

--
Pablo Castro
Program Manager - ADO.NET Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hello,
If you're opening and closing the connection we should be re-using it if
pooling is enabled. Are you always using the same connection string? Same NT
user identity?

I use the same connection string. The sample program looks like this:

ITransaction transaction = GetNewTransaction();
for (int loop=0; loop<15; ++loop)
{
SqlConnection sqlConnection = new SqlConnection("Integrated
Security=true");
sqlConnection.Open();
sqlConnection.EnlistDistributedTransaction(transaction);
sqlConnection.Dispose();
}
transaction.Commit(0,0,0);

The 'GetNewTransaction()' method is a method that returns a distributed
transaction managed by MSDTC.

I used the .NET Reflector to find out the internals. When the connection is
disposed, it calls its Close method. The Close method calls 'Advise' on the
DTC transaction internally to be informed about the transaction outcome. It
does this each time the connection is closed and MSDTC only allows 10
connection points to be connected. The 11th time fails. I guess that it
shouldn't register to the same transaction again if it was already registered
before. That would definitely fix the problem.

I have contacted Microsoft PSS to resolve this issue. We are using an
application that uses MSDTC and webservices. The webservice is called
multiple times within the transaction, so we really need to open the database
multiple times (or we should implement connection pooling ourselves).

I also got a response of one of your collegues, that is working on the .NET
managed providers, that is looking into this matter. I called PSS to be able
to get a fix for this (when available). If you're interested in the sample
program that demonstrates this issue, then I can send it to you (complete
solution file).
 
Back
Top