[Xapian-discuss] allterms iterator dangerous?
Francis Irving
francis at flourish.org
Thu Apr 24 10:57:20 BST 2008
Thanks for everyone's help, I'll have a better present to give
in thanks shortly.
On Thu, Apr 24, 2008 at 09:36:11AM +0100, Richard Boulton wrote:
> If you're on Unix, you can use the fact that xapian keeps the database
> file handles open during a search. This means that if you unlink the
> files which a search is in progress, your search should still complete
> correctly. There is a brief period where some of the file handles are
> open but others haven't yet been opened, so I'd suggest using a symlink
> to point to the "live database", building a new live database, then
> switching the symlink over, then wait a few seconds (to ensure no
> searches are in the process of opening the database), and then delete
> the old database.
You're right, replacing it completely is much simpler and better. I
was partly scared of the "rm -fr" code that that required, but have
added checks for presence of iamflint to make it safer.
Is the following OK, this from a Ruby script using the Ruby bindings:
- Open a writable database
- Write some stuff to it
- Call flush on it
- Rename the directory of the database to a new name
- Exit (so calling the destructor)
I want to make sure that
- the flush will ensure everything is written to disk before the
database readers start reading it after the rename.
- that when it later exits and close the files, everything will be
fine.
I suspect it will, but am just being sure :)
Francis
More information about the Xapian-discuss
mailing list