Article ID: 319345 - Last Review: September 27, 2005 - Revision: 5.1

FIX: Thread abort during SqlCommand.ExecuteReader corrupts SqlConnection pool

This article was previously published under Q319345
Expand all | Collapse all

SYMPTOMS

If the following conditions are true:
  • A long running query that uses the SqlClient.SqlCommand.ExecuteReader method in a multithreaded .NET application is aborted.
  • Threads thereafter use the same connection string to try to read data by using SqlClient.SqlCommand.ExecuteReader.
you receive the following error message:
System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first.
The call stack may appear as follows:
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean executing)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
					

CAUSE

When the thread that interacts with the DataReader object is aborted, the connection cannot be cleaned up properly because the SqlClient.SqlConnection.Close method that contains the cleanup code is not called. This leaves the connection in an indeterminate state and eventually causes the connection pool to enter an unusable state.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft .NET Framework. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
318836  (http://support.microsoft.com/kb/318836/ ) How to obtain the latest .NET Framework service pack
The English version of this fix should have the following file attributes or later:
   Date            Version                                 Size              File name     
   --------------------------------------------------------------------
   05-Mar-2002     1.0.3705.211    1,175,552 bytes   System.data.dll
   29-Jan-2002                                  1,831,936 bytes   NDP10U318609.msp
				

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft .NET Framework Service Pack 2 (SP2).

APPLIES TO
  • Microsoft ADO.NET 1.0
Keywords: 
kbhotfixserver kbqfe kbbug kbfix kbnetframe100presp2fix kbnetframe100sp2fix KB319345
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations