FIX: Error 3307 with NOLOCK Joins in a Cursor Declaration

ID: Q181514


The information in this article applies to:

BUG #: 17798 (WINDOWS: 6.5)

SYMPTOMS

A cursor declaration containing a NOLOCK optimizer hint within the scope of a transaction, and running under stressful conditions on a multiprocessor computer may generate error 3307 when a rollback command is issued:

Error : 3307, Severity: 21, State: 1
Process 12 was expected to hold logical lock on page 416.
WARNING: Process being freed while holding Dataserver semaphore
The following is an example of an sp_cursoropen call:

   exec sp_cursoropen    @cursor=@ch output,

            @stmt="select * from pubs.dbo.authors(NOLOCK),
            pubs.dbo.sales(NOLOCK), pubs.dbo.titles(NOLOCK)",
            @scrollopt=1, @ccopt=4, @rows=@rc output 


CAUSE

SQL Server suppressed duplicate key violations. When the user connection issued the rollback statement, some of the pages involved in the NOLOCK operation where still considered part of the transaction scope. The rollback attempt then encounters the error 3307 because it does not have a valid lock on the page.


WORKAROUND

To work around this problem, remove the NOLOCK optimizer hint.


STATUS

Microsoft has confirmed this to be a problem in SQL Server version 6.5. This problem has been corrected in U.S. Service Pack 5a for Microsoft SQL Server version 6.5. For information about downloading and installing the latest SQL Server Service Pack, see http://support.microsoft.com/support/sql/.

For more information, contact your primary support provider.


MORE INFORMATION

Other errors that have been encountered as part of the NOLOCK cursor usage are:

Additional query words: db err log prodsql


Keywords          : SSrvErr_Log SSrvGen kbbug6.50 kbfix6.50.SP5 
Version           : winnt:6.5
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: April 21, 1999