From: Austin Clements Date: Wed, 29 Feb 2012 22:17:54 +0000 (+1900) Subject: Re: [PATCH] Actually close the xapian database in notmuch_database_close X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=125bdc13d2b1b8fa5eeaf581a9adc103f7613a1d;p=notmuch-archives.git Re: [PATCH] Actually close the xapian database in notmuch_database_close --- diff --git a/aa/0e55318507ea2f1bb4790dbcbe16fda5370347 b/aa/0e55318507ea2f1bb4790dbcbe16fda5370347 new file mode 100644 index 000000000..03d3b4b76 --- /dev/null +++ b/aa/0e55318507ea2f1bb4790dbcbe16fda5370347 @@ -0,0 +1,112 @@ +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 C69FB431FAE + for ; Wed, 29 Feb 2012 14:18:01 -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 lgBaSWQHLk8X for ; + Wed, 29 Feb 2012 14:18:01 -0800 (PST) +Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU + [18.9.25.14]) + by olra.theworths.org (Postfix) with ESMTP id 21B99431E64 + for ; Wed, 29 Feb 2012 14:18:01 -0800 (PST) +X-AuditID: 1209190e-b7f7c6d0000008c3-49-4f4ea4161541 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id DD.0B.02243.614AE4F4; Wed, 29 Feb 2012 17:17:58 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q1TMHulA025287; + Wed, 29 Feb 2012 17:17:57 -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 q1TMHsKv004790 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Wed, 29 Feb 2012 17:17:55 -0500 (EST) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1S2rqM-0002Zt-EE; Wed, 29 Feb 2012 17:17:54 -0500 +Date: Wed, 29 Feb 2012 17:17:54 -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: <20120229221754.GD772@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> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20120229211922.GQ24964@survex.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42IRYrdT1xVb4udv0LZXwGJ26w8mi+s3ZzJb + 3F/+ntWB2WPi+dNsHs9W3WL2WLfzD3sAcxSXTUpqTmZZapG+XQJXxszVK1gKpvNWTP19iqmB + 8SBXFyMnh4SAicSvk+/YIGwxiQv31gPZXBxCAvsYJeZdWMEI4WxglOheOZEVwjnJJDF9+1ko + ZwmjxP4rq8H6WQRUJS4svMkIYrMJaEhs278czBYRMJXY8OABO4jNLGApcXXGNFYQW1ggWOLU + 5NNgvbwCWhLnv60DqxESeMAocfkMJ0RcUOLkzCcsEL1aEjf+vWTqYuQAsqUllv/jAAlzChhI + PNmwB6xVVEBFYsrJbWwTGIVmIemehaR7FkL3AkbmVYyyKblVurmJmTnFqcm6xcmJeXmpRbrG + ermZJXqpKaWbGEHBzinJt4Px60GlQ4wCHIxKPLxMhX7+QqyJZcWVuYcYJTmYlER5TecDhfiS + 8lMqMxKLM+KLSnNSiw8xSnAwK4nwfuwGyvGmJFZWpRblw6SkOViUxHnVtN75CQmkJ5akZqem + FqQWwWRlODiUJHh/LwJqFCxKTU+tSMvMKUFIM3FwggznARqutxhkeHFBYm5xZjpE/hSjopQ4 + LydIQgAkkVGaB9cLS0avGMWBXhGGaOcBJjK47ldAg5mABgdweoMMLklESEk1MLqqfSutZ+tn + Wvxv/R853r9VC6OkxNcpVu4+zK5/La5y1Xxr16n9W35r7XiexvWPa+fKmam2f+Kl/30M4D2h + d3ji3CKeCTaOGz9tTZv9KZRrv05r979VWx0LV1wN3lVvHla/cuIFZZ07U1PvMh0x8/9ldtWo + 85zQbwf2lPLUtfOfTefX3HZn/18lluKMREMt5qLiRAA1lO7IIQMAAA== +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: Wed, 29 Feb 2012 22:18:01 -0000 + +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? + +Also, since close could throw an exception, it should get wrapped in a +try/catch like flush currently is.