[Xapian-discuss] Re: 1.0 news, and a call for testing
Fabrice Colin
fabrice.colin at gmail.com
Mon May 7 14:31:19 BST 2007
On 5/6/07, Richard Boulton <richard at lemurconsulting.com> wrote:
> Richard Boulton wrote:
> > The lock file shouldn't be removed, because flint uses higher level
> > file-locking, rather than just testing for the presence of the lock
> > file. The lock on it should be released, though, when the Writable
> > database fails to be opened, so the overwrite step should work.
> >
> > I'll try and write a test case to simulate this situation, and reproduce
> > it here.
>
> I've added a test to Xapian for this situation, but it doesn't reproduce
> the problem. If you could submit a working piece of code that fails in
> this way, that would be very helpful.
>
Thanks for implementing DatabaseVersionError. It works as expected in
the snapshot I tried (svn8484).
As for the locking problem I described, I quickly hacked omindex to try
and overwrite the database if a format error is detected :
--- omindex.cc_bak 2007-05-07 20:09:00.000000000 +0800
+++ omindex.cc 2007-05-07 21:35:11.000000000 +0800
@@ -836,12 +836,14 @@
try {
if (!overwrite) {
db = Xapian::WritableDatabase(dbpath, Xapian::DB_CREATE_OR_OPEN);
+ cout << "Opened database" << endl;
if (!skip_duplicates) {
// + 1 so that db.get_lastdocid() is a valid subscript.
updated.resize(db.get_lastdocid() + 1);
}
} else {
db = Xapian::WritableDatabase(dbpath,
Xapian::DB_CREATE_OR_OVERWRITE);
+ cout << "Opened database" << endl;
}
indexer.set_stemmer(stemmer);
@@ -861,6 +863,16 @@
db.flush();
// cout << "\n\nNow we have " << db.get_doccount() << " documents.\n";
exitcode = 0;
+ } catch (const Xapian::DatabaseVersionError &e) {
+ cout << "Database Version Exception: " << e.get_msg() << endl;
+ try
+ {
+ if (!overwrite) {
+ db = Xapian::WritableDatabase(dbpath,
Xapian::DB_CREATE_OR_OVERWRITE);
+ }
+ } catch (const Xapian::Error &ee) {
+ cout << "Another Exception: " << ee.get_msg() << endl;
+ }
} catch (const Xapian::Error &e) {
cout << "Exception: " << e.get_msg() << endl;
} catch (const string &s) {
If I run the resulting omindex against an old database I have, with :
$ ./omindex --db ~/.pinot/daemon_bak --url
file:///home/fabrice/Documents/UniversalCharsetDetection.doc
/home/fabrice/Documents/UniversalCharsetDetection.doc
I get this output :
"
Database Version Exception: Flint version file
/home/fabrice/.pinot/daemon_bak/iamflint is version 200506110 but I
only understand 200704230
Another Exception: Unable to acquire database write lock on
/home/fabrice/.pinot/daemon_bak: already locked
"
Is this enough to point in the right direction ? Let me know if you need more
information.
Fabrice
More information about the Xapian-discuss
mailing list