Symptoms
Consider the following scenario:
-
You run an ALTER INDEX … ONLINE query in Microsoft SQL Server 2012 or SQL Server 2014.
-
This query is aborted either because of a deadlock or a user-initiated action, such as running a kill command or canceling the query.
In this scenario, any DML operations that have to use index metadata either are blocked or take a long time to be completed.
Additionally, you may experience the following symptoms:-
Elevated values for the PWAIT_MD_RELATION_CACHE or MD_LAZYCACHE_RWLOCK wait type when you query the sys.dm_os_wait_stats and sys.dm_exec_requests dynamic management views (DMV)
-
Elevated values for SOS_RW wait type when you query the sys.dm_os_spinlock_stats DMV
This problem is usually observed as a lock convoy that occurs when every new DML query slowly clears the synchronization objects. Because of the waiting nature of the synchronization objects, the CPU usage is usually limited.
Resolution
Cumulative update information
The issue was first fixed in the following cumulative update of SQL Server.
Cumulative Update 1 for SQL Server 2014 /en-us/help/2931693
Cumulative Update 9 for SQL Server 2012 SP1 /en-us/help/2931078
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:
Hotfix information
A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. If the hotfix is available for download, there is a "Hotfix Download Available" section at the top of this Knowledge Base article. If this section does not appear, submit a request to Microsoft Customer Service and Support to obtain the hotfix. Note If additional problems occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and problems that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft website:http://support.microsoft.com/contactus/?ws=supportNote The "Hotfix Download Available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language. Important After you apply this hotfix, the ALTER INDEX … ONLINE query can be aborted without decreasing the performance of SQL Server.
Workaround
To work around this problem, you can flush the metadata entry to prevent the lock convoy and potential recompile cycles that decrease query performance. To do this, use one of the following methods to help flush the metadata entry:
-
Restart the instance of SQL Server 2012 or SQL Server 2014.
-
Put the problematic database into offline state, and then bring it online again.
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.