KB4517771 - FIX: Orphaned CLR sessions cause blocking in SQL Server

Applies to: SQL Server 2016 DeveloperSQL Server 2016 EnterpriseSQL Server 2016 Enterprise Core

Symptoms


Assume that you use a session that calls a common language runtime (CLR) stored procedure (a "calling session") to access data in Microsoft SQL Server, and that procedure in turn establishes a separate connection (a "second session") to the same server instead of a Context Connection. Then, if the calling session is terminated because of a time-out or cancelation, the second session may become orphaned, and will exist in the system until it is manually terminated by using the KILL command. If that orphaned session holds any locks, other sessions may be blocked waiting for the locks to be released.

Status


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

Resolution


This issue is fixed in the following cumulative updates for SQL Server:
About cumulative updates for SQL Server:
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server
Note By default, the fix is turned off because of the need forpreserving the legacy behavior of CLR threading in SQL Server. You only need to turn it on if your system exhibits the symptoms mentioned earlier. To enable the fix, you need to add the trace flag 6559 to server by using Database Engine Service Startup Options. Remember that this trace flag can be used only together with SQL Server startup options. It cannot be set by using the DBCC TRACEON command.

References


Learn about the terminology that Microsoft uses to describe software updates.