Re: Possible threading issues in nm 0.32

Subject: Re: Possible threading issues in nm 0.32

Date: Tue, 11 May 2021 18:56:08 +0200

To: Alexander Adolf, David Bremner, notmuch@notmuchmail.org

Cc:

From: Michael J Gruber


... just a guess: Could it be that 

a9f74aee ("CLI/new: drop the write lock to run the pre-new hook.", 2021-03-18)

was not enough?

notmuch_database_reopen() only reopens the xapian db but does not update
other members in notmuch_database_t *notmuch, such as the last doc id
and thread id.

If a pre-merge hook changes the database then values in that struct will
be out of date.

Before the config changes in nm 0.32, there was no such struct to begin
with. After that, notmuch holds the struct just to be able to run the
hook (from the proper dir).

So I would think that reopen()ing to MODE_READ_ONLY is not a problem.
But after the hook run, are full close() then open() to
MODE_READ_WRITE() is necessary so that the values in the struct are
correct (or change reopen() to do that).

Indeed, if you open in MODE_READ_ONLY and don't hold a write lock you
cannot trust any cached values such as those stored in the struct, can
you?

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

Thread: