[Xapian-discuss] Flint Database 'Can't acquire write lock'?

Olly Betts olly at survex.com
Tue Apr 24 05:21:27 BST 2007


On Tue, Apr 24, 2007 at 12:58:47PM +0900, Josef Novak wrote:
> $ cat test.txt | ./simpleindex testdb
> Exception: Unable to acquire database write lock on testdb: locking
> probably not supported by this FS
> 
> I suppose this is not an incrediblyl helpful message

Actually, it is helpful - it tells me that fcntl() failed with errno set
to ENOLCK.  The Linux fcntl man page says:

    ENOLCK Too many segment locks open, lock table is full, or a
    remote locking protocol failed (e.g. locking over NFS).

So unless something else is doing a lot of locking, that strongly
suggests that you need to do something to get locking supported.

Alternatively, try to build the database locally rather than over NFS!

> so I also ran strace (by the way, thank you for introducing me to this
> incredibly useful program!):
> 
> execve("/bin/cat", ["cat", "test.txt"], [/* 57 vars */]) = 0
> uname({sys="Linux", node="lkr250006", ...}) = 0
> [...]

You seem to have sent the strace output for just `cat test.txt', but the
error message above tells me what the errno value was so the strace
output wouldn't help here anyway.

[
Although it does remind me what a lot of work /bin/cat can do just to
initialise!

We fork and obtain the lock in a child process because fcntl() has
rather unhelpful semantics - if a process opens the same file twice with
separate calls to open(), then it can get an exclusive lock on both fds.
So two threads could easily open the same database for writing.

Once the child process has the lock, it execs /bin/cat to avoid VM
overhead.  We want the lock to be released if the parent dies, and
the child has stdin connected to the parent so /bin/cat does the
job perfectly.  But we really should try using a trivial helper program
instead of /bin/cat here.
]

Cheers,
    Olly



More information about the Xapian-discuss mailing list