Re: Resource Accumulation on SQLServer

From: Erland Sommarskog (sommar_at_algonet.se)
Date: 02/15/04


Date: Sun, 15 Feb 2004 22:36:16 +0000 (UTC)


[posted and mailed, please reply in news]

Gary Whitten (whitteng@con2inc.com) writes:
> We have a JDBC project that works with SQLServer, along with other
> DBs. During development, we noticed that resource useage on SQLServer
> seemed to grow steadily - Processes, Process Locks and/or Object Locks,
> according to the "Current Activity" section of Enterprise Manager.
> Fairly quickly (a few hours), SQLServer would use so many resources it
> used up all available system memory and the system would crash.

Hm, what do you mean with "crashes"? If you exhaust some resource, I
would rather expect SQL Server kill a connection, or refuse to let
someone in, but I would not expect it to crash.

One thing I should point out from the beginning: the fact that SQL Server
grabs about all available memory on the machine is perfectly normal. It
thinks that the more data it can have in cache, the better.

That said, if the number of locks accumulate, then you might have a problem.

> Without understanding much about why that was happening, mostly out of
> trial and error, we started using transactions, which seemed to fix the
> problem. Now, one of our customers seems to be seeing the problem again:
>
> 511 Process Locks, 18 Object Locks, 526 Processes

I don't know what a "process lock" is, but I get the feeling that you've
been running the Performance Monitor; I never run that tool myself. I
would guess it is a lock on the current database, which about every
process has. Thus, nothing to lose sleep over.

18 object locks is not very much at all. It seems like an idle database.

So is 526 connections bad or not? I can't tell, because I don't know
your application. But assuming that you expect a far lower number, you
may need to review how you close connections. (But since I don't know
JDBC or Java, I can tell about the client-side parts here.) The connections
may just be oprhans. Sampsa suggested that you may not close result sets,
but if you had failed to get all data, I would expect a lot more object
locks.

A shot from the hip, is that you should look into to issue SET NOCOUNT
ON when you open your connections. If you are using stored procedures,
but that in your SPs. Without SET NOCOUNT ON, you get empty resultsets
with the row count for INSERT/DELETE/UPDATE statements; these could be
the culprits.

-- 
Erland Sommarskog, SQL Server MVP, sommar@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp


Relevant Pages

  • Performance Monitor locking counter
    ... I have a Performance Monitor counter set up with the idea of monitoring ... SQLServer: Locks ...
    (microsoft.public.sqlserver.tools)
  • Resource Accumulation on SQLServer
    ... we noticed that resource useage on SQLServer ... seemed to grow steadily - Processes, Process Locks and/or Object Locks, ... 511 Process Locks, 18 Object Locks, 526 Processes ...
    (comp.lang.java.databases)
  • Re: Locking behavior involving table joins
    ... The SELECT would be quering old date and issuing shared row locks. ... If your JOIN is an all with no condition clause, you could still query all ... all of the other connections to complete their work before starting. ... > I have a connection that performs a join on TableA and TableB. ...
    (microsoft.public.sqlserver.server)
  • RE: ASPSTATE issues
    ... The application used sqlserver connections to a certain ... Are you using the SQLServer as the ASP.NET web application's Session ... here are some tech articles on server process monitor and ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: DAO, Transactions, SQLServer
    ... dbSQLPassThrough in all my queries, I was getting rid of Jet, but not ... With this option I no longer get outstanding connections, ... > I have a problem with DAO, Transactions and SQLServer. ... > are opened (by the driver I believe) and I suspect that the driver sends ...
    (microsoft.public.sqlserver.connect)