Re: [bug] notmuch doesn't commit changes before an open transaction on close

Subject: Re: [bug] notmuch doesn't commit changes before an open transaction on close

Date: Sat, 25 Dec 2021 20:13:04 -0400

To: Steven Allen,


From: David Bremner

Steven Allen <> writes:

> Notmuch claims to commit changes made before an open transaction on
> close but actually throws them away (according to the documentation).
> According to the notmuch documentation,
>> For writable databases, notmuch_database_close commits all changes
>> to disk before closing the database.  If the caller is currently in
>> an atomic section (there was a notmuch_database_begin_atomic
>> without a matching notmuch_database_end_atomic), this will discard
>> changes made in that atomic section (but still commit changes made
>> prior to entering the atomic section).
> However, this isn't true. Notmuch atomic transactions don't flush on
> entry so, this comment from the xapian documentation applies:
>> If you're applying atomic groups of changes and only wish to ensure
>> that each group is either applied or not applied, then you can prevent
>> the automatic commit() before and after the transaction by starting
>> the transaction with begin_transaction(false). However, if
>> cancel_transaction is called (or if commit_transaction isn't called
>> before the WritableDatabase object is destroyed) then any changes
>> which were pending before the transaction began will also be
>> discarded.
> source:
> This means that, in theory at least, xapian could throw away *all*
> changes to the database if a transaction is open.

The docs are corrected, and notmuch now does periodic automatic commits
to reduce the amount of lost work when interrupted. At the moment I
think that is the best we can do, so I'm marking this as fixed.

notmuch mailing list --
To unsubscribe send an email to