[Xapian-devel] about 'DatabaseModifiedError' and 'reopen'

Olly Betts olly at survex.com
Mon Nov 10 04:31:47 GMT 2014

On Fri, Oct 24, 2014 at 10:52:03AM +0800, 没有锂称 wrote:
> When I read the Database, there will appear 'DatabaseModifiedError' at
> sometimes. then I had to catch the 'DatabaseModifiedError', reopen the
> Database and repeat the last operation. But when the number of
> concurrent of the write is very high, the error
> 'DatabaseModifiedError' will often appear. So, it seems not a good
> idea to catch and reopen the Database. Is there another method to
> resolve the problem?

My suggestion would be to batch up your updates (or batch them up more
than you currently are).

It's inherently much more efficient to apply updates in batches, but in
particular it means that the time between commits will be greater, so
searches will get a chance to complete before the revision they are
reading gets yanked away from underneath them.

There's work in progress to allow readers to lock the revision being
read, which would allow you to avoid DatabaseModifiedError.  However,
batching up updates is still a generally a good idea.


More information about the Xapian-devel mailing list