[Xapian-discuss] how can i search and add document at same time

David P. Novakovic davidnovakovic at gmail.com
Wed Sep 9 10:35:07 BST 2009


The second handle will fail reads sometimes with a corrupt database error...
I've spoken to olly about it.. i think the general concensus was that two of
the files in the index may be at different revisions when the search is
performed.

This is why I was thinking it may be good to lock for read access while
there is a document being inserted into the index, it would be a lot more
effective (and probably faster) than managing our own locking mechanism.

One of the benefits of xapian over other engines is being about to
incrementally add to the index and continue to read from it without having
to do a complete rebuild. but with this file revision problem it kinda
negates that benefit because you can't guarantee that the read will be
sucessful. I suppose you could keep trying until it succeeds.. not optimal
though.

David

On Wed, Sep 9, 2009 at 7:25 PM, James Aylett <james-xapian at tartarus.org>wrote:

> On Wed, Sep 09, 2009 at 05:06:15PM +0800, ouwind wrote:
>
> > sorry. i mean i has two threads, one thread is adding document to
> > the xapian database. another threads is searching the database.both
> > use m_indexdb.(Xapian::WritableDatabase* m_indexdb;). so it will
> > have exception
>
> Right. Well, the second thread could open a read-only handle to the
> database; you can't share Xapian objects between threads in general
> (noted in <http://xapian.org/docs/overview.html>). You could manage
> shared access yourself as an alternative.
>
> Which makes sense in your case will depend on your application.
>
> J
>
> --
>  James Aylett
>
>  talktorex.co.uk - xapian.org - uncertaintydivision.org
>
> _______________________________________________
> Xapian-discuss mailing list
> Xapian-discuss at lists.xapian.org
> http://lists.xapian.org/mailman/listinfo/xapian-discuss
>


More information about the Xapian-discuss mailing list