FIX: Interleaving Prepare And Adhoc Execute of Query May Cause Recompile Loop

Article translations Article translations
Article ID: 267953 - View products that this article applies to.
This article was previously published under Q267953
BUG #: 236625 (SHILOH_BUGS)
BUG #: 58063 (SQLBUG_70)
Expand all | Collapse all

On This Page

SYMPTOMS

If one connection prepares a query but never runs the query, while a second connection is running the same query ad hoc, SQL Server might begin to recompile the query infinitely. More and more memory is used as the recompile continues, CPU utilization is high, and the server might become very sluggish. You may eventually encounter the following 17803 error messages in the SQL Server errorlog as memory is depleted:
2000-06-14 17:09:21.31 ods Error: 17803, Severity: 17, State: 14
2000-06-14 17:09:21.31 ods Insufficient memory available..
Generally, you must re-start SQL Server to recover from this situation.

RESOLUTION

SQL Server 2000

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

Hotfix

NOTE: The following hotfix was created prior to Microsoft SQL Server 2000 Service Pack 1.

The English version of this fix should have the following file attributes or later:
   Version     File name     Platform
   -----------------------------------
   8.00.217    s80217i.exe   x86
NOTE: Due to file dependencies, the most recent hotfix or feature that contains the above files may also contain additional files.

SQL Server 7.0

To resolve this problem, obtain the latest service pack for SQL Server 7.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
301511 INF: How to Obtain the Latest SQL Server 7.0 Service Pack

WORKAROUND

To work around this problem:
  • Execute the prepared query at least once.

    -or-

  • Consistently have all the connections submit the query ad hoc or prepared.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

SQL Server 2000

This problem was first corrected in SQL Server 2000 Service Pack 1.

SQL Server 7.0

This problem was first corrected in SQL Server 7.0 Service Pack 3.

MORE INFORMATION

A prepare of a query can be performed in OLE DB or ODBC by calling ICommandPrepare::Prepare or SQLPrepare, respectively. This is typically done when the same query is to be run many different times. You run the prepared query by calling ICommand::Execute or SQLExecute.

It might be possible to run DBCC FREEPROCCACHE to flush the plans from the cache. If you can do this, then that is sufficient to stop the recompile loop and the server stabilizes.

You can detect this problem by watching the following Performance Monitor counters:

SQL Server:Cache Manager - Cache Use Counts/sec for Adhoc Sql Plans
SQL Server: SQL Statistics - SQL Recompilations/sec
SQL Server: SQL Statistics - Batch Requests/sec
SQL Server: SQL Statistics - Compilations/sec

The first two counters jump to a very high value (generally 50000 or higher on a multi-processor computer), while the last two counters drop to nearly zero, even if there are queries being sent to the server from other connections.

You do not have to have a multi-processor computer to encounter this problem, but the problem does happen more quickly in a multi-processor computer environment.

Properties

Article ID: 267953 - Last Review: October 31, 2003 - Revision: 3.1
APPLIES TO
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 7.0 Standard Edition
Keywords: 
kbbug kbfix kbsqlserv2000sp1fix KB267953

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com