Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 1505 invoked from network); 3 Nov 2009 10:35:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Nov 2009 10:35:08 -0000 Received: (qmail 3329 invoked by uid 500); 3 Nov 2009 10:35:05 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 3231 invoked by uid 500); 3 Nov 2009 10:35:05 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 3221 invoked by uid 99); 3 Nov 2009 10:35:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 10:35:05 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.211.183] (HELO mail-yw0-f183.google.com) (209.85.211.183) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 10:35:02 +0000 Received: by ywh13 with SMTP id 13so6221213ywh.29 for ; Tue, 03 Nov 2009 02:34:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.150.61.10 with SMTP id j10mr10066215yba.282.1257244480689; Tue, 03 Nov 2009 02:34:40 -0800 (PST) In-Reply-To: <27ff0e30911030221j43aa6353lf73276e6fe1b09ba@mail.gmail.com> References: <27ff0e30910280345y815d2d9k91f986fe9e0eb5de@mail.gmail.com> <867513fe0910280349j5585b568s72467419d8d8ead3@mail.gmail.com> <27ff0e30910280417i5dcf8faeid74bee940df86aa8@mail.gmail.com> <9ac0c6aa0910280447s5fc7fb21q154259209c379fb1@mail.gmail.com> <27ff0e30911030124r1d8ea101u61f5ffc29013da1f@mail.gmail.com> <9ac0c6aa0911030150t6db98646ubee210ebeda425b3@mail.gmail.com> <27ff0e30911030221j43aa6353lf73276e6fe1b09ba@mail.gmail.com> Date: Tue, 3 Nov 2009 05:34:40 -0500 Message-ID: <9ac0c6aa0911030234xd4d75aia429c84216b671f3@mail.gmail.com> Subject: Re: deleteDocuments() does not work From: Michael McCandless To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Nov 3, 2009 at 5:21 AM, Dinh wrote: > Hi Michael, > >> Does that mean you no longer see the original problem (changes not >> being reflected)? > > Yes. The deleted documents do not appear in search results any more. I am > not sure that if they are flushed to disk > at that time yet but at least there is a sign that they are "deleted". I > have stopped and started the servlet engine to ensure > that deleted document is no longer there. I think that Lucene requires th= e > previously opened IndexReader be closed before changes > can be reflected. Hmmm: closing the old IndexReader shouldn't be necessary in order for a newly opened IndexReader to see changes. Something else must've been fixed at the same time (and I'm glad you got it fixed!). >> You get the entrySet from the Map, you then iterate over its >> Map.Entry, then you replace in your original map some entries (the >> ones that are opened). =A0So, you are modifying a Java collection while >> iterating over elements from its Set view... I just don't know if >> that's safe (anyone?) > > I am a bit skeptical about my approach. Because the IndexSearchers can be > used by other threads (requests) at the same time. That's definitely a problem. [Shameless plug:] the next rev of Lucene in Action has a class (SearcherManager) which gracefully handles reopening in the presence of multiple threads still using the old IndexSearcher. It uses the reference counting already builtin to IndexReader to keep track of how many queries are still using the old reader. > Also, because reload() is synchronized so there is a single thread access= ing > it only. So I think that there will be no ConcurrentModificationException Right, but your one thread is both iterating over and modifying the Map, at once. That's what concerns me (but it could very well be safe). >> Would be good to instrument/debug and confirm >> that the precise IndexReader that's searching the Directory your >> IndexWriter just committed to, is in fact reopened. > > Do you think that these code are enough > > IndexReader oldReader =3D searcher.getIndexReader(); > IndexReader newReader =3D oldReader.reopen(true); > > if (newReader !=3D oldReader) { > =A0 =A0oldReader.close(); > =A0 =A0searcher.close(); > =A0 =A0searchers.put(entry.getKey(), new IndexSearcher(newReader)); > } Yes, this code looks fine! Mike --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org