CLR Question

  • We have a production CLR process that queries Active Directory for User Information and loads it into a table. We had 2 jobs that collided and ended up with blocking and hung jobs accessing the table. In an attempt to stop and restart the process I killed the job, however the process would not rollback as I believe the CLR thread still had a lock on the table. The process was in a rollback state and never moving(this is a small transaction with no more than 100 or so rows)

    I know this is not an ideal situation, but was curious for opinions on how to get rid of the lock on the table:

    My understanding is you can use the kpid from the sysprocesses table and map to a process on the server, and kill it there, but you run a likely risk of crashing SQL Server completely.

    I was thinking the most likely way to clear the process is to restart the SQL Service, however this would have been a large impact to the other databases on the instance.

    My thought and what I was looking for feedback on was switching the clr enabled function from 1 to 0 and then back to 1. My thought was this would unload the assemblies and kill the process. There was minimal impact as we only have a few databases using CLR assemblies compared to restarting the entire service.

    Thanks for the feedback

    Erich

  • I would probably bounce the instance but I can understand you not wanting to impact the other databases on the instance. If you have success with changing the 'enabled' flag please post back, it may help someone else down the line.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Thanks for your feedback! I did have success changing clr_enabled from 1 to 0 and then back 0 to 1. After turning it off, it unloaded the assemblies from memory which is what I think freed up the spid that was trying to rollback.

  • Good deal, happy you got it sorted. Thanks for posting back.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply