[PATCH v2 00/11] compactor changes v2
Tomi Ollila
tomi.ollila at iki.fi
Tue Nov 5 12:14:24 PST 2013
On Tue, Nov 05 2013, Ben Gamari <bgamari.foss at gmail.com> wrote:
> Tomi Ollila <tomi.ollila at iki.fi> writes:
>
>>
>> The whole series looks OK to me. The only thing I'm, a bit worried about
>> what happens is I Ctrl-C compaction at any state. Is it possible that I
>> end up with corrupted database ? Someone may accidentally execute
>> notmuch compact -- for example by picking the command from history.
>>
> You should in principle never end up in a situation where the original
> database is corrupted. Xapian's Compactor interface reads from the
> existing database and writes out the compacted database to a new
> directory. The notmuch compact command keeps the original database in
> place until the last possible moment.
>
> When the compacted database is completely constructed it, deletes or
> moves the old database out of the way and then moves the new database
> into place. The worst thing that could happen is that you manage to
> interrupt the process between deleting the old database and moving the
> new one into place (a very small window). In this case you'd simply need
> to move the new database into place manually (although you'd need to
> figure out where the compacted database is located).
Ah true. I failed to keep the whole picture in mind. Indeed the compactor
first compacts from .notmuch/xapian to .notmuch/xapian.compact (and
finally directory renaming is done in database.cc... (and with directories
we cannot do atomic file update using link()/rename() calls).
(If we wanted to handle this "small window" we could try use 'xapian.compact'
directory in case 'xapian' was nonexistent but... :)
That understood I'm ok with these pathes (when that oversight fixed).
>
> Cheers,
>
> - Ben
Tomi
More information about the notmuch
mailing list