Database left unlocked by Tcl bindings
Eric
eric at deptj.eu
Mon Feb 22 11:26:27 GMT 2016
On Sun, 21 Feb 2016 22:33:22 +0000, Olly Betts <olly at survex.com> wrote:
> On Sun, Feb 21, 2016 at 02:15:25PM +0100, Eric J wrote:
> > I discovered, while trying to set up Tcl bindings for Notmuch
> > (https://notmuchmail.org/), which uses Xapian, that flintlock was not
> > being locked (I had lost updates).
>
> It seems to work for me, testing with this:
>
> package require Tcl 8
> package require xapian 1.0.0
> xapian::WritableDatabase db "tmp.db" $xapian::DB_CREATE_OR_OPEN
> xapian::WritableDatabase db2 "tmp.db" $xapian::DB_CREATE_OR_OPEN
eric at bruno [ ~ ]$ cat /proc/version
Linux version 3.13.300 (root at bruno) (gcc version 4.8.2 (GCC) ) #2 SMP
Tue Sep 16 21:01:43 BST 2014
eric at bruno [ ~ ]$ tclsh
% info patchlevel
8.6.1
% package require Tcl 8
8.6.1
% package require xapian 1.0.0
1.2.18
% xapian::WritableDatabase db "tmp.db" $xapian::DB_CREATE_OR_OPEN
_e0c4b00000000000_p_Xapian__WritableDatabase
% xapian::WritableDatabase db2 "tmp.db" $xapian::DB_CREATE_OR_OPEN
_f0d3b00000000000_p_Xapian__WritableDatabase
%
At which point
eric at bruno [ ~ ]$ lsof tmp.db/flintlock
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
cat 13543 eric 5w REG 8,9 0 930437 tmp.db/flintlock
cat 13552 eric 9w REG 8,9 0 930437 tmp.db/flintlock
Blaming the execl is due to stepping though my copy of the lock code in
gdb, and seeing, in lsof, 5w on the open, still 5w on the fork, 5ww on
the fcntl, and 5w again on the execl.
> I wonder if the problem is unrelated to locking, but instead it's that
> the Tcl database doesn't get explicitly destroyed in your script, so
> that the C++ object doesn't either, and the changes don't get committed.
>
> I would try calling close() on the WritableDatabase object before your
> script exits.
I did have a close in my script, and then added a destroy. No way of
telling if it was first-to-close or last-to-close that was being lost.
> There's some discussion of this in the Tcl bindings docs (section
> "Destructors"):
>
> https://xapian.org/docs/bindings/tcl8/
Thanx,
Eric
--
ms fnd in a lbry
More information about the Xapian-discuss
mailing list