dead records in locking.tdb (was: Locking database cleanup?)

Steve Williams steve at
Sat May 20 05:28:50 GMT 2006

Daniel Coletti wrote:
> Hi,
> 	I'm having a problem that's been addressed (last month) in this
> list[0], since I read the post from the list's archives I can't reply
> this particular email, so excuse me for breaking the thread.
> [0]
> In this discussion -about dead records in the locking.tdb file- Jeremy
> kindly responded ...
> ``As part of the validation
> process when reading a record containing open and locking info,
> we validate the pid associated with that record by sending it
> a zero signal. If we get an ESRCH (no such process) error back
> we delete the record.
> So long as pid's don't wrap this should be robust.
> ´´

I thought I would point out that this approach fails miserably on 
OpenBSD (and other OS's??), which has "randomized" PID's.  This has 
bitten myself on multiple occasions, and I believe it even affected 
Sendmail.  I just thought I'd point this out, that relying on the 
historical "PID's always increment" premise eventually bites one in the 
posterior, in a random, very hard to predict/troubleshoot way! 

In this case, the log files might reflect the process died, but the KILL 
signal finds a process.. how could that be?  It was someone's shell that 
logged in afterwards, and by coincidence got the same PID as the process 
that terminated abnormally.

Just a heads up..

Steve Williams

> Now, I'm running samba 3.0.14a-3sarge, and using samba as a file server
> for different version of Ms Windows executing a FOXPRO legacy
> application (the smb.conf is down below).
> If I execute a FOX rlock() to get a lock of a specific record in a DBF
> file, I can see that the locking record gets added correctly in the
> locking.tdb file. While having this record locked I hard reseted the
> Windows PC.
> What I see next is that the smbd instance lives for a few seconds and as
> the Windows PC comes back on, this particular smbd instance dies but the
> record in the locking.tdb file still exists ... avoiding the same or any
> new Windows PC to get a lock of this DBF.
> My questions are:
> 	1- Is this validation process that Jeremy mentioned has been added (or
> fixed) in a later samba release from 3.0.14a-3?
> 	2- Is there any way to delete the locking.tdb record from file using
> tdbtool? Would release the non-existing lock? (eventhough I see a
> "delete" action in the tdbtool help I can't establish the correct key of
> this record using tdbdump)
> My problem is that I can't afford restarting samba, which cleans the
> locking.tdb dead record.
> Thanks a lot!
> my smb.conf file:
> [global]
>         workgroup = XTECH
>         realm = XTECH.LOCAL
>         security = ADS
>         auth methods = winbind
>         password server = tcwad01.XTECH.local
>         idmap uid = 1000-30000
>         idmap gid = 1000-30000
>         template homedir = /vhome/%D/%U
>         template shell = /bin/bash
>         winbind separator = +
>         winbind use default domain = Yes
>         winbind enum users = no
>         lock spin time = 30
>         lock spin count = 200
>         smb ports = 139
>         socket options = TCP_NODELAY SO_SNDBUF=65536 SO_RCVBUF=65536
> [datosf]
>         oplocks = no
>         level2 oplocks = no
>         inherit permissions = Yes
>         writable = yes
>         delete readonly = yes
>         path = /home/datosf
>         force directory mode = 0777
>         veto oplock files =
> /*.dbf/*.DBF/*.cdx/*.CDX/*.db/*.DB/*.lck/*.LCK/*.EXE/*.exe/*.fxp/*.FXP/*.idx/*.IDX/
>         force create mode = 0777
>         comment = tmp Datos F
>         create mode = 0777
>         level2 oplocks = No
>         directory mode = 0777
> daniel//

More information about the samba-technical mailing list