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:

Check It Out!

SQLskills Blackbelt Bundle and 2022 Updates - 1 Year Access

Original price was: $2,495.00.Current price is: $990.00.

View Course


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.

Posted Under:

Leave a Reply

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

Other articles

Summer Sale: $699 Blackbelt Bundle!

Summer Sale time! Hundreds of dollars lower-than-ever prices on our signature 158-hour Blackbelt training bundle: Check It Out! SQLskills Complete Short Course Bundle $4,575.00 Original

Explore

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.