It appears that file locking between LetoDBf and other applications is not working.
I can *not* reproduce error, seem specific to your environment,
as my "shrd" is a Linux executable run at server and i notice a drive-letter in example: Samba ?
//letodb.iniShare_Tables = 1
1 --> use 'real' *record* locks viewable to other applications
and also respect record locks set by other
( else the record locks are 'virtual' [ internal list with record numbers ] )
Database driver must be also the same, given by:
"Default_Driver" in 'letodb.ini' ( LetoDBf application can change its default )
LetoDB[f] server default: CDX versus Harbour default: NTX
--> shrd.prg example will use DBFNTX
( NTX locking != CDX; see harbour/docs/locks.txt )
Lastly LetoDBf can even utilize extended "Lock_Scheme" for huge database
( leave expert option out if not needed )
All above relates to *record* locking.
-----
# verify file is really the same ;-)
# use same database driver as used by server
# check for locks, maybe for SMB with:
smbstatus -L
and for LetoDBf server with lsof ?:
lsof /data/comp/compk/bkstat.dbf
( http://www.linuxask.com/questions/how-to-check-if-a-file-is-locked-in-linux )
# Samba have options about locking/ oplocks ...
# verify file is really the same ;-)
# use same database driver as used by server
# check for locks, maybe for SMB with:
smbstatus -L
and for LetoDBf server with lsof ?:
# Samba have options about locking/ oplocks ...
# smbstatus -L
Pid Uid DenyMode Access R/W Oplock SharePath Name Time
26768 0 DENY_ALL 0x12019f RDWR NONE /volume1/bms comp/compk/bkstat.dbf Mon Jul 3 08:07:00 2017
DENY_ALL is what we want in example -- but its not set at server.
# lsof /data/comp/compk/bkstat.dbfCOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEletodb 11617 root 226uW REG 253,0 1091 52809 /data/comp/compk/bkstat.dbfsmbd 26768 root 33u REG 253,0 1091 52809 /data/comp/compk/bkstat.dbf
We see for letodb an upper 'W" ( in FD FileDescriptor ) == exclusive opened.
( would be 'R' if opened in shared mode )
But there is *none* for smbd ( Samba ) --> IMO cause of problems.
Now to configure Samba ( i do that rarely ):
[ if an option is not set, version dependent default value is active ]
oplocks = no
level2 oplocks = no
share modes = yes
locking = yes
strict locking = no
more ? ...
Problem should be independent of LetoDB[f] !?,
and should relate to just a DBF EXCLUSIVE opened one time over Samba,
other time local at Linux server.
So just two instances of your 'shrd.prg' with two different paths,
one time as linux app to run at server ... -- can you confirm ?
I'm curious about where the problem was, please let me know.
Could it be because LetoDBf is running in chroot environment?
sure no 'chroot', that means IMHO something very different ...
LetoDBf open the databases just with Harbour engine [ hb_rddOpenTable() ],
beforehand 'magically' ;-) calculates the absolute path,
so my conclusion in last post was that reported problem relates to any DBF opened by Harbour directly at server
best regards
Rolf
//shrd2.prg
PROCEDURE main( )
LOCAL cText := TIME()
USE z:\comp\compk\bkstat EXCLUSIVE NEW
IF NetErr()
cText += " bkstat open FAIL"
ELSE
cText += " bkstat open EXCL"
ENDIF
//MEMOWRIT( "/var/log/letodb/result.txt", cText )
? cText
RETURN
-- snip --
then start firstly your Windows shrd.exe from first post
--> should go into browse.
Then start above at machine with LetoDBf:
correct would be an open fail ...
best regards
Rolf
can you please compile following for your Linux server (NAS)
-- snip --
//shrd2.prg
PROCEDURE main( )
LOCAL cText := TIME()
USE /data/comp/compk/bkstat.dbf EXCLUSIVE NEW
then start firstly your Windows shrd.exe from first post
--> should go into browse.
Then start above at machine with LetoDBf:
correct would be an open fail ...
Still having this issue.
#1:
avoid logic relying on <exclusive>,
ever open <shared> in local App and in Samba App, then FLock() ...
This will not prevent from critical moments, when <exclusive> logic is needed/
implemented.
i like to make wonders, but can not do miracle :-)
I'll be testing #1(b) in the next few days. Is it possible to show lock information for each table in LetoDBf Console?
I found the <record> locks. Thanks.
Consider the following: ...
I found the <record> locks. Thanks.Consider the following:Open an application and lock customer 899. 899 is displayed in the red box. Leave the application open.Open the same application again and lock record 1010. 1010 is not displayed in the red box. Leave the application open.Close the first instance of the application. 1010 is now displayed in the red box.
..
# need a second directory place for second LetoDBf,
as it else would read the others letodb.ini, adapt the port!
/etc/letodb.ini
[Main]
DataPath = /data/comp
LogPath = /var/log/letodb
EnableFileFunc = 1
EnableUDF = 1
HardCommit
= 1
TimeOut = -1
No_Save_WA = 1
Share_Tables
= 1
/dev/vg1000/lv /volume1 ext4 usrjquota=...
samba.conf[global]printcap name=cupswinbind enum groups=yesinclude=/var/tmp/nginx/smb.netbios.aliases.conf
...
...
grep -q "${CHROOTTARGET}/dev/pts " /proc/mounts || mount -o bind /dev/pts ${CHROOTTARGET}/dev/pts
[ ! -d ${CHROOTTARGET}/data ] && mkdir -p ${CHROOTTARGET}/data
grep -q "${CHROOTTARGET}/volume1/bms " /proc/mounts || mount -o bind /volume1/bms ${CHROOTTARGET}/data
chroot ${CHROOTTARGET}/ /usr/local/bin/letodb start
...
${INSTALL_DIR}/app/stop.pychroot ${CHROOTTARGET}/ /usr/local/bin/letodb stop
sudo mount -t cifs -o guest //localhost/data /mnt/samba
mount.cifs
--> something help text ?
NAS was angry. Had to recover.
...apt-get install cifs-utils
before ? - or afterwards ? - below command ?
There are two places where OS appears to be installed://volume1/@appstore/debian-chroot/var/chroottarget/
The second one being in chroot jail. etc/samba folder appears in both places. As shares are only defined in NAS OS /etc/samba folder, I am assuming that /jail/etc/samba folder is not being used. This is where I got lost.
root@bmsprod:/# mount -t cifs -o guest //localhost/bms /mnt/sambamount error(95): Operation not supportedRefer to the mount.cifs(8) manual page (e.g. man mount.cifs)root@bmsprod:/#
If i google for this: 'mount error(95)'
countercheck with monitor that excl file is opened at excl server:2914
...
01.15.2018 06:15:01 INFO: LetoDBf Server 3.00, will run at port :2812 ( internal also used :2813 )01.15.2018 06:15:01 INFO: DataPath=/data/comp, ShareTables=1, NoSaveWA=1, max database=999
...
01.15.2018 06:15:01 INFO: LetoDBf Server 3.00, will run at port :2814 ( internal also used :2815 )01.15.2018 06:15:01 INFO: DataPath=/mnt/samba, ShareTables=1, NoSaveWA=1, max database=999
Application ends with the following error when it tries to open company.dbf in exclusive mode.Subsystem Call ....: LETO
System Code .......: 1021Description .......: Open error
...
01.15.2018 06:15:01 INFO: LetoDBf Server 3.00, will run at port :2814 ( internal also used :2815 )01.15.2018 06:15:01 INFO: DataPath=/mnt/samba, ShareTables=1, NoSaveWA=1, max database=999
i bet!, that your DBFs are not in that path, but in:
/mnt/samba/comp
I changed the DataPath to /mnt/samba/comp but still it did work.
...
Error LETO/1021 Open Error: comp/sysdata
...USE 'comp/sysdata' NEW
#outcomment both! to burn LetoDBf address for exclusive usage
-cflag="-DLETO_SMBSERVER=bmsprod"...
IF leto_Connect( "//192.168.2.200:2814/" ) < 0
bmsprod = 192.168.2.200 in my setup here.
However, I tried with //bmsprod:2814 and still get the same error.
letodbf_01.log01.16 10:36:15.633 +01.16 10:35:26.789 << open: (len 40)01.16 10:35:26.789 O;sysdata;SYSDATA;TF;;DBFCDX;1;mm/dd/yy;01.16 10:35:26.789 DEBUG leto_InitArea( connect:2, area:1, alias:SYSDATA, not detached:1 -- request:SYSDATA)
01.16 10:35:26.789 +1;0;.cdx;.fpt;2;3;64;3;2458009;14;........
in line 3487/3489 you find a #ifdef/ #endif pair.Comment out these both lines with // at front -- recompile library + snippet.
Leto_Connect( "//bmsprod:2812/" ) --> 1
Leto_Connect( "//bmsprod:2814/" ) --> 0
/etc/fstab# about ,iocharset=utf8 i am a bit unsure, but sound not bad
Hello Ash,
to prove my hypothesis,
you move line 3488 [ leto_clientlog(...) ] in source/client/letocl.c
below the following 5 lines, aka after 3495, but before the bracket '}'.
Then you won't get a 'flt.log' in case the server is not 'found'.If you get a flt.log ( my assumption ), there must action at :2814with error feedback in letodbf_xx.log after changing debug level.
best regards
Rolf
Hello Ash,just caught myself ;-)Please use IP-address for LETO_SMBSERVER in rddletoaddon.hbpand for leto_connect()I will start thinking if and how we can use DNS name ...best regardsRolf
Hello Ash,
? that was a filename containing a Win drive letter ?
Please revert change and check against newest upload.
[ old logic could be also tricked out by: X:/path\test /o\ ]
Let me know if bug! is not fixed.
With newest upload you should be able to use a DNS name [ 'bmsprod' ]
for LETO_SMBSERVER in the hbp.
You then also can LetoConnect() to an IP, now it should be the equal.
Please test ...
best regards
Rolf
Hello Ash,you mean the RTE instead of a 'silent' NetErr() ?:i overlooked, that 'shared error' was set for the switched connection,and the calling function doesn't know about.The good news: now you can *not* open a table exclusive,which is already opened shared.or exclusive.But not vice versa:you anytime can open a table shared, even SMBSERVER have it opened exclusive.This is what i would expect -- i announced respect of each others exclusive.best regardsRolf
Hello Ash,
Last two tests run OK.New Test - Run flt.exe and fltn.exe. Both can browse the table at the same time. Not good.
please show me in that moment:smbstatus -L---I may need to do more, needs a bit time. I'm just testing following:exclusive -> redirect connection to exclusive servershared -> open table at both server, to prevent Samba app from getting exclusive accessThis complicates enormous :-( -- lets see how far i get.best regardsRolf
and from within chroot jail.
root@bmsprod:/# smbstatus -LNo locked files
My application appears to behave in the same manner as it did before the introduction of port 2814.
# no side can open <exclusive>, if the other side have opend at least <shared> ?
Port 2814 no longer in use.
... the same behaviour - LetoDBf and Samba can open the same table in EXCLUSIVE mode at the same time.
Hello Ash,why did you change this:;letobms.ini[Main]this line not neededDataPath = /volume1/bms/comp/mnt/samba/comp!!!Our entry in /etc/fstab is still there !! ?best regardsRolf
Hello Ash,we had all fine setup-ed, with an entry to mount samba in /etc/fstab in /mnt/samba,correct letosmb.ini ....:-(best regardsRolf