NO-WAIT and WAIT???

yoachan

Member
Hi All!
Really need a hand here..

http://progress.solvepoint.com/2007/11/30/openedge-record-lock-anti-pattern/

It tells about making PROGRESS waited for 60 minutes for a record to be available (If another user locked it first).
Can anyone tells how to make it shorter? I only need to make PROGRESS waited for - let's say - 5 seconds.
If it's exceeded, then I must tell PROGRESS to stop waiting for the record to be available and tell user that the record is locked for an update.

Any help apreciated.

Best Regard

YoChan
 
Hi,

Why not use no-wait and the check if the record is locked by using the function locked <record>?

Code:
find <record> where <where-statement> no-error no-wait.
if locked(<record>) then do:
  pause 5.
  find <record> where <where-statement> no-error no-wait.
 
end.
if locked(<record>) then do:
  message '<record> is locked'.
end.
 
If you want to change the default lock wait timeout use the -lkwtmo startup parameter.

Or rethink your coding and use NO-WAIT and test for AVAILABLE and LOCKED and act appropriately.
 
Of course, the real key here is not so much the part of waiting for a short period as it is making sure that no one locks something for 60 minutes in the first place! If you do all your UI and extended calculations on local variables and temp-tables and then commit the transaction to the database in a tight block with no input blocking or other delays, then the only locks will last a fraction of a second.
 
@All
thank you for your replies. Really appreciate it :)


@sdjensen
I can't do that, for it will give my server extra load just to do the loop thousands time per second just to check whether the record is available or not... But I think I can I can set max iteration to stop the loop for keep on running.
Thank you.

@TomBascom
I think I should reconsider my code :)
And I'll consult my superintendent about using -lkwtmo startup parameter. We've never used it before.
Thank you.

@tamhas
I think I got the point. It will cause me extra work to do though, but it'll reduce my code's lock time; less chance for locking collision.
Thank you.
 
Try this

FIND FIRST area EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
IF NOT AVAILABLE area THEN DO:
IF LOCKED area THEN
MESSAGE "Registro Ocupado" VIEW-AS ALERT-BOX ERROR.
ELSE
MESSAGE "No existe" VIEW-AS ALERT-BOX ERROR.
END.
UPDATE area.

I use a table called area.
With this there are no wait if the record is in use, and I control the error.
 
Back
Top