Re: [PATCH] Actually close the xapian database in notmuch_database_close
[notmuch-archives.git] / aa / 0e55318507ea2f1bb4790dbcbe16fda5370347
1 Return-Path: <amdragon@mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id C69FB431FAE\r
6         for <notmuch@notmuchmail.org>; Wed, 29 Feb 2012 14:18:01 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id lgBaSWQHLk8X for <notmuch@notmuchmail.org>;\r
16         Wed, 29 Feb 2012 14:18:01 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id 21B99431E64\r
20         for <notmuch@notmuchmail.org>; Wed, 29 Feb 2012 14:18:01 -0800 (PST)\r
21 X-AuditID: 1209190e-b7f7c6d0000008c3-49-4f4ea4161541\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id DD.0B.02243.614AE4F4; Wed, 29 Feb 2012 17:17:58 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q1TMHulA025287; \r
27         Wed, 29 Feb 2012 17:17:57 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q1TMHsKv004790\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Wed, 29 Feb 2012 17:17:55 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1S2rqM-0002Zt-EE; Wed, 29 Feb 2012 17:17:54 -0500\r
37 Date: Wed, 29 Feb 2012 17:17:54 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Justus Winter <4winter@informatik.uni-hamburg.de>\r
40 Subject: Re: [PATCH] Actually close the xapian database in\r
41         notmuch_database_close\r
42 Message-ID: <20120229221754.GD772@mit.edu>\r
43 References:\r
44  <1330507157-22859-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
45         <1330507157-22859-2-git-send-email-4winter@informatik.uni-hamburg.de>\r
46         <20120229154833.GB772@mit.edu> <20120229211922.GQ24964@survex.com>\r
47 MIME-Version: 1.0\r
48 Content-Type: text/plain; charset=us-ascii\r
49 Content-Disposition: inline\r
50 In-Reply-To: <20120229211922.GQ24964@survex.com>\r
51 User-Agent: Mutt/1.5.21 (2010-09-15)\r
52 X-Brightmail-Tracker:\r
53  H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42IRYrdT1xVb4udv0LZXwGJ26w8mi+s3ZzJb\r
54         3F/+ntWB2WPi+dNsHs9W3WL2WLfzD3sAcxSXTUpqTmZZapG+XQJXxszVK1gKpvNWTP19iqmB\r
55         8SBXFyMnh4SAicSvk+/YIGwxiQv31gPZXBxCAvsYJeZdWMEI4WxglOheOZEVwjnJJDF9+1ko\r
56         ZwmjxP4rq8H6WQRUJS4svMkIYrMJaEhs278czBYRMJXY8OABO4jNLGApcXXGNFYQW1ggWOLU\r
57         5NNgvbwCWhLnv60DqxESeMAocfkMJ0RcUOLkzCcsEL1aEjf+vWTqYuQAsqUllv/jAAlzChhI\r
58         PNmwB6xVVEBFYsrJbWwTGIVmIemehaR7FkL3AkbmVYyyKblVurmJmTnFqcm6xcmJeXmpRbrG\r
59         ermZJXqpKaWbGEHBzinJt4Px60GlQ4wCHIxKPLxMhX7+QqyJZcWVuYcYJTmYlER5TecDhfiS\r
60         8lMqMxKLM+KLSnNSiw8xSnAwK4nwfuwGyvGmJFZWpRblw6SkOViUxHnVtN75CQmkJ5akZqem\r
61         FqQWwWRlODiUJHh/LwJqFCxKTU+tSMvMKUFIM3FwggznARqutxhkeHFBYm5xZjpE/hSjopQ4\r
62         LydIQgAkkVGaB9cLS0avGMWBXhGGaOcBJjK47ldAg5mABgdweoMMLklESEk1MLqqfSutZ+tn\r
63         Wvxv/R853r9VC6OkxNcpVu4+zK5/La5y1Xxr16n9W35r7XiexvWPa+fKmam2f+Kl/30M4D2h\r
64         d3ji3CKeCTaOGz9tTZv9KZRrv05r979VWx0LV1wN3lVvHla/cuIFZZ07U1PvMh0x8/9ldtWo\r
65         85zQbwf2lPLUtfOfTefX3HZn/18lluKMREMt5qLiRAA1lO7IIQMAAA==\r
66 Cc: Olly Betts <olly@survex.com>, notmuch@notmuchmail.org\r
67 X-BeenThere: notmuch@notmuchmail.org\r
68 X-Mailman-Version: 2.1.13\r
69 Precedence: list\r
70 List-Id: "Use and development of the notmuch mail system."\r
71         <notmuch.notmuchmail.org>\r
72 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
75 List-Post: <mailto:notmuch@notmuchmail.org>\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
77 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
78         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
79 X-List-Received-Date: Wed, 29 Feb 2012 22:18:01 -0000\r
80 \r
81 Quoth Olly Betts on Feb 29 at  9:19 pm:\r
82 > On Wed, Feb 29, 2012 at 10:48:33AM -0500, Austin Clements wrote:\r
83 > > Quoth Justus Winter on Feb 29 at 10:19 am:\r
84 > > > Formerly the xapian database object was deleted and closed in its\r
85 > > > destructor once the object was garbage collected. Explicitly call\r
86 > > > close() so that the database and the associated lock is released\r
87 > > > immediately.\r
88 > > \r
89 > > Interesting.  Is this a bug in Xapian?  According to the docs,\r
90 > > ~Database is supposed to close the database (if there are no other\r
91 > > copies, which there shouldn't be), so this should be redundant with\r
92 > > the delete notmuch->xapian_db a few lines down, but your experience\r
93 > > obviously suggests that it isn't and I can't find the code path in\r
94 > > Xapian that would close it in the destructor.\r
95\r
96 > Most Xapian API classes (including Database and WritableDatabase) just\r
97 > hold a reference-counted pointer, and so it's the destructor of the\r
98 > reference-counted object which closes the database.  If "PIMPL" means\r
99 > anything to you, that's what we have here.\r
100\r
101 > Some other API classes objects (such as PostingIterator) internally hold\r
102 > a reference to the database they are using, so calling close()\r
103 > explicitly is useful if you don't want to have to worry about such\r
104 > objects still existing and holding onto references which keep the\r
105 > database open.\r
106 \r
107 Makes sense.  Justus, could you add a comment to your patch explaining\r
108 that we explicitly close the database because there may be other\r
109 objects with references to it that would keep it open?\r
110 \r
111 Also, since close could throw an exception, it should get wrapped in a\r
112 try/catch like flush currently is.\r