Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 48842 invoked from network); 19 Sep 2007 22:55:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Sep 2007 22:55:20 -0000 Received: (qmail 15151 invoked by uid 500); 19 Sep 2007 22:55:08 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 14118 invoked by uid 500); 19 Sep 2007 22:55:06 -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 14107 invoked by uid 99); 19 Sep 2007 22:55:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Sep 2007 15:55:05 -0700 X-ASF-Spam-Status: No, hits=0.9 required=10.0 tests=SPF_PASS,URIBL_RHS_DOB X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [130.107.64.135] (HELO Balboa.AI.SRI.COM) (130.107.64.135) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Sep 2007 22:55:03 +0000 Received: from Balboa.AI.SRI.COM (localhost [127.0.0.1]) by Balboa.AI.SRI.COM (8.11.7p2+Sun/8.10.1) with SMTP id l8JMsh013468 for ; Wed, 19 Sep 2007 15:54:43 -0700 (PDT) Received: from Salt.AI.SRI.COM ([130.107.65.211]) by Balboa.AI.SRI.COM (SMSSMTP 4.1.9.35) with SMTP id M2007091915544200743 for ; Wed, 19 Sep 2007 15:54:42 -0700 Received: from localhost.ai.sri.com ([127.0.0.1] helo=[130.107.65.150] ident=root) by Salt.AI.SRI.COM with asmtp (Exim 3.35 #1 (Debian)) id 1IY8RO-0001E4-00 for ; Wed, 19 Sep 2007 15:54:42 -0700 Message-ID: <46F1A8B5.1030401@ai.sri.com> Date: Wed, 19 Sep 2007 15:54:45 -0700 From: Jay Yu User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Re: thread safe shared IndexSearcher References: <46F15AE1.5040400@ai.sri.com> <46F171FB.2080306@ai.sri.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Mark, After reading the implementation of LuceneIndexAccessor.getSearcher(), I realized that the method is synchronized and wait for writingDirector to be released. That means if we getSearcher for each query in each thread, there might be a contention and performance hit. In fact, even the method of release(searcher) is costly. On the other hand, if multiple threads share share one searcher then it'd defeat the purpose of using LuceneIndexAccessor. Do I miss sth here? What's your suggested use case for LuceneIndexAccessor? Thanks! Jay Mark Miller wrote: > Ill respond a point at a time: > > 1. > > ****************************** Hi Maik, > > So what happens in this case: > > IndexAccessProvider accessProvider = new IndexAccessProvider(directory, > > analyzer); > > LuceneIndexAccessor accessor = new LuceneIndexAccessor(accessProvider); > > accessor.open(); > > IndexWriter writer = accessor.getWriter(); > > // reference to the same instance? > > IndexWriter writer2 = accessor.getWriter(); > > writer.addDocument(....); > > writer2.addDocument(....); > > > > // I didn't release the writer yet > > // will this block? > > IndexReader reader = accessor.getReader(); > > reader.delete(....); > > ************ > > This is not really an issue. First, if you are going to delete with a Reader > you need to call getWritingReader and not getReader. When you do that, the > getWritingReader call will block until writer and writer2 are released. If > you are just adding a couple docs before releasing the writers, this is no > problem because the block will be very short. If you are loading tons of > docs and you want to be able to delete with a Reader in a timely manner, you > should release the writers every now and then (release and re-get the Writer > every 100 docs or something). An interactive index should not hog the > Writer, while something that is just loading a lot could hog the Writer. > This is no different than normal�you cannot delete with a Reader while > adding with a Writer with Lucene. This code just enforces those semantics. > The best solution is to just use a Writer to delete � I never get a > ReadingWriter. > > 2. http://issues.apache.org/bugzilla/show_bug.cgi?id=34995#c3 > > This is no big deal either. I just added another getWriter call that takes a > create Boolean. > > 3. I don't think there is a latest release. This has never gotten much > official attention and is not in the sandbox. I worked straight from the > originally submitted code. > > 4. I will look into getting together some code that I can share. The > multisearcher changes that are need are a couple of one liners really, so at > a minimum I will give you the changes needed. > > > > - Mark > > > > On 9/19/07, Jay Yu wrote: > > Mark, > > > > thanks for sharing your insight and experience about LuceneIndexAccessor! > > I remember seeing some people reporting some issues about it, such as: > > http://www.archivum.info/java-dev@lucene.apache.org/2005-05/msg00114.html > > http://issues.apache.org/bugzilla/show_bug.cgi?id=34995#c3 > > > > Have those issues been resolved? > > > > Where did you get the latest release? It is not in the official Lucene > > sandbox/contrib. > > > > Finally, are you willing to share your extended version to include your > > tweak relating to the MultiSearcher? > > > > Thanks a lot! > > > > Jay > > > > Mark Miller wrote: > >> I use option 3 extensivley and find it very effective. There is a tweak or > >> two required to get it to work right with MultiSearchers, but other than > >> that, the code is great. I have built a lot on top of it. I'm on the list > >> all the time and would be happy to answer any questions you have in > regards > >> to LuceneIndexAccessor. Frankly, I think its overlooked far too much. > > >> - Mark > > > >> On 9/19/07, Jay Yu wrote: > > >>> In a multithread app like web app, a shared IndexSearcher could throw a > >>> AlreadyClosedException when another thread is trying to update the > >>> underlying IndexReader by closing the shared searcher after the index is > >>> updated. Searching over the past discussions on this mailing list, I > >>> found several approaches to solve the problem. > >>> 1. use solr > >>> 2. use DelayCloseIndexSearcher > >>> 3. use LuceneIndexAccessor > > > >>> the first one is not feasible for us; some people seemed to have > >>> problems with No. 2 and I do not find a lot of discussions around No.3. > > >>> I wonder if anyone has good experience on No 2 and 3? > >>> Or do I miss other better solutions? > > >>> Thanks for any suggestion/comment! > > >>> Jay > > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > >>> For additional commands, e-mail: java-user-help@lucene.apache.org > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > > For additional commands, e-mail: java-user-help@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org