Katmai bug: SSMS doesn’t drop database locks when leaving the context of a database


I came across an interesting bug in Management Studio in the latest Katmai CTP today – when a connection disconnects from a database, SSMS doesn’t release the shared database lock that it holds. This prevents any operations that need exclusive database access (like a RESTORE) and can be somewhat disconcerting if you don’t realize what’s going on. Try executing the following in SSMS in the November CTP:



USE master;
GO


CREATE DATABASE MySSMSTest;
GO


USE MySSMSTest;
GO


CREATE TABLE test (c1 INT);
GO


USE master;
GO


DROP DATABASE MySSMSTest;
GO


And you’ll see:



Msg 3702, Level 16, State 4, Line 1
Cannot drop database “MySSMSTest” because it is currently in use.


It works perfectly in SQLCMD in the same CTP, and also in SQL Server 2005. You can work around this by doing something like:



ALTER DATABASE MySSMSTest SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE;


GO


Not exactly ideal – but, hey, it’s only a CTP. This has already been reported in Connect as issue 320135 – I added a workaround.


I’ll post any further bugs that I find here as well as making sure they’re on Connect.

Leave a Reply

Your email address will not be published. Required fields are marked *

Other articles

Imagine feeling confident enough to handle whatever your database throws at you.

With training and consulting from SQLskills, you’ll be able to solve big problems, elevate your team’s capacity, and take control of your data career.