Sunday, March 11, 2012

Active connections

Does anybody know an easy way to check how many connections are being made to the database? I'm getting the following error
An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll

Additional information: A connection pooling error has occurred.

and find it hard to believe that there are no connections left in the pool.

I've checked in Enterprise Manager and the maxmimum number of process running under the user account used to access the DB from code is 2. Strangely the error seems to occur when I explicitly close the connection.

thanks
SimonHi Simon,

You could run sp_monitor from Query Anylizer to find out.

EXEC sp_monitor

It will tell you how many connections since the last start and how many are present.

:)

JB|||Make sure you're closing all of you connections on all of your pages. Here are a few perf counters to look at:
\\bob\.NET CLR Data(_global_)\SqlClient: Current # connection pools
\\bob\.NET CLR Data(_global_)\SqlClient: Current # pooled and nonpooled connections
\\bob\.NET CLR Data(_global_)\SqlClient: Current # pooled connections|||OK, looks like something weird to me.

When I run in debug mode my number of pooled connections:

1. Goes up by 4 when clean starting ... i.e. Application_Start fires.
2. Goes up by 2 when normal start.
3. Does not go up when navigating from page to page.

When I run in 'normal' mode the number of pooled connections:

1. Goes up by 2 when clean starting ... i.e. Application_Start fires.
2. Does not go up when normal start.
3. Does not go up when navigating from page to page.

It never seems to decrease though.

What is going on??

Simon|||pooled connections will not be terminated from the database server's perspective until the connection inactivity timeout is reached on the pooled connections.

So under normal circumstances, you wont see the number of connections decrease unless your app sits still for a while.

No comments:

Post a Comment