[Xapian-discuss] DatabaseModifiedError on get_data - best practice?

Olly Betts olly at survex.com
Thu Mar 8 00:57:21 GMT 2012


On Fri, Feb 17, 2012 at 12:54:36PM +0000, Andrew Betts wrote:
> I have previously had a problem with getting this error on a get_mset
> call, and solved it by subclassing XapianEnquire with a
> backoff-and-retry algorithm (as suggested by this list, many thanks!).
>  However, I now get it intermittently when calling get_data on a
> XapianDocument.  The same solution doesn't seem to be quite as easy in
> this case, because:
> 
> 1. The document is not instantiated by my code, it's returned from the
> Iterator, so I can't easily subclass it without editing the bindings.

Also, subclassing Xapian classes which aren't intended to be subclassed
means that your additions will be ignored if you pass an object of the
subclass to Xapian.  I don't think anything takes an Enquire object, so
that's actually OK (at least currently), but for Xapian::Document it's
an issue.

I'd probably recommend wrapping by making the Xapian object a member
rather than a base class, to make it more obvious what will happen.
But wrapping isn't the answer here (if it was, the job the wrapper
does could be done in the Xapian library).

> So, first is it necessary to reopen the database in these situations,
> or could I simply call get_data on the same document object after a
> brief delay?

The data you wanted has been overwritten, and retrying won't magically
recover it.  You need to reopen the database and start again.

> C) Add retry at the application level (need to add to several dozen
> projects!)

This is the way to do it, at least until we track which older versions
are still in use.

Cheers,
    Olly



More information about the Xapian-discuss mailing list