|  | Posted by Erland Sommarskog on 07/14/05 01:33 
New MSSQL DBA (boscong88@gmail.com) writes:> Hi all, met with something very scary and want to confirm if anyone
 > else have met this possible bug with EM?
 >
 > Got a production DB, say DB_A with quite a few users in it. this day,
 > when I look into the EM-->management-->Current Activity-->Locks/Object,
 > I saw a lot of locking on some objects belonging to a user, say User_A
 > but the problem is, this User_A doesn't own a thing in DB_A!! And even
 > if I drop this user from DB_A, the EM GUI still showing there are quite
 > a locks on objects owned by User_A.
 
 Mike is plain wrong when he say there this not a bug in Enterprise Manager.
 There is a bug, and I have known about for a long time. In difference to
 you, I didn't run into it this way - I found it by looking at the code.
 
 Here is the relevant part from sp_MSset_current_activity (a procedure
 that exists only for Enterprise Manager):
 
 select @stmt ='update ' + @locktab + ' set [Table] = name,
 [ObjOwner] = user_name(uid) from ' + quotename(@lckdb, '[') +
 '.[dbo].[sysobjects] where id = ' +
 convert(nvarchar(10), @lckobjid) + ' and [Database] = ''' + @lckdb
 + ''' and [ObjID] = ' + convert(nvarchar(10), @lckobjid)
 exec (@stmt)
 
 The context is that the procedure have first found all processes and locks
 and saves these in a temp table. Then it iterates over all locked objects
 to translate the names in a look. The bug is the part
 
 user_name(uid)
 
 user_name() works in the current database, but here we examine some
 other database. the programmer should have joined with
 @lckdb + '.dbo.sysusers' instead.
 
 
 --
 Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
 
 Books Online for SQL Server SP3 at
 http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
  Navigation: [Reply to this message] |