voith

I've been running some load testing on a BizTalk application we are about to deploy and noticed that the perfmon counter NumberOfReclaimedConnections grows continuously in the app domain where we use the BizTalkOperations class.

The code below can be used to reproduce the effect:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.BizTalk.Operations;
using System.Collections;
using System.Threading;

namespace BTTester
{
class Program
{
static void Main(string[] args)
{
while (true)
{
BizTalkOperations btOps = new BizTalkOperations();

Thread.Sleep(3000);

IEnumerable enumerable = btOps.GetServiceInstances();

foreach (Instance msg in enumerable)
{
Console.WriteLine(msg.InstanceStatus);
}
}
}
}
}

After a little inspection with reflector, it looks like there is one assembly that manages all the sql connections for the management API:

Microsoft.BizTalk.DBAccessor

In it, there is a class (Microsoft.BizTalk.Database.DatabaseAccessor) that returns a sqldatareader to calling methods (i.e., the methods originated from a call to methods from Microsoft.BizTalk.Operations.BizTalkOperations).

It looks like one of 2 is missing:

1) The callers of Microsoft.BizTalk.DBAccessor.ExecuteReader should close/dispose the sql connection when they are done with their sqldatareader object.

2) The code within Microsoft.BizTalk.DBAccessor.ExecuteReader should call the overloaded version of System.Data.SqlClient.SqlCommand.ExecuteReader that takes a CommandBehaviour enumeration and pass in the CommandBehaviour.CloseConnection value.

I have not installed BizTalk 2006 R2, so this issue may be fixed in that update.

Any thoughts