Hello all,
I recently updated to notmuch 0.31.4+137~g6967dcb and made some changes to the 
way I sync my mail using lieer.
I wanted to utilise the pre-new and post-new notmuch hooks.
However, when running an operation to import mail in the context of the notmuch 
pre-new hook (by running gmi pull), I can see that the database is locked, 
which means that running notmuch new hangs.
From man (5) notmuch-hooks the wording is such that it implies that the 
database is not locked when the pre-new and post-new hooks are run.

If I strace notmuch new, I can see that the database is opened for writing 
before the pre-new hook is run, and it is not closed before the hook is run.
This means that any operation which needs write access to database (e.g. 
lieer’s gmi pull) cannot obtain the database lock, so it hangs.

The problem can be reproduced by creating $DATABASEDIR/.notmuch/hooks/pre-new 
and having it perform a notmuch CLI command to write to the DB, such as apply a 
tag.

I described the problem in https://github.com/gauteh/lieer/issues/195 
<https://github.com/gauteh/lieer/issues/195>

Assuming the database should be able to be opened for writing in the context of 
the pre-new (and post-new) hooks, this seems like a bug.
Here is some output...

Running notmuch new before the pre-new hook is executed:

..
openat(AT_FDCWD, "/home/myhome/path/to/maildir//.notmuch/xapian/flintlock", 
O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 3
fcntl(3, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=1}) 
= 0
openat(AT_FDCWD, "/home/ml943601/b/mail/brcm//.notmuch/xapian/iamglass", 
O_RDONLY) = 4
..

It’s never closed before the hook is executed.
What the hang looks like:

 [~]
$ notmuch new
path: /home/myhome/path/to/maildir/gmaildir/
pull: partial synchronization.. (hid: 66446860)
fetching changes ....fetching changes ....fetching changes ....fetching changes 
...resolving changes (376) ........................................receiving 
content (156) ...^C
Traceback (most recent call last):
  File "/home/myhome/git/lieer/gmi", line 24, in <module>
    g.main ()
  File "/home/myhome/git/lieer/lieer/gmailieer.py", line 215, in main
    args.func (args)
  File "/home/myhome/git/lieer/lieer/gmailieer.py", line 418, in pull
    self.partial_pull ()
  File "/home/myhome/git/lieer/lieer/gmailieer.py", line 548, in partial_pull
    updated     = self.get_content (message_gids)
  File "/home/myhome/git/lieer/lieer/gmailieer.py", line 754, in get_content
    self.remote.get_messages (need_content, _got_msgs, 'raw')
  File "/home/myhome/git/lieer/lieer/remote.py", line 133, in func_wrap
    return func (self, *args, **kwargs)
  File "/home/myhome/git/lieer/lieer/remote.py", line 384, in get_messages
    cb (msg_batch)
  File "/home/myhome/git/lieer/lieer/gmailieer.py", line 749, in _got_msgs
    with notmuch.Database (mode = notmuch.Database.MODE.READ_WRITE) as db:
  File "/usr/local/lib/python3.8/dist-packages/notmuch/database.py", line 164, 
in __init__
    self.open(path, mode)
  File "/usr/local/lib/python3.8/dist-packages/notmuch/database.py", line 223, 
in open
    status = Database._open(_str(path), mode, byref(db))

There is no other program running at the time of the hang which accesses the 
database.
The problem seems to be caused by the database being opened for writing before 
the hook is executed.

Does notmuch require the database to be open when calling the hook?

Cheers,
—  Matt

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to