Lock errro

This forum is for eXpress++ general support.
Post Reply
Message
Author
omni
Posts: 531
Joined: Thu Jan 28, 2010 9:34 am

Lock errro

#1 Post by omni »

Roger,

We have a stand-alone exe that runs on one of users server (win2003). No client server.

This process downloads data (mobile locations, messages,etc) from a web site 24/7. The files that are updated are fairly large, 50,000-500,00 records. Never a problem on these files. About 30-50 times daily there are special routines to update other files which are very small. One is driving us crazy. 130 records, its driver hours used the prior day. When the messages come in, we open the file, find the driver record, lock it, update, unlock it and close it. There is a lock error almost every day on one of these, even though the lock routine is successful. Just says lock is required for this operation and the exe locks up. The user is getting very upset at this as the exe stops running until they cancel and restart it.
This is our record locking routine..used now for 8 years. There is no alert message, so the lock had to be successful.

FUNCTION OISRCLCK
LOCAL XLOCK
XLOCK=.F.
DO WHILE .NOT. ( XLOCK := RLOCK() )
n := DC_GuiAlert(,"Unable to lock record #" + LTRIM(STR(RECNO())) + IF(EOF()," (EOF) ","") + " of " + ;
IF( !EMPTY(ALIAS()),UPPER(ALIAS())," Work Area #" + LTRIM(STR(SELECT())) ) + ". ;" + ;
"Procedure " + UPPER(PROCNAME(0)) + " -- line " + LTRIM(STR(PROCLINE(0),5)) + ";" + ;
"Procedure " + UPPER(PROCNAME(1)) + " -- line " + LTRIM(STR(PROCLINE(1),5)) + ";" + ;
" " ,{ "Retry", "Quit" } ,14,"Error Warning",,,{"9.Arial Bold","9.Arial Bold" })
if n=2
return .f.
else
loop
endif

ENDDO
RETURN .t.


Any recommendations?

Thanks

Fred Henck
omni

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Lock errro

#2 Post by Tom »

Hi, Fred.

This condition is never true:

DO WHILE .NOT. ( XLOCK := RLOCK() )

xLock := RLock() means xLock becomes RLock(). This happens anyway, even if RLock returns false. This should be correct:

DO WHILE .NOT. ( XLOCK = RLOCK() )

Your app worked so far by mistake: This (a failing lock) simply never happend until now. ;)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Lock errro

#3 Post by skiman »

Tom wrote: This condition is never true:
DO WHILE .NOT. ( XLOCK := RLOCK() )
If the rlock is succesfull it return .T., this way xlock also becomes equal to .T..

Just wondering why the xlock var is used.
'Do while !rlock()' would be a shorter notice.

With this locking system, there is a dc_guialert each time there is a lock error. Sometimes a second try after a sleep(10) could be succesfull, and everything would work without any problem.

Code: Select all

nCounter := 0
do while !rlock()
    if nCounter > 5    // after 5 tries give the alert
        n := dc_guialert....
        if n = ....
             exit
        endif
    else                // wait and retry
         nCounter ++
         sleep(10)
   endif
enddo
Best regards,

Chris.
www.aboservice.be

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Lock errro

#4 Post by Tom »

@Chris: Damned, you're right! :shock:
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Lock errro

#5 Post by skiman »

Tom,

There were two options: :think:
1. Someone else had used your account.
2. You had on Tuesday evening a hell of a party.

Because I'm convinced you are using this type of notation yourself in your application.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Lock errro

#6 Post by rdonnay »

Good eye, Tom.

I would have assumed that there was nothing wrong with the lock routine if he had been using it for years.
My first guess was that the record was getting unlocked somewhere in the code.
The eXpress train is coming - and it has more cars.

Post Reply