Re: [PATCH] lib: Simplify close and codify aborting atomic section
authorW. Trevor King <wking@tremily.us>
Mon, 22 Sep 2014 19:00:22 +0000 (12:00 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:42 +0000 (10:04 -0800)
f8/e123bd22aad7f0e31525cea39ecb5c8be7986f [new file with mode: 0644]

diff --git a/f8/e123bd22aad7f0e31525cea39ecb5c8be7986f b/f8/e123bd22aad7f0e31525cea39ecb5c8be7986f
new file mode 100644 (file)
index 0000000..8aa51e0
--- /dev/null
@@ -0,0 +1,148 @@
+Return-Path: <wking@tremily.us>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 14135431FC0\r
+       for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 12:00:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id TxXEoqq9AeG0 for <notmuch@notmuchmail.org>;\r
+       Mon, 22 Sep 2014 12:00:25 -0700 (PDT)\r
+Received: from resqmta-po-04v.sys.comcast.net (resqmta-po-04v.sys.comcast.net\r
+       [96.114.154.163])\r
+       (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 1158D431FB6\r
+       for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 12:00:25 -0700 (PDT)\r
+Received: from resomta-po-08v.sys.comcast.net ([96.114.154.232])\r
+       by resqmta-po-04v.sys.comcast.net with comcast\r
+       id uJyo1o004516pyw01K0QYv; Mon, 22 Sep 2014 19:00:24 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+       by resomta-po-08v.sys.comcast.net with comcast\r
+       id uK0P1o008152l3L01K0Pjx; Mon, 22 Sep 2014 19:00:24 +0000\r
+Received: by odin.tremily.us (Postfix, from userid 1000)\r
+       id 1533E13A7891; Mon, 22 Sep 2014 12:00:22 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin;\r
+       t=1411412423; bh=L0pza3r2wiztdH8PAeBCdOolv1u+hBM3gHCkZ/9B7SI=;\r
+       h=Date:From:To:Cc:Subject:References:In-Reply-To;\r
+       b=rQq0K0zb6f6u6j33d94snCkyCuMuDqoSfX8vMDsfcSZ1tjbG5YvY0JZkKtrYBfw6U\r
+       s/aD460zMjyFBsSq807qpoItliTY05R+mCr/lpvmqfcXXsRTu/4d/euWTNH4PE9Xnh\r
+       +SSmBgRLMfyqLJ7gEL5tvCvQGblQmiWmy7cXlxz4=\r
+Date: Mon, 22 Sep 2014 12:00:22 -0700\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: Austin Clements <amdragon@mit.edu>\r
+Subject: Re: [PATCH] lib: Simplify close and codify aborting atomic section\r
+Message-ID: <20140922190022.GO20827@odin.tremily.us>\r
+References: <1411400615-20934-1-git-send-email-amdragon@mit.edu>\r
+       <20140922165954.GI20827@odin.tremily.us>\r
+       <20140922185050.GB7970@csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; micalg=pgp-sha1;\r
+       protocol="application/pgp-signature"; boundary="5PFZVUeDPxlnBcQp"\r
+Content-Disposition: inline\r
+In-Reply-To: <20140922185050.GB7970@csail.mit.edu>\r
+OpenPGP: id=39A2F3FA2AB17E5D8764F388FC29BDCDF15F5BE8;\r
+       url=http://tremily.us/pubkey.txt\r
+User-Agent: Mutt/1.5.23 (2014-03-12)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
+       s=q20140121; t=1411412424;\r
+       bh=0K3jMy7/3YhBPLD15lLqIXDY/1ZRCDxMS9iIkPOap0o=;\r
+       h=Received:Received:Received:Date:From:To:Subject:Message-ID:\r
+       MIME-Version:Content-Type;\r
+       b=JR35izmixUIMyvRGG2ZsZKsTDvg9EE6c8JIFLeXmpW64oyqANIeuVo2gTMRFt2mDp\r
+       AyO/Ux2vciZvf+0Cv0eE/FG6aKqkWdTanUIcrRpyGidOh9utMfNUTYnz9VMZ3CR2uF\r
+       k+bLOGCerhNw1LMrPln6hZILB6ozH8I9STtAT8HHQ04ORtzmzIewi84Ty8daVt9aV5\r
+       V3t/A1GPGBQOdK5vFgUGbGN8IajsCa4dnHx3A0Jxh6g32iXG765aFelQZGu8Z51pC5\r
+       Ko6sqUL3uH8XokXiLCTGDcWMZHNJZMUuoOOu064qitBSXXUD+T2GzAVDj9rBFOpHhc\r
+       v1M2GtzAzMJEA==\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 22 Sep 2014 19:00:29 -0000\r
+\r
+\r
+--5PFZVUeDPxlnBcQp\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+On Mon, Sep 22, 2014 at 06:50:50PM +0000, Austin Clements wrote:\r
+> Quoth W. Trevor King on Sep 22 at  9:59 am:\r
+> > On Mon, Sep 22, 2014 at 11:43:35AM -0400, Austin Clements wrote:\r
+> > > This patch simplifies notmuch_database_close to just call\r
+> > > Database::close.  This works for both read-only and read/write\r
+> > > databases, takes care of committing changes, unifies the\r
+> > > exception handling path, and codifies aborting outstanding\r
+> > > transactions.\r
+> >=20\r
+> > If we're dropping the flush call here, where will it be triggered\r
+> > instead?  We'll need to flush/commit our changes to the database\r
+> > at some point before closing.  Do clients now need an explicit\r
+> > flush/commit command (explicit, client-initiated flushes sound\r
+> > like a good idea to me).\r
+>=20\r
+> The call to Database::close implicitly flushes/commits, as mentioned\r
+> in the comment in the patch, so there's no need for any new APIs or\r
+> client changes.  The call to Database::flush in\r
+> notmuch_database_close was entirely redundant with the call to\r
+> Database::close.\r
+\r
+Ah, I thought the implicit flush/commit was just in our code.  Since\r
+it's also in the underlying Xapian close, then this patch looks pretty\r
+good to me.  I'd mention Xapian's explicit close in the notmuch.h\r
+message.  Xapain's docs say [1]:\r
+\r
+  For a WritableDatabase, if a transaction is active it will be\r
+  aborted, while if no transaction is active commit() will be\r
+  implicitly called.\r
+\r
+Cheers,\r
+Trevor\r
+\r
+[1]: http://xapian.org/docs/apidoc/html/classXapian_1_1Database.html#a59f5f=\r
+8b137723dcaaabdbdccbc0cf1eb\r
+\r
+--=20\r
+This email may be signed or encrypted with GnuPG (http://www.gnupg.org).\r
+For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\r
+\r
+--5PFZVUeDPxlnBcQp\r
+Content-Type: application/pgp-signature; name="signature.asc"\r
+Content-Description: OpenPGP digital signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v2\r
+\r
+iQIcBAEBAgAGBQJUIHHEAAoJEG8/JgBt8ol8TD0P/25sw/RjQN+51URpyT4wAGJg\r
+i89pJ/QBSFz2sk9F/K2GzuOA8LzMqWr1lImQIdi1ypMjHGmmfxkuNWUYWvgQHpc1\r
+KLKaSXql6FAY5KD4mtPGFlLUa9CKNWOqBKwrVRBSjs7UqT8fN+C24XbYA6qnCB0C\r
+Z84TLTxa/4UOpu8nZABASSkWmWcmXphpSdUKzBSLLG6o9iSmaY3YyEXVSfREEV2S\r
+OqmuzOGlxO03hS3j/zOdOrs8CHYrsDvq0kWZZWS7hBIDidZbuXpAsrRJTxpwUScd\r
+o/wjLCfzogyvQhLZZC81LLtACVNkkfhZqES+Bb01cO+/Aoh+GSs0/xn1Qz3kazH1\r
+/IA41Cod+EiE5Wmdx+3D6fK/fkM0NkUcXaE4S6x/AfPYfoeOkKNTBmuA5FjK4N/I\r
+vRiHJAaneUZ6O7wd5xuCe6tgOfXZuNcubdC5p2i9pB+3n03SbzLadBF/ezE8vG2z\r
+srwI37UuPPx/CH1OTtBN8SOab3dbPuuyfI77kbgzhOaPsIsUSiAQutTojEX0p8VE\r
+4rmuv8lfP2gRawO+if7WQUViRSYJrBsLK4U7kl+uEaCKa3uW1rRAXXUtwJfYjwVU\r
+XJwY+wA3pHOibfiFaHcGV0XRMkOQ4XnP8PMBI6NVy9rEjwjuD6wzcpHALYpJcAkj\r
+ZRS7f4VOe+/2kmh3Ot/7\r
+=YbTe\r
+-----END PGP SIGNATURE-----\r
+\r
+--5PFZVUeDPxlnBcQp--\r