From 16ee7ef21265fe405f6629e609ce093dcaf8d808 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 2 Mar 2012 13:11:41 +1900 Subject: [PATCH] Re: [PATCH] Actually close the xapian database in notmuch_database_close --- 15/c10187874ae25090de6efa22efeec482244efa | 136 ++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 15/c10187874ae25090de6efa22efeec482244efa diff --git a/15/c10187874ae25090de6efa22efeec482244efa b/15/c10187874ae25090de6efa22efeec482244efa new file mode 100644 index 000000000..0948c2eb5 --- /dev/null +++ b/15/c10187874ae25090de6efa22efeec482244efa @@ -0,0 +1,136 @@ +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 ACCF2431FAF + for ; Thu, 1 Mar 2012 10:11:51 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 kLYa-Tvqif06 for ; + Thu, 1 Mar 2012 10:11:48 -0800 (PST) +Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU + [18.7.68.37]) + by olra.theworths.org (Postfix) with ESMTP id 03FB9431FAE + for ; Thu, 1 Mar 2012 10:11:47 -0800 (PST) +X-AuditID: 12074425-b7f4a6d0000008e0-d3-4f4fbbe36361 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP + id D3.66.02272.3EBBF4F4; Thu, 1 Mar 2012 13:11:47 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q21IBhnl025827; + Thu, 1 Mar 2012 13:11:44 -0500 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q21IBf9R025475 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 1 Mar 2012 13:11:43 -0500 (EST) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1S3ATd-0001PR-JP; Thu, 01 Mar 2012 13:11:41 -0500 +Date: Thu, 1 Mar 2012 13:11:41 -0500 +From: Austin Clements +To: Justus Winter <4winter@informatik.uni-hamburg.de> +Subject: Re: [PATCH] Actually close the xapian database in + notmuch_database_close +Message-ID: <20120301181141.GA4797@mit.edu> +References: + <1330507157-22859-1-git-send-email-4winter@informatik.uni-hamburg.de> + <1330507157-22859-2-git-send-email-4winter@informatik.uni-hamburg.de> + <20120229154833.GB772@mit.edu> <20120229211922.GQ24964@survex.com> + <20120229221754.GD772@mit.edu> + <20120301065930.5076.72748@thinkbox.jade-hamburg.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20120301065930.5076.72748@thinkbox.jade-hamburg.de> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42IR4hRV1n2829/foPOGsMXs1h9MFtdvzmS2 + uL/8PasDs8fE86fZPJ6tusXssW7nH/YA5igum5TUnMyy1CJ9uwSujKVTnrEXdIhU/F5+mamB + 8Qd/FyMnh4SAicTys7PZIWwxiQv31rN1MXJxCAnsY5S4feIrC4SznlFi9vwHzBDOCSaJi2/n + sEM4Sxglrh7uZQbpZxFQkXjWOQHMZhPQkNi2fzkjiC0iYCqx4cEDsB3MApYSV2dMYwWxhQWC + JU5NPs0GYvMKaEscnn+XBcQWEtjBJLHvTSREXFDi5MwnLBC9WhI3/r1k6mLkALKlJZb/4wAJ + cwo4SrRumghWIgp0wpST29gmMArNQtI9C0n3LITuBYzMqxhlU3KrdHMTM3OKU5N1i5MT8/JS + i3Qt9HIzS/RSU0o3MYKCnd1FdQfjhENKhxgFOBiVeHi9Jvr7C7EmlhVX5h5ilORgUhLlrd8J + FOJLyk+pzEgszogvKs1JLT7EKMHBrCTCK9UPlONNSaysSi3Kh0lJc7AoifNqar3zExJITyxJ + zU5NLUgtgsnKcHAoSfAqAqNaSLAoNT21Ii0zpwQhzcTBCTKcB2i4GkgNb3FBYm5xZjpE/hSj + opQ4ryhIQgAkkVGaB9cLS0avGMWBXhHmNQap4gEmMrjuV0CDmYAGL77sBzK4JBEhJdXAePYu + w4O1ZvPVHy3xyfk3YY1jbhPPw/y7cetOOu2xe1nQt/CJXKWWrssHFz4Gdf/qNe5nGZ+qLVUM + tr6/h3t2UnHG89N3uZ4fme3+bc7ifz/LH50V3MKe8LLrofmDW3pq2+ViZ7//r+NmayMd7HPl + 1ZUXOcE1FxtzAoUZVRwea1cZLlXYVLfzqxJLcUaioRZzUXEiAB8BTUAhAwAA +Cc: Olly Betts , 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: Thu, 01 Mar 2012 18:11:51 -0000 + +Quoth Justus Winter on Mar 01 at 7:59 am: +> Quoting Austin Clements (2012-02-29 23:17:54) +> >Quoth Olly Betts on Feb 29 at 9:19 pm: +> >> On Wed, Feb 29, 2012 at 10:48:33AM -0500, Austin Clements wrote: +> >> > Quoth Justus Winter on Feb 29 at 10:19 am: +> >> > > Formerly the xapian database object was deleted and closed in its +> >> > > destructor once the object was garbage collected. Explicitly call +> >> > > close() so that the database and the associated lock is released +> >> > > immediately. +> >> > +> >> > Interesting. Is this a bug in Xapian? According to the docs, +> >> > ~Database is supposed to close the database (if there are no other +> >> > copies, which there shouldn't be), so this should be redundant with +> >> > the delete notmuch->xapian_db a few lines down, but your experience +> >> > obviously suggests that it isn't and I can't find the code path in +> >> > Xapian that would close it in the destructor. +> >> +> >> Most Xapian API classes (including Database and WritableDatabase) just +> >> hold a reference-counted pointer, and so it's the destructor of the +> >> reference-counted object which closes the database. If "PIMPL" means +> >> anything to you, that's what we have here. +> >> +> >> Some other API classes objects (such as PostingIterator) internally hold +> >> a reference to the database they are using, so calling close() +> >> explicitly is useful if you don't want to have to worry about such +> >> objects still existing and holding onto references which keep the +> >> database open. +> > +> >Makes sense. Justus, could you add a comment to your patch explaining +> >that we explicitly close the database because there may be other +> >objects with references to it that would keep it open? +> +> I thought I did, I'm not a native speaker though, so if you want to +> reword my message be my guest ;) + +Sorry, I meant a code comment. Perhaps something like, + +/* Many Xapian objects (and thus notmuch objects) hold references to + * the database, so merely deleting the database may not suffice to + * close it. Thus, we explicitly close it here. */ + +> >Also, since close could throw an exception, it should get wrapped in a +> >try/catch like flush currently is. +> +> My interpretation of [0] was that Xapian::Database::close() does not +> throw any exceptions. + +Olly mentioned on IRC that it can throw an exception (because, for +example, close calls flush). + +> Cheers, +> Justus +> +> 0: http://xapian.org/docs/apidoc/html/classXapian_1_1Database.html#59f5f8b137723dcaaabdbdccbc0cf1eb -- 2.26.2