Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D71039D2E for ; Wed, 8 Feb 2012 12:49:29 +0000 (UTC) Received: (qmail 69164 invoked by uid 500); 8 Feb 2012 12:49:27 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 69097 invoked by uid 500); 8 Feb 2012 12:49:26 -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 69089 invoked by uid 99); 8 Feb 2012 12:49:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Feb 2012 12:49:26 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of zhoucheng2008@gmail.com designates 209.85.220.176 as permitted sender) Received: from [209.85.220.176] (HELO mail-vx0-f176.google.com) (209.85.220.176) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Feb 2012 12:49:18 +0000 Received: by vcbfl13 with SMTP id fl13so398932vcb.35 for ; Wed, 08 Feb 2012 04:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=WA8+4LK9IaEEIOuxGJ4dnF9oJ3k7qAry1JsCLWuKEB0=; b=o7m5ruH9h0pBE9lMrXzJ0QdCV9/hjxrvNNH6cxwj6igYtxi3WpbfsMQXbS+D0IqlF4 KseIVqbUtYysjwXJSJzzfsSuvzHcP8316lmOQwbIiexZj9k4V7+yRoqBvehd5FHS3xKp Hb8X+LY3URrdtmRL4jiPKj0WdiQz6IO70QISE= MIME-Version: 1.0 Received: by 10.52.23.97 with SMTP id l1mr12221279vdf.0.1328705337318; Wed, 08 Feb 2012 04:48:57 -0800 (PST) Received: by 10.52.69.170 with HTTP; Wed, 8 Feb 2012 04:48:57 -0800 (PST) In-Reply-To: References: Date: Wed, 8 Feb 2012 20:48:57 +0800 Message-ID: Subject: Re: NRTManager and AlreadyClosedException From: Cheng To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=20cf3079bc64a45bf904b873512a X-Virus-Checked: Checked by ClamAV on apache.org --20cf3079bc64a45bf904b873512a Content-Type: text/plain; charset=ISO-8859-1 I use it exactly the same way. So there must be other reason causing the problem. On Wed, Feb 8, 2012 at 8:21 PM, Ian Lea wrote: > Releasing a searcher is not the same as closing the searcher manager, > if that is what you mean. > > The searcher should indeed be released, but once only for each > acquire(). Your searching threads should have code like that shown in > the SearcherManager javadocs. > > IndexSearcher s = manager.acquire(); > try { > // Do searching, doc retrieval, etc. with s > } finally { > manager.release(s); > } > // Do not use s after this! > s = null; > > -- > Ian. > > > On Wed, Feb 8, 2012 at 12:09 PM, Cheng wrote: > > You are right. There is a method by which I do searching. At the end of > the > > method, I release the index searcher (not the searchermanager). > > > > Since this method is called by multiple threads. So I think the index > > searcher will be released multiple times. > > > > First, I wonder if releasing searcher is same as releasing the searcher > > manager. > > > > Second, as said in Mike's blog, the searcher should be released, which > has > > seemingly caused the problem. What are my alternatives here to avoid it? > > > > Thanks > > > > > > > > On Wed, Feb 8, 2012 at 7:51 PM, Ian Lea wrote: > > > >> Are you closing the SearcherManager? Calling release() multiple times? > >> > >> From the exception message the first sounds most likely. > >> > >> > >> -- > >> Ian. > >> > >> > >> On Wed, Feb 8, 2012 at 5:20 AM, Cheng wrote: > >> > Hi, > >> > > >> > I am using NRTManager and NRTManagerReopenThread. Though I don't close > >> > either writer or the reopen thread, I receive AlreadyClosedException > as > >> > follow. > >> > > >> > My initiating NRTManager and NRTManagerReopenThread are: > >> > > >> > FSDirectory indexDir = new NIOFSDirectory(new File( > >> > indexFolder)); > >> > > >> > IndexWriterConfig iwConfig = new IndexWriterConfig( > >> > version, new LimitTokenCountAnalyzer( > >> > StandardAnalyzer, maxTokenNum)); > >> > > >> > iw = new IndexWriter(indexDir, iwConfig); > >> > > >> > nrtm = new NRTManager(iw, null); > >> > > >> > ropt = new NRTManagerReopenThread(nrtm, > >> > targetMaxStaleSec, > >> > targetMinStaleSec); > >> > > >> > ropt.setName("Reopen Thread"); > >> > ropt.setPriority(Math.min(Thread.currentThread().getPriority() + 2, > >> > Thread.MAX_PRIORITY)); > >> > ropt.setDaemon(true); > >> > ropt.start(); > >> > > >> > > >> > Where may the searchermanager fall out? > >> > > >> > > >> > > >> > org.apache.lucene.store.AlreadyClosedException: this SearcherManager > is > >> > closed77 > >> > at > >> > > >> > org.apache.lucene.search.SearcherManager.acquire(SearcherManager.java:235) > >> > at > >> com.yyt.core.er.lucene.YYTLuceneImpl.codeIndexed(YYTLuceneImpl.java:138) > >> > at com.yyt.core.er.main.copy.SingleCodeER.run(SingleCodeER.java:50) > >> > at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) > >> > at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) > >> > >> --------------------------------------------------------------------- > >> 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 > > --20cf3079bc64a45bf904b873512a--