FIX: TCP port is not closed when you use System.Data.SqlClient to connect to a database that has database mirroring configured and a failover occurs

Consider the following scenario:

  • You configure database mirroring between two instances of Microsoft SQL Server.

    Note One instance is the principal server instance that contains the principal database, and the other instance is the mirror server instance that contains the mirror database.

  • You run a Microsoft .NET Framework 2.0–based application that uses the .NET Framework Data Provider for SQL Server (System.Data.SqlClient) to connect to the principle database from a client computer.

  • A TCP port is used to establish a connection to the principal server instance from the client computer.

  • You specify the failover partner in the connection string.

    For example, you use the following code to configure the connection string:

    Data Source=<principal server instance>;Failover Partner=<mirror server instance>;Initial 
    Catalog=<database name>;Integrated Security=True;Network Library=dbmssocn
  • You perform a failover operation from the principal server instance to the mirror server instance.

In this scenario, the TCP port that is used to establish connection for the principal server instance on the client computer is not closed. Therefore, a new TCP port is used to establish a connection for the mirror server instance on the client computer.

Additionally, the TCP port for the principle server instance is set to the CLOSE_WAIT state on the client computer, and the corresponding TCP port is set to the FIN_WAIT_2 state on the principal server. If failover operations occur many times, all the ports of the client computer may be unavailable.

Note To check active connections, open a command prompt, type the following command, and the press Enter:

NetStat -n

Symptoms

The issue occurs because the .NET Framework Data Provider for SQL Server does not close the connection correctly after a failover occurs.

Note The connection can be released only by garbage collection.

Cause

Hotfix information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

To resolve this problem immediately, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft website:

http://support.microsoft.com/contactus/?ws=supportNote In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Prerequisites

To apply this hotfix, you must have the Microsoft .NET Framework 3.5.1 installed on a computer that is running one of the following operating systems:

  • Windows 7

  • Windows Server 2008 R2


Restart requirement

You do not have to restart the computer after you apply this hotfix.

Hotfix replacement information

This hotfix does not replace a previously released hotfix.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

For all supported x86-based versions of Windows 7



File name

File version

File size

Date

Time

Platform

System.data.dll

2.0.50727.5664

2,927,616

15-Apr-2011

22:32

x86

For all supported x64-based versions of Windows 7 and of Windows Server 2008 R2

File name

File version

File size

Date

Time

Platform

System.data.dll

2.0.50727.5664

3,096,064

15-Apr-2011

22:28

x64

System.data.dll

2.0.50727.5664

2,927,616

15-Apr-2011

22:32

x86

For all supported IA-64–based versions of Windows Server 2008 R2

File name

File version

File size

Date

Time

Platform

System.data.dll

2.0.50727.5664

3,234,816

15-Apr-2011

22:23

IA-64

System.data.dll

2.0.50727.5664

2,927,616

15-Apr-2011

22:32

x86

Resolution

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Status

For more information about TCP connection states and Netstat output, click the following article number to view the article in the Microsoft Knowledge Base:

137984 TCP Connection States and Netstat OutputFor more information about how to use database mirroring, visit the following MSDN website:

How to use database mirroringFor more information about how to make the initial connection to a database mirroring session, visit the following MSDN website:

How to make the initial connection to a database mirroring session

References

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×