Iain, connection leaks occur because the session is not properly
disposed/closed. The current pattern I have been using with no
problems is
ISession session = OpenSessio();
try
{
using(var ts = new TransactionScope())
{
...
ts.Complete();
}
}
finally { session.Dispose(); }
On Apr 15, 12:48 am, Iain <[email protected]> wrote:
> Hi All,
>
> I am having a connection leak when we using the ambient transaction,
> and the transaction is aborted. That is, I get the exception:
> System.InvalidOperationException: Timeout expired. The timeout period
> elapsed prior to obtaining a connection from the pool. This may have
> occurred because all pooled connections were in use and max pool size
> was reached.
>
> I am guessing something is holding onto a reference to the connection,
> or an internal part of the connection. As adding a watch to following
> and debug breaking within the transaction also causes this issue.
> ((System.Data.SqlClient.SqlInternalConnectionTds)
> ((System.Data.SqlClient.SqlConnection)
> (session.Connection))._innerConnection)._connectionPool.Count
>
> Is this a known issue or unsupported? Currently our workaround is to
> promote the transaction to a distributed transaction which seems to
> work ok, as per this
> article:http://davybrion.com/blog/2010/03/msdtc-woes-with-nservicebus-and-nhi...
>
> Here is the unit test that re-produces the issue:
>
> [Test]
> public void CanUseSystemTransactionsToAbort()
> {
> for (var i = 0; i < 200; i++)
> {
> using (ISession session = sessions.OpenSession())
> using (TransactionScope tx = new
> TransactionScope(TransactionScopeOption.RequiresNew))
> {
> W s = new W();
> session.Save(s);
> session.Flush();
> }
> }
>
> }
>
> Cheers,
>
> Iain
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.