2.7 - Detection of a locked record has become quite slow

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am

2.7 - Detection of a locked record has become quite slow

Post by Karl-Heinz »

Robert / Chris

1. VO and X# share the same DBF+FPT.
2. VO locks a record.
3. X# tries to lock the same record, but suddenly it takes ~ 2 seconds to see the err msg

Code: Select all

IF ! SELF:server:RLock ( SELF:server:recno ) 
    ? "RLock() failed" 
ENDIF


4. I checked the lock tries settings:

VO:

Code: Select all

? LockTries() 	// default is 1


X#:

Code: Select all

? LockTries() // default is 10                 
? XSharp.RuntimeState.LockTries  // 10
But, no matter which value i try, i can´t change the X# behaviour. It always takes ~ 2 seconds to see the err msg. It seems that X# simply ignores this setting ?

Code: Select all

LockTries(1)  // has no affect 
LockTries(0xffffffff) // has no affect


BTW. There´s no such delay if X# tries a Flock() instead.

I installed 2.6 and the lock is detected again as fast as with VO. But i´ve noticed that this build also ignores the Locktries() setting. There´s no delay problem if VO tries to lock a record that´s already locked by X#. Because VO doesn´t ignore the Locktries() setting i´m even able to simulate the slow X# behaviour with the setting

Code: Select all

LockTries(1500000).


What has changed in the 2.7 build in this area ?

regards
Karl-Heinz
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

2.7 - Detection of a locked record has become quite slow

Post by Chris »

Hi Karl-Heinz,

Thanks, I see the problem! It can be reproduced with X# alone, the sample below takes zero time to run in VO and X# 2.6, but takes almost 2 seconds in 2.7:

Code: Select all

FUNCTION Start() AS VOID
LOCAL cDbf AS STRING
LOCAL n AS INT
cDbf := "c:testtestlock.dbf"
DbCreate(cDbf , {{"TESTFLD","N",10,0},{"TESTMEMO","M",10,0}} , "DBFCDX")
DbUseArea(TRUE,"DBFCDX",cDbf,,TRUE)
FOR n := 1 UPTO 10
	DbAppend()
NEXT
DbCloseArea()

DbUseArea(TRUE,"DBFCDX",cDbf,"old",TRUE)
DbGoto(5)
? RLock()

DbUseArea(TRUE,"DBFCDX",cDbf,"new",TRUE)
DbGoto(5)
LOCAL d := DateTime.Now AS DateTime
? "Trying a 2nd RLOCK() in the same record"
? "Result:", RLock()
? "Time passed:", (DateTime.Now - d):ToString()
DbCloseAll()
The change that was made had to do with how low level IO access is done in fpt files, I assume some error there caused those problems with fpt files. Will open a report for this and let's see what Robert finds out.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

2.7 - Detection of a locked record has become quite slow

Post by robert »

Guys,
I'll have a look tomorrow.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am

2.7 - Detection of a locked record has become quite slow

Post by Karl-Heinz »

Hi Chris,

I have modified your sample to demonstrate how LockTries() affects the duration of the second lock attempt. When you run the code with VO it takes 4 seconds. Try LockTries(3500000*2) and it lasts 8 seconds.

But if you run the code with X# 2.6 you should notice that the LockTries() setting is ignored !

Code: Select all

FUNCTION Start() AS VOID 
LOCAL cDbf AS STRING 
LOCAL fStart AS FLOAT
LOCAL n AS DWORD  
LOCAL oDB1, oDB2 AS DBServer

// X# seems to ignore the LockTries() setting ! 
LockTries(3500000)   // tries ~ 4 seconds to lock the already locked record
 
cDbf := "C:testthreadtest.dbf"
 
DbCreate(cDbf , {{"TESTFLD","N",10,0},{"TESTMEMO","M",10,0}} , "DBFCDX")
DbUseArea(TRUE,"DBFCDX",cDbf,,TRUE)
FOR n := 1 UPTO 10
	DbAppend() 
NEXT 
DbCloseAll() 

oDB1  := DbServer { cDbf , TRUE , FALSE , "DBFCDX" } 
oDB1:GoTo(5) 
fStart := Seconds()
? "Trying the first RLOCK()"
? "Result:", oDB1:RLOCK(oDB1:RECNO) 
? "Time passed:", Seconds() - fStart 
?
oDB2  := DbServer { cDbf ,  TRUE , FALSE , "DBFCDX" } 
oDB2:GoTo(5)           
fStart := Seconds()
 
? "Trying a 2nd RLOCK()"
? "Result:", oDB2:RLOCK(oDB2:RECNO)
? "Time passed:", Seconds() - fStart 
 
DbCloseAll()
   
wait
regards
Karl-Heinz
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

2.7 - Detection of a locked record has become quite slow

Post by robert »

Karl-Heinz,
LockTries is indeed ignore. I will fix that.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply