tags:

views:

485

answers:

3

I'm getting a problem with only 1 of about 30 sites we run on a W2003 Web Server.

Probably for about 25% of the day, the website constantly returns : SQL Timeout Errors on various connections to SQL (using ODBC)

I have checked and updated the ODBC drivers to the latest that I could find (3.5.x?) and I am also checking the SQL server to see if that has problems (another server running on the same network connected via Gb LAN)

The IIS log files return "[Microsoft][ODBC_SQL_Server_Driver]Timeout_expired"

I experienced the problem this morning, so tried to reboot the SQL server to see if it was a load related problem or something - but the site continued to generate these errors for about 20 minutes after the reboot (even though all our other sites were working at this point) - then it stopped timing out and is now working again.

I tried to extend the Timeout of SQL connections for the website to see if this changed something, but it hasn't seem to have done a thing.

This site has been running for about 3 years continually with no problems and we haven't changed anything on our servers for some time now - this started happening around Christmas time, but has got more and more regular since.

I have been through all the code to make sure that DB Connections are being open/closed correctly (Site is classic ASP), and ensured that it's not opening too many concurrent connections - but all to no avail and I'm starting to run out of ideas.... anyone?

My only thought is to change to OLEDB connection instead of an ODBC - but before I do that, I wanted to check that there wasn't something else I've missed which I could try first.

Thanks in Advance!

Carl.

A: 

Does the SQL Server have a regular maintenance plan scheduled (and running), including rebuilding indexes?

Mitch Wheat
A: 

Since you haven't changed the code, there is nothing wrong with your connections.

Go find out why the SQL statements are taking so long. It's hard to say it any simpler. You may find you have a deadlock situation between your code that has not changed, and some other use of the database, which has changed. But you need to go track that down and not touch the working code that hasn't changed.

John Saunders
+1  A: 

You mention changing the timeout of SQL connections, but it's not clear what exactly is timing out: is it the connection to the database, or do the queries take too long?

One tool that might help is Sql Profiler. Limit it to the user or database that is experiencing the timouts. If query length is an issue, this should give you insight in exactly which queries are running long.

If the connection itself is timing out, check Current Activity in Management Studio. This shows the number of open connections; if they're large, there probably is a leak somewhere. You can test that in development by running with a connection string that contains:

MAX POOL SIZE=2;

This will cause leaks to quickly exhaust the connection pool.

Mitch Wheat's suggestion is very good, inaccurate statistics can really deteriorate performance over time. This query can tell you if your statistics are up to date:

SELECT 
    object_name = Object_Name(ind.object_id),
    IndexName = ind.name,
    StatisticsDate = STATS_DATE(ind.object_id, ind.index_id)
FROM SYS.INDEXES ind
order by STATS_DATE(ind.object_id, ind.index_id) desc
Andomar
I've since installed some software to monitor the Performance of SQL which has given me some interesting information - but I'm a bit at a loss as to how I can use it effectively.... My Seek Time Writes (Disk Wait Time, MS) seems to be taking between 60ms and 140ms - normal reports to be about 10-15ms. Also Cache Hits (Logical Reads/Physical Reads) seem to be very bad and Physical Reads (RW Per Sec) seems to be in the region of 150ms to 400ms.... What would that point to? Answer on a postcard....
Carl Crawley
You could look at the time an "execution batch" takes. If it's less than ten seconds, that's not giving a timeout to the web server. I'd investigate the number of simultaneous connections.
Andomar