PRB: Locks and Timeouts

Last reviewed: April 25, 1997
Article ID: Q47603

The information in this article applies to:

  - Microsoft SQL Server version 4.2 for OS/2
  - Microsoft SQL Server version 4.2

SYMPTOMS

SQL Server does not notify an application when a nondeadlocking lock collision occurs with another application. Since the other application could hold the lock for a long time, there should be some way for an interactive application to regain control and do something else. The same is also true for queries that take a long time to process.

WORKAROUND

Rather than sending the command via dbsqlexec(), use dbsqlsend(). Then use dbdataready() repeatedly to determine when results have begun to arrive. If too much time has elapsed, issue dbcancel() to abort the current command. If results have arrived, issue dbsqlok() and if the command was successful, enter the normal dbresults()\dbnextrow() loop.

This technique allows the application to regain control before results have begun to arrive and also between calls to dbresults() and dbnextrow(). Once a call to dbresults() or dbnextrow() has been issued, the only way for the application to regain control is via a timeout.

Unfortunately, the dbproc() is marked DEAD when timeout occurs. Although it may be possible to clear the DEAD flag and continue processing, the prescribed technique is to reopen the dbproc().

In either case, there is no way to determine whether the timeout is due to a lock collision or just a long-running query.


Additional query words: Optimization and tuning Windows NT dblib
Keywords : kbprg SSrvDB_Lib SSrvServer SSrvWinNT
Version : 4.2 | 4.2
Platform : OS/2 WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 25, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.