[Xapian-discuss] Re: Trying to use db.reopen()

Olly Betts olly at survex.com
Sat Jan 14 03:49:20 GMT 2006


On Sat, Jan 14, 2006 at 11:26:03AM +0800, Fabrice Colin wrote:
> Olly Betts <olly at survex.com>:
> > This whole situation will go away when I finish implementing the new
> > flint backend.  There a reader will be able to signal that it's using a
> > particular B-tree revision, and the writer will then know not to discard
> > that revision until the reader has finished using it.
>
> Does this mean it will be safe to have N readers and 1 writer accessing the
> index concurrently without extra locking ?

Yes.  The plan is that the writer will attempt to exclusively lock a
revision prior to discarding it.  If the attempt fails (which will
happen if a reader has a non-exclusive lock on that revision), it won't
discard that revision yet.  And multiple readers can non-exclusive lock
the same revision.

I suspect the writer will actually just discard revisions lower than the
first locked one.  I've only got a rough sketch of how the free block
tracking will probably work, but it looks like that might be necessary.
It also avoids the writer having to do O(#readers) work checking locked
revisions in the worst case.

Note that N readers and 1 writer is safe at the moment too (well, except
for the annoyances of DatabaseModifiedError, but that's the case with 1
reader and 1 writer too).  Your question could be read as suggesting it
isn't, so I just thought I'd clarify...

Cheers,
    Olly



More information about the Xapian-discuss mailing list