CLR TVFs Are Not Gracefully Handled During AppDomain Recycles - by Adam Machanic

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 765930 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 10/3/2012 8:41:29 AM
Access Restriction Public


When an AppDomain recycle occurs, most CLR module types are able to gracefully handle the situation: in-flight requests continue on the old AppDomain, new requests go to the new AppDomain, and eventually when all of the old requests are complete the old AppDomain is disposed of. This creates a more reliable and robust environment and keeps end-users from seeing exceptions when the server needs to do some housecleaning.

Unfortunately, this graceful handling is not done for TVFs. If a table-valued function is running and a recycle occurs, the function will immediately be aborted. Even worse, it will send the user a confusing and very misleading exception:

Msg 10316, Level 16, State 1, Line 2
The app domain with specified version id (4) was unloaded due to memory pressure and could not be found.

CLR TVFs are, in my experience, both the most useful -- by far -- of the available SQLCLR module types, and are probably also the most frequently used. Putting such functionality into a less robust, less reliable bucket is a major disservice to SQL Server developers and end users of SQL Server based solutions.
Sign in to post a comment.
Posted by Microsoft on 2/27/2013 at 12:57 PM
Hello Adam,
Thanks for reporting the issue. We looked at this and behavior has existed in previous versions of SQL Server. And given the other high priority requests in our pipeline, fixing this issue is not a priority for us at the moment. I understand the pain and hopefully we can look at it in the future if our business priorities change.

Umachandar, SQL Programmability Team