[PATCH v6 00/17] Fix 'notmuch new' atomicity issues

Austin Clements amdragon at MIT.EDU
Thu Sep 29 08:01:47 PDT 2011


Quoth Sebastian Spaeth on Sep 28 at  6:36 pm:
> On Sat, 11 Jun 2011 16:04:26 -0400, Austin Clements <amdragon at MIT.EDU> wrote:
> > Here's the reworked patch series that uses atomic sections more
> > heavily rather than changing the removal API.  This is atomic-new-v6
> > on http://awakening.csail.mit.edu/git/notmuch.git .
> 
> I just caught up implementing find_message_by_filename and
> begin|end_atomic
> 
> One oddity, since databases are opened in read-only by default, I was
> surprise to see find_message_by_filename on such a database have my
> python instance crash...
> 
> > lib: Add an API to find a message by filename.
> >   Culled from "lib: Add API's to find by filename and ..." in the old
> >   series.  What I kept is identical.
> 
> db.find_message_by_filename("moo")
> Internal error: Failure to ensure database is writable
> (lib/directory.cc:100).
> 
> Outch?

Oof.

It appears that looking up a directory requires a writable database
because notmuch will try to *create* a database document for the
directory if one doesn't already exist.  This is clearly wrong
behavior for a "find" function.

The exact code path is
  notmuch_database_find_message_by_filename
  _notmuch_database_filename_to_direntry
  _notmuch_database_find_directory_id
  _notmuch_directory_create

_notmuch_message_add_filename currently depends on
_notmuch_database_filename_to_direntry to create the directory
document if it doesn't exist.  Possibly
_notmuch_database_filename_to_direntry,
_notmuch_database_find_directory_id, and _notmuch_directory_create
should acquire a flags argument with a "create" flag that controls
this behavior.


More information about the notmuch mailing list