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 2F9DC431FB6 for ; Fri, 28 Jan 2011 01:45:46 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=unavailable 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 UOvd+mYWrwex for ; Fri, 28 Jan 2011 01:45:46 -0800 (PST) Received: from smtprelay02.ispgateway.de (smtprelay02.ispgateway.de [80.67.31.36]) by olra.theworths.org (Postfix) with ESMTP id C2183431FB5 for ; Fri, 28 Jan 2011 01:45:45 -0800 (PST) Received: from [87.180.40.233] (helo=stokes.schwinge.homeip.net) by smtprelay02.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1Piktj-0007za-0x for notmuch@notmuchmail.org; Fri, 28 Jan 2011 10:45:43 +0100 Received: (qmail 18234 invoked from network); 28 Jan 2011 09:45:25 -0000 Received: from kepler.schwinge.homeip.net (192.168.111.7) by stokes.schwinge.homeip.net with QMQP; 28 Jan 2011 09:45:25 -0000 Received: (nullmailer pid 18660 invoked by uid 1000); Fri, 28 Jan 2011 09:45:25 -0000 From: Thomas Schwinge To: Carl Worth , Austin Clements , Jameson Rollins Subject: Re: notmuch's idea of concurrency / failing an invocation In-Reply-To: <87fwsdobpy.fsf@yoom.home.cworth.org> References: <87fwsetdin.fsf@kepler.schwinge.homeip.net> <8762taxk9y.fsf@algae.riseup.net> <87vd1a84qj.fsf@servo.finestructure.net> <87fwsdobpy.fsf@yoom.home.cworth.org> User-Agent: Notmuch/0.5-33-g665f77b (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Fri, 28 Jan 2011 10:45:19 +0100 Message-ID: <877hdps6og.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Df-Sender: thomas@schwinge.name 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 09:45:46 -0000 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hallo! On Fri, 28 Jan 2011 15:10:01 +1000, Carl Worth wrote: > On Thu, 27 Jan 2011 17:20:21 -0500, Austin Clements wr= ote: > > I'm looking into breaking notmuch new up into small transactions. It > > wouldn't be much a leap from there to simply close and reopen the datab= ase > > between transactions if another task wants to use it, which would relea= se > > the lock and let the queued notmuch task have the database for a bit. >=20 > That sounds like something very useful to pursue. Please continue! Ack! And actually -- I just wondered about that: what happens if ``notmuch new'' has executed notmuch_database_add_message for a new message M, but then is killed before adding any tags and finishing up (and supposing that the DB isn't in an invalid state now). This process of adding M to the DB and applying any tags isn't one single transaction currently, right? (And this is exactly what you're working on chainging?) Am I right that what currently happens is that upon the next ``notmuch new'' run, notmuch will not reconsider M (given that it already is present in the DB), but continue with the next messages -- thus leaving M without any tags? This isn't a very likely scenario, but still a possible one. > > It seems silly to have a daemon when all of notmuch's state is already = on disk > > and queue on a lock is as good as a queue in a daemon, but without the > > accompanying architectural shenanigans. Ack, too. A daemon seems one abstraction layer too much. (But I'm not actively opposed either, if someone has a valid use for such a scheme.) > 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. > Another advantage that can happen with queueing (wherever it occurs) is > to allow a client to be very responsive without waiting for an operation > to complete. Though that can of course be band if the operation isn't > reliably committed. (Obviously this can only work as long as we don't immediatelly need the operation's result; think ``notmuch show''.) So, if the DB has the functionality to internally queue and immediatelly acknowledge transactions, and only later (reliably) commit them, wouldn't that be fine indeed? For example, ``notmuch tag'' then wouldn't have to wait for the DB to be writable. (And note that I have no idea whether Xapian supports such things.) But on the other hand we would like to immediatelly display the requested change in the UI, right? What notmuch-show.el:notmuch-show-remove-tag currently does is *not* re-asking the DB for a message's current tags after having removed a specific one, but instead it interprets the tag removal command itself -- which is easy enough in this case, and rather unlikely to ever yield different results, at least unless there's another process operating on the DB concurrently. Otherwise, the other way round, the client could maintain a list of to-do items, to which actions are added if the DB is currently busy, and this list is periodically worked on in order to get it empty. For example, tag changes that are in this list, but not yet committed in the DB could be displayed in another color in the UI. But doing so would shift the responsibility to the UI, which should be in the DB, in my humble opinion. (Actually, this issue feels similar to the one who should be doing the re-trying in case the DB is busy: the UI, or the notmuch process itself, which we're discussing in another thread.) As you can guess I'm not very much into DBs, and neither too much into concurrent systems, so if my ideas don't make sense, please feel free to refer me to literature. Gr=C3=BC=C3=9Fe, Thomas --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAk1CkC8ACgkQFaWaPJ2HwAoguwCcCn2F8JpKLEehzryPb3iRFhD1 2R0AnjOS0Swp28eBpFTyng1VAI6oHX7P =dhDz -----END PGP SIGNATURE----- --=-=-=--