Re: [PATCH 0/3] notmuch-deliver: wait for database to become unlocked and test

Subject: Re: [PATCH 0/3] notmuch-deliver: wait for database to become unlocked and test

Date: Mon, 7 Nov 2011 03:32:29 +0200

To: David Riebenbauer

Cc: Notmuch Mailing List

From: Ali Polatel


On Sun, Nov 06, 2011 at 12:23:01PM +0100, David Riebenbauer wrote:
>Hi,
>
>I noticed that mail would bounce in my setup, if the xapian database
>was locked while notmuch-deliver tried to run.

I recall having this problem sometime ago...

>My solution was to make it wait for some time adn retry. A test
>program for is alos included.

Looks like a workaround more than a solution. What happens if the
database doesn't become available for writing in the meantime?

Quoting from:
http://xapian.org/docs/admin_notes.html#single-writer-multiple-reader

"Xapian enforces this restriction using by having a writer lock the database.
Each Xapian database directory contains a lock file named flintlock (we've kept
the same name as flint used, since the locking technique is the same).

This lock-file will always exist, but will be locked using fcntl() when the
database is open for writing. Because of the semantics of fcntl() locking, for
each WritableDatabase opened we spawn a child process to hold the lock, which
then exec-s cat, so you will see a cat subprocess of any writer process in the
output of ps, top, etc."

See? It's a simple fcntl() lock!

That said, I'm against adding this kind of kludge to notmuch-deliver or
any other tool accessing the database via libnotmuch. Until the issue is
fixed properly I, and I suppose you, can live with a simple shell script
using flock(1) on the file .notmuch/xapian/flintlock.

One possible solution is described by Austin in the mail:
id:AANLkTi=KOx8aTJipkiArFVjEHE6zt_JypoASMiiAWBZ6@mail.gmail.com
which I quite like.

>Regards,
>David

		-alip

>David Riebenbauer (3):
>  notmuch-deliver: wait for the database to become unlocked
>  notmuch-deliver: test wait for database to become available
>  notmuch-deliver: Convert test program to glib main loop.
>
> contrib/notmuch-deliver/.gitignore          |    2 +
> contrib/notmuch-deliver/Makefile.am         |    2 +-
> contrib/notmuch-deliver/configure.ac        |    1 +
> contrib/notmuch-deliver/src/main.c          |   25 +++-
> contrib/notmuch-deliver/test/Makefile.am    |   26 +++
> contrib/notmuch-deliver/test/nm-test.sh     |    9 +
> contrib/notmuch-deliver/test/nm-testconfig  |   12 ++
> contrib/notmuch-deliver/test/notmuch-lock.c |  226 +++++++++++++++++++++++++++
> contrib/notmuch-deliver/test/testmail       |    7 +
> 9 files changed, 306 insertions(+), 4 deletions(-)
> create mode 100644 contrib/notmuch-deliver/test/Makefile.am
> create mode 100755 contrib/notmuch-deliver/test/nm-test.sh
> create mode 100644 contrib/notmuch-deliver/test/nm-testconfig
> create mode 100644 contrib/notmuch-deliver/test/notmuch-lock.c
> create mode 100644 contrib/notmuch-deliver/test/testmail
>
>-- 
>1.7.7.1
>
>_______________________________________________
>notmuch mailing list
>notmuch@notmuchmail.org
>http://notmuchmail.org/mailman/listinfo/notmuch
part-000.sig (application/pgp-signature)

Thread: