Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 44756431FB6 for ; Fri, 28 Jan 2011 08:57:36 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.698 X-Spam-Level: X-Spam-Status: No, score=-0.698 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bgIXxWvtIhxM for ; Fri, 28 Jan 2011 08:57:35 -0800 (PST) Received: from mail-qw0-f53.google.com (mail-qw0-f53.google.com [209.85.216.53]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 83BCE431FB5 for ; Fri, 28 Jan 2011 08:57:35 -0800 (PST) Received: by qwe5 with SMTP id 5so3713284qwe.26 for ; Fri, 28 Jan 2011 08:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=R1ggX/9a5PmlB/yJsW5F1VF6tPCFQ1ua3ffXNhHt8FI=; b=rg3ZTAYBesEUlaDGitSPir0WKIo9v/caYmPZQEJav3LClj0rbgLZh9gQSIfRr/LkOc XMN8KbKk4uzkw0rMCr1p/PJaSEaHXfQJV09EpdhRnMgD4ZLPUW5VGmSgJuPDhAHTo9O+ 8oouAzsji+NYYguqwIoVkIKOb3XO9UrvP4usc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=cWbR38hGEJRQht2MSUVqidMBfm65IszE/5UWX5qYV8Fqk2y9UYjRSFNQsh97QIq9Yh bNuCemK6QbvoZDqjYtr/N95UYed71bQ+yFHdwsBz1H/o6o/29WBg/ioZUSeBZJA7xqju JNMLAfomJ+kN2tTmf40g9RGTZch2g4yENRokU= MIME-Version: 1.0 Received: by 10.229.238.148 with SMTP id ks20mr2910814qcb.78.1296233854560; Fri, 28 Jan 2011 08:57:34 -0800 (PST) Sender: amdragon@gmail.com Received: by 10.229.97.143 with HTTP; Fri, 28 Jan 2011 08:57:34 -0800 (PST) In-Reply-To: <1296228975-ner-3626@everglades> References: <87fwsetdin.fsf@kepler.schwinge.homeip.net> <8762taxk9y.fsf@algae.riseup.net> <87vd1a84qj.fsf@servo.finestructure.net> <87fwsdobpy.fsf@yoom.home.cworth.org> <877hdps6og.fsf@kepler.schwinge.homeip.net> <1296228975-ner-3626@everglades> Date: Fri, 28 Jan 2011 11:57:34 -0500 X-Google-Sender-Auth: ExmzuTiUvxJ-Ao0dU5RJdBCpL2o Message-ID: Subject: Re: notmuch's idea of concurrency / failing an invocation From: Austin Clements To: Mike Kelly Content-Type: multipart/alternative; boundary=00163646b8ee726b67049aeaf657 Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2011 16:57:36 -0000 --00163646b8ee726b67049aeaf657 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Jan 28, 2011 at 10:36 AM, Mike Kelly wrote: > On Fri, 28 Jan 2011 10:45:19 +0100, Thomas Schwinge > wrote: > > > It would definitely be nice to avoid the complexity inherent in having > a > > > daemon, but how do you imagine "queue on a lock" to work? We don't have > > > anything like that in place now. > > > > I suppose what he means is trying to get the lock, and if that fails wait > > a bit / wait until it is available again. > > > > Actually, as a next step, wouldn't it also be possible to add some > > heuristic to avoid ``notmuch new'' (being a low-priority task) blocking > > some interactive user (UI; high-priority task)? But we can pursue such > > schemes as soon as the basic infrastructure is in place. > > Couldn't we pretty much get the desired behavior by using flock(2)? > Basically, take out a LOCK_EX when we need to write, and a LOCK_SH when > we only need to read. Using the blocking form, things should pretty much > just queue up and take their turn, right? > > I'm not familiar with Xapian, but if it doesn't give us something we > could use this sort of locking on, couldn't we just add some > /path/to/mail/.notmuch.lock file that we open to hold a lock on? > Yes, exactly. All of this. Unfortunately, Xapian doesn't expose the ability to block on the lock (see the fcntl call in backends/flint_lock.cc, which is hard-coded to the non-blocking F_SETLK instead of F_SETLKW), so we'd either need a new Xapian option, or we would just have to wrap our own flock/fcntl lock around things as you suggest. --00163646b8ee726b67049aeaf657 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Fri, Jan 28, 2011 at 10:36 AM, Mike Kelly <pioto@pioto.org&g= t; wrote:
On Fri, 28 Jan 2011 10:45:19 +0100, Thomas Schwinge <<= a href=3D"mailto:thomas@schwinge.name">thomas@schwinge.name> wrote:<= br> > > It would definitely be nice to avoid the complexity inherent in h= aving a
> > daemon, but how do you imagine "queue on a lock" to wor= k? We don't have
> > anything like that in place now.
>
> I suppose what he means is trying to get the lock, and if that fails w= ait
> a bit / wait until it is available again.
>
> Actually, as a next step, wouldn't it also be possible to add some=
> heuristic to avoid ``notmuch new'' (being a low-priority task)= blocking
> some interactive user (UI; high-priority task)? =A0But we can pursue s= uch
> schemes as soon as the basic infrastructure is in place.

Couldn't we pretty much get the desired behavior by using flock(2= )?
Basically, take out a LOCK_EX when we need to write, and a LOCK_SH when
we only need to read. Using the blocking form, things should pretty much just queue up and take their turn, right?

I'm not familiar with Xapian, but if it doesn't give us something w= e
could use this sort of locking on, couldn't we just add some
/path/to/mail/.notmuch.lock file that we open to hold a lock on?

Yes, exactly. =A0All of this. =A0Unfortunately, X= apian doesn't expose the ability to block on the lock (see the fcntl ca= ll in backends/flint_lock.cc, which is hard-coded to the non-blocking F_SET= LK instead of F_SETLKW), so we'd either need a new Xapian option, or we= would just have to wrap our own flock/fcntl lock around things as you sugg= est.

--00163646b8ee726b67049aeaf657--