[Xapian-discuss] Threaded test (in C++) to reproduce our database problems

Olly Betts olly@survex.com
Thu, 17 Jun 2004 14:29:29 +0100


On Thu, Jun 17, 2004 at 08:42:12AM -0400, Eric Ridge wrote:
> Hopefully, CVS HEAD will fix this, but as another data-point:  The
> test (poorly written as it is) also fails on our test Gentoo system,
> which is a dual processor hyperthreaded Xeon, running the 2.6.6 Linux
> kernel.  So it ain't just my Mac.

Apparently the "4 processor" box I was using is actually dual processor
hyperthreaded too.

> As an aside, is it necessary to compile Xapian with -pthread or
> -lpthread or -D_REENTRANT or -D_THREAD_SAFE or something?  My thinking
> is no, but I'm just a novice when it comes to pthreads.

Well, I didn't.  Xapian itself doesn't look for _REENTRANT or
_THREAD_SAFE, though it's possible the STL headers or some other
library does.

A quick poke in /usr/include suggests the only likely issue might be
errno which uses a per-thread version if _LIBC_REENTRANT is defined (but
nothing seems to define that).

Ah, and that probably explains the odd syscall interrupted error I saw -
the other thread had probably overwritten errno in the small window
between the syscall (read/pread/write/pwrite) and the if statement which
checks errno.

And it might also explain the whole problem.  If EINTR is overwritten 
by some other error value at the wrong moment, reading or writing a
block might incorrectly be thought to have failed.  CVS HEAD changes
the quartz backend to stop it doing a full close and reopen of all
the btree tables on flush(), which probably makes it a lot less likely
to encounter this situation.

So try configuring 0.8.0 with:

./configure CPPFLAGS=-D_LIBC_REENTRANT

I'll give this a whirl too.

Cheers,
    Olly