FIX: Direct Update Gets 2 update_page LocksID: Q121060
|
When performing an update-in-place on a table with the row size padded out to one row per page, Microsoft SQL Server obtains an update_page lock on two different pages - one on the page actually being updated and the other on the next page in the page chain. The second page is never actually written to, but the update_page lock is held until the transaction is complete. This scenario is commonly used to create a sequence number table to generate row sequence numbers.
You can use any of the following options to avoid this problem:
Microsoft has confirmed this to be a problem in Microsoft SQL Server version 4.2. This problem was corrected in SQL Server version 6.0. For more information, contact your primary support provider.
The sp_lock output in the following script illustrates the problem:
CREATE TABLE keys(
key_name char ( 30 ) ,
key_value int,
filler0 char ( 255 ) ,
filler1 char ( 255 ) ,
filler2 char ( 255 ) ,
filler3 char ( 255 ) )
GO
CREATE UNIQUE CLUSTERED INDEX keys_pkey_idx ON keys ( key_name )
GO
insert into keys values ('a', 1, ' ' ,' ', ' ', ' ')
insert into keys values ('b', 1, ' ' ,' ', ' ', ' ')
insert into keys values ('c', 1, ' ' ,' ', ' ', ' ')
GO
BEGIN TRAN
SET SHOWPLAN ON
GO
UPDATE keys SET key_value = key_value + 1
WHERE key_name = 'b'
GO
SET SHOWPLAN OFF
GO
EXEC sp_lock
GO
ROLLBACK TRAN
GO
Additional query words: sql6 Windows NT
Keywords : kbprg SSrvLock SSrvTran_SQL kbbug4.20 kbfix6.00
Version : 4.2 6.0
Platform : WINDOWS
Issue type :
Last Reviewed: March 20, 1999