Feedback
Did this article resolve your question/issue?

   

Article

How to trap condition thrown by Lock Wait Timeout (-lkwtmo)

Information

 
TitleHow to trap condition thrown by Lock Wait Timeout (-lkwtmo)
URL Name000045865
Article Number000139465
EnvironmentProduct: Progress
Version: 8.x, 9.x
Product: OpenEdge
Version: All Supported Versions
OS: All Supported Platforms
Other: Locking, ABL
Question/Problem Description
How to trap the STOP condition thrown by Lock Wait Timeout (-lkwtmo)

 
Steps to Reproduce
Clarifying Information
When a lock on a record is attempted, and it is found that the record is already locked, depending upon how the code was written the session may end up in a wait state that will last until the interval specified in the -lkwtmo parameter is satisfied.

After the -lkwtmo interval has elapsed, if the record is still locked by another user, the STOP condition is thrown within the program the lock was attempted.  This condition can stop further execution of the program in question, however it may be desirable for the process to continue executing.
 
Error MessageLock wait timeout of seconds expired (8812)
<file-name> in use by <user> on <tty>. Wait or choose CANCEL to stop. (2624)
Defect Number
Enhancement Number
Cause
Resolution
To avoid the STOP condition that is thrown ending program execution,

1.  Add an ON STOP condition to the block containing the failed record retrieval statement.

Example: Test for the STOP condition within the block where the lock is attempted
 
DO ON STOP UNDO, LEAVE:
  FIND FIRST <tablename> EXCLUSIVE-LOCK.
END.

MESSAGE "hi " AVAILABLE(<tablename>) 
VIEW-AS ALERT-BOX INFO BUTTONS OK.

2. Alternatively, use NO-WAIT with NO-ERROR and check if the record is locked until the lock is released: 

Example:
 
ETIME(TRUE). 

REPEAT: 
    FIND FIRST <tablename> EXCLUSIVE-LOCK NO-WAIT NO-ERROR. 
        IF NOT LOCKED <tablename> OR 
        ETIME GT 10000 /* 10000 milliseconds = 10 seconds */ THEN LEAVE. 
END. 

IF LOCKED <tablename> THEN DO: 
    MESSAGE "The record is locked" VIEW-AS ALERT-BOX. 
    LEAVE. 
END.

Since OpenEdge 11.7, the "-catchStop 1" feature can be used to CATCH a STOP condition. Refer to Article  How to use -catchStop to trap error 8812   
 
Workaround
Notes
Last Modified Date11/20/2020 7:09 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.