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 913C7431FB6 for ; Fri, 28 Jan 2011 10:17:19 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=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 s-28PaUfxJA7 for ; Fri, 28 Jan 2011 10:17:19 -0800 (PST) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D122D431FB5 for ; Fri, 28 Jan 2011 10:17:18 -0800 (PST) Received: by qyk12 with SMTP id 12so3940826qyk.5 for ; Fri, 28 Jan 2011 10:17:18 -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 :content-transfer-encoding; bh=9tgRmcdPcKCrEYXfKeZcIP8ejrPcH0HFJrRMmObQh94=; b=n+aa8+0Vt+acWLPRRQkVUQuT7B7TqhPj+1fRUMTRFhzfkh7ulBcwZJQjrcNt51xw5M C+/Ndraw6i9hnlD+X+xehTpOS0IbJVBaIohvOSLRdmFEHF1wtjeWV+YAuMYT3eesIvMB OnBNbR4bgbOhI7kCb3v0z73P4guzDKtygzp5s= 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 :content-transfer-encoding; b=R09gMMvGatRWAXdZAG1BviYrq01YsSSfgepdiEFJJlqI1kBZP80nusKrL8SXFOms9I M6DbR3T3quhoqU6hXCTl4S3hcr23UvYyIpoZJ5traEIksBb/lJ9fY8xDBBvWS+QnvjHR Dd9Wm1N9gk4TBBG4Za+a+ATgU0cOuID4KMohA= MIME-Version: 1.0 Received: by 10.229.220.81 with SMTP id hx17mr1166490qcb.116.1296238638065; Fri, 28 Jan 2011 10:17:18 -0800 (PST) Sender: amdragon@gmail.com Received: by 10.229.97.143 with HTTP; Fri, 28 Jan 2011 10:17:18 -0800 (PST) In-Reply-To: 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 13:17:18 -0500 X-Google-Sender-Auth: dJSapOE3E4wmvF6-fS9DBwk7bLI Message-ID: Subject: Re: notmuch's idea of concurrency / failing an invocation From: Austin Clements To: Mike Kelly Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 18:17:19 -0000 Actually, this is trivial to play with. Here's a stop-gap wrapper script for people having trouble with Xapian locking, #!/bin/bash NOTMUCH_BIN=3D"/path/to/notmuch" MAIL_DIR=3D"/path/to/mailroot" ( case "$1" in setup|help) ;; search|show|count|reply|dump|search-tags|part) flock -s 200;; *) flock -x 200;; esac "$NOTMUCH_BIN" "$@" 200>&- ) 200>"$MAIL_DIR"/.notmuch/lock On Fri, Jan 28, 2011 at 11:57 AM, Austin Clements wrote: > > 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 havi= ng a >> > > daemon, but how do you imagine "queue on a lock" to work? We don't h= ave >> > > 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) blockin= g >> > 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 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. =A0All of this. =A0Unfortunately, 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.