[Xapian-discuss] swapping database mid replication

Olly Betts olly at survex.com
Sat Mar 5 02:37:21 GMT 2011


On Fri, Mar 04, 2011 at 07:03:33PM +0000, Richard Boulton wrote:
> Secondly, I wouldn't recommend swapping databases like that in any
> situation; even without replication, Xapian may get confused when
> attempting to open the database, opening some of the old files and
> some of the new files, causing an error to occur.  Instead, you should
> use a stub database to point to the current database you want to use,
> and atomically replace it with a new version when you want to change,
> using a single mv.  (See http://xapian.org/docs/overview.html ,
> section "Specifying a database").

As of Xapian 1.2.4, you can compact to a stub database and it will be
atomically updated for you - e.g.

xapian-compact new.db live.db

where live.db is a stub file or directory.

You can also compact a directory to itself if it's a stub:

xapian-compact live.db live.db

This works even if live.db's stub expands to a list of databases
beforehand.

Note that the old database(s) which live.db pointed to isn't/aren't
currently automatically removed.  The issue is that you really want
wait for any possible current readers to finish, so I punted on how best
to address that for now.

Cheers,
    Olly



More information about the Xapian-discuss mailing list