]> git.notmuchmail.org Git - notmuch/commit
Avoid database corruption by not adding partially-constructed mail documents.
authorCarl Worth <cworth@cworth.org>
Fri, 4 Jun 2010 17:16:53 +0000 (10:16 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 4 Jun 2010 17:16:53 +0000 (10:16 -0700)
commit98845fdbb2a4acaa0036f8e2e998e726b18e6b13
treed74a31c55be0f83ff36d773f3dc305d666818a9b
parent361b9d4bd9042629e3729b43d18a862ddc716242
Avoid database corruption by not adding partially-constructed mail documents.

Previously we were using Xapian's add_document to allocate document ID
values for notmuch_message_t objects.  This had the drawback of adding
a partially constructed mail document to the database. If notmuch was
subsequently interrupted before fully populating this document, then
later runs would be quite confused when seeing the partial documents.

There are reports from the wild of people hitting internal errors of
the form "Message ... has no thread ID" for example, (which is
currently an unrecoverable error).

We fix this by manually allocating document IDs without adding
documents. With this change, we never call Xapian's add_document
method, but only replace_document with either the current document ID
of a message or a new one that we have allocated.
lib/database-private.h
lib/database.cc
lib/directory.cc
lib/message.cc
lib/notmuch-private.h