BUG: SERIALIZABLE Isolation Fails When Using Aggregate Functions

ID: Q198674


The information in this article applies to:

BUG #: 53786 (SQLBUG_70)

SYMPTOMS

SQL Server 7.0 Books Online documents 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE' as providing the ability prevent other users from performing data modifications when in a transaction.

A SELECT statement using an aggregate function (such as MIN, MAX, COUNT, AVG, and so on) will not maintain the correct range lock and allows modifications on secondary connections. Setting the transaction isolation level to serializable should maintain the range lock and prevent phantom INSERT, UPDATE, and DELETE operations.


RESOLUTION

A supported fix that corrects this problem is now available from Microsoft, but has not been fully regression tested and should be applied only to systems experiencing this specific problem. If you are not severely affected by this specific problem, Microsoft recommends that you wait for the next SQL Server service pack that contains this fix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:

http://support.microsoft.com/support/supportnet/default.asp

The English version of this fix should have the following file attributes or later:


   File name   Platform
   ---------------------

   S70631i.exe (x86)
   S70631a.exe (Alpha) 


NOTE: If you contact Microsoft to obtain this fix, a fee may be charged. This fee is refundable if it is determined that you only require the fix you requested. However, this fee is non-refundable if you request additional technical support, if your no-charge technical support period has expired, or if you are not eligible for standard no-charge technical support.

For additional information about eligibility for no-charge technical support, please see the following article in the Microsoft Knowledge Base:
Q154871 Determining If Your Product Is Eligible for No-Charge Technical Support


WORKAROUND

Before executing the aggregate select, perform a SELECT * statement from the table with the same conditions to force the appropriate locks to be held.


STATUS

Microsoft has confirmed this to be a problem in SQL Server version 7.0.


MORE INFORMATION

For clarity, the following is a sample that demonstrates the behavior.


-- Connection #1
use pubs
go
set transaction isolation level serializable
go
begin transaction
go

--
--  Should BLOCK the second connection but does not
select min(au_lname) from authors
go

-- Connection #2
use pubs
go
set transaction isolation level serializable
go
begin transaction
go
insert into authors (au_id, au_lname, au_fname, contract) values ('000-00-0000', 'aa', 'aa', 1)
go 
NOTE: The INSERT should be blocked, but it is allowed to complete. This allows a new row to be introduced in the range that did not exist during the original SELECT operation.

Additional query words: BOL SQLBOL


Keywords          : SSrvTran_SQL kbbug7.00 
Version           : winnt:7.0
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: April 16, 1999