Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 25693 invoked from network); 18 Oct 2009 13:11:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Oct 2009 13:11:11 -0000 Received: (qmail 21463 invoked by uid 500); 18 Oct 2009 13:11:09 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 21385 invoked by uid 500); 18 Oct 2009 13:11:09 -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 21375 invoked by uid 99); 18 Oct 2009 13:11:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Oct 2009 13:11:09 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.217.219] (HELO mail-gx0-f219.google.com) (209.85.217.219) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Oct 2009 13:11:00 +0000 Received: by gxk19 with SMTP id 19so3617420gxk.5 for ; Sun, 18 Oct 2009 06:10:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.233.2 with SMTP id f2mr6045472ybh.259.1255871438070; Sun, 18 Oct 2009 06:10:38 -0700 (PDT) In-Reply-To: <4ACEF8B9.2030202@stimulussoft.com> References: <4ACEF8B9.2030202@stimulussoft.com> Date: Sun, 18 Oct 2009 09:10:38 -0400 Message-ID: <9ac0c6aa0910180610n77832f52x45c4e0befc6fe5c4@mail.gmail.com> Subject: Re: Index.close() infinite TIME_WAITING From: Michael McCandless To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Jamie did you ever get to the bottom of this? Can you reduce this code down to a smaller example that shows the hang? Also, can you post a thread stack dump when you hit the hang? Is it possible you are adding documents from one thread while calling IndexWriter.close in another? I see you have "catch AlreadyClosedException" when adding docs -- do you ever actually hit that? Mike On Fri, Oct 9, 2009 at 4:47 AM, Jamie Band wrote: > Hi Michael > > Thanks for your help. Here are the stacks: > > index processor [TIME_WAITING] CPU time: 33:01 > java.lang.Object.wait(long) > org.apache.lucene.index.IndexWriter.doWait() > org.apache.lucene.index.IndexWriter.shouldClose() > org.apache.lucene.index.IndexWriter.close(boolean) > org.apache.lucene.index.IndexWriter.close() > com.stimulus.archiva.index.VolumeIndex.closeIndex() > com.stimulus.archiva.index.VolumeIndex$IndexProcessor.run() > > The source code to our indexer is attached. As you can see, documents are > added to a blocking queue. The index processor thread takes it out of the > queue and processes it. After about 60k documents IndexWriter's close met= hod > enters TIME_WAITING indefinitely. It there any workaround to this problem= ? > > > package com.stimulus.archiva.index; > > import java.io.File; > import java.io.IOException; > import java.io.PrintStream; > import javax.mail.MessagingException; > import org.apache.commons.logging.*; > import org.apache.lucene.document.Document; > import org.apache.lucene.index.*; > import org.apache.lucene.store.FSDirectory; > import com.stimulus.archiva.domain.Config; > import com.stimulus.archiva.domain.Email; > import com.stimulus.archiva.domain.EmailID; > import com.stimulus.archiva.domain.Indexer; > import com.stimulus.archiva.domain.Volume; > import com.stimulus.archiva.exception.*; > import com.stimulus.archiva.language.AnalyzerFactory; > import com.stimulus.archiva.search.*; > import java.util.*; > import java.util.concurrent.ExecutorService; > import java.util.concurrent.Executors; > import java.util.concurrent.ScheduledExecutorService; > import java.util.concurrent.ScheduledFuture; > import java.util.concurrent.TimeUnit; > import org.apache.lucene.store.LockObtainFailedException; > import org.apache.lucene.store.AlreadyClosedException; > import java.util.concurrent.locks.ReentrantLock; > import java.util.concurrent.*; > > public class VolumeIndex extends Thread { > =A0 =A0 =A0 =A0 =A0protected ArrayBlockingQueue queue; > =A0 =A0 =A0 =A0protected static final Log logger =3D > LogFactory.getLog(VolumeIndex.class.getName()); > =A0 =A0 =A0 =A0 =A0 IndexWriter writer =3D null; > =A0 =A0 =A0 =A0 =A0 Volume volume; > =A0 =A0 =A0 =A0 =A0 protected static ScheduledExecutorService scheduler; > =A0 =A0 =A0 =A0protected static ScheduledFuture scheduledTask; > =A0 =A0 =A0 =A0protected static IndexInfo EXIT_REQ =3D new IndexInfo(null= ); > =A0 =A0 =A0 =A0ReentrantLock indexLock =3D new ReentrantLock(); > =A0 =A0 =A0 =A0ArchivaAnalyzer analyzer =A0 =A0 =3D new ArchivaAnalyzer()= ; > =A0 =A0 =A0 =A0Indexer indexer =3D null; > =A0 =A0 =A0 =A0File indexLogFile; > =A0 =A0 =A0 =A0PrintStream indexLogOut; > =A0 =A0 =A0 =A0IndexProcessor indexProcessor; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 public VolumeIndex(Indexe= r indexer, Volume volume) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("creating new volume index {"+vo= lume+"}"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 this.volume =3D volume; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 this.indexer =3D indexer; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 this.queue =3D new > ArrayBlockingQueue(Config.getConfig().getIndex().getIndexBackl= og()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexLogFile =3D getIndexLogFile(volu= me); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (indexLogFile!=3Dnull) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (indexLogFile.length()>104= 85760) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexLogFile.delete()= ; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexLogOut =3D new PrintStre= am(indexLogFile); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("set index log file path > {path=3D'"+indexLogFile.getCanonicalPath()+"'}"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.error("failed to open index lo= g > file:"+e.getMessage(),e); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 startup(); > =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 protected File getIndexLogFile(Volume volume)= { > =A0 =A0 =A0 =A0 =A0 =A0 =A0try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 String indexpath =3D volume.getIndexP= ath(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int lio =3D indexpath.lastIndexOf(Fil= e.separator)+1; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 String logfilepath =3D > indexpath.substring(lio,indexpath.length()-1); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logfilepath +=3D ".log"; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logfilepath =3D "index_"+logfilepath; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logfilepath =3D > Config.getFileSystem().getLogPath()+File.separator+logfilepath; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return new File(logfilepath); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.error("failed to open index lo= g > file:"+e.getMessage(),e); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return null; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0public void deleteMessages(List id= s) throws > MessageSearchException { > =A0 =A0 =A0 =A0 =A0 =A0 if (ids =3D=3D null) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new MessageSearchException("ass= ertion failure: null > ids",logger); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Term[] terms =3D new Term= [ids.size()]; > =A0 =A0 =A0 =A0 =A0 =A0 int c =3D 0; > =A0 =A0 =A0 =A0 =A0 =A0 StringBuffer deleteInfo =3D new StringBuffer(); > =A0 =A0 =A0 =A0 =A0 =A0 for (String id : ids) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 terms[c++] =3D new Term("uid",id); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 deleteInfo.append(id); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 deleteInfo.append(","); > =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 String deleteStr =3D dele= teInfo.toString(); > =A0 =A0 =A0 =A0 =A0 =A0 if (deleteStr.length()>0 && > deleteStr.charAt(deleteStr.length()-1)=3D=3D',') > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 deleteStr =3D deleteStr.substring(0,delet= eStr.length()-1); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("delete mess= ages {'"+deleteInfo+"'}"); > =A0 =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexLock.lock(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 openIndex(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer.deleteDocuments(terms); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer.expungeDeletes(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new MessageSearchException(= "failed to delete email > from index.",e,logger); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } finally { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 } finally { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 closeIndex(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexLock.unlock(); > =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 protected void openIndex() throws MessageSear= chException { > =A0 =A0 =A0 =A0 =A0 =A0Exception lastError =3D null; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (writer=3D=3Dnull) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("openIndex() index will be opene= d. it is > currently closed."); > =A0 =A0 =A0 =A0 =A0 } else { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("openIndex() did not bother open= ing index. it is > already open."); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 logger.debug("opening index for write {"+volume+"}"); > =A0 =A0 =A0 =A0 =A0 indexer.prepareIndex(volume); > =A0 =A0 =A0 =A0 =A0 logger.debug("opening search index for write > {indexpath=3D'"+volume.getIndexPath()+"'}"); > =A0 =A0 =A0 =A0 =A0 boolean writelock; > =A0 =A0 =A0 =A0 =A0 int attempt =3D 0; > =A0 =A0 =A0 =A0 =A0 int maxattempt =3D 10; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if > (Config.getConfig().getIndex().getMultipleIndexProcesses()) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 maxattempt =3D 10000; > =A0 =A0 =A0 =A0 =A0 =A0} else { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 maxattempt =3D 10; > =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 do { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 writelock =3D false; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FSDirectory fsDirectory =3D > FSDirectory.getDirectory(volume.getIndexPath()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int maxIndexChars =3D > Config.getConfig().getIndex().getMaxIndexPerFieldChars(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer =3D new IndexWriter(fs= Directory,analyzer,new > IndexWriter.MaxFieldLength(maxIndexChars)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (logger.isDebugEnabled() &= & indexLogOut!=3Dnull) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer.setInfoStream(= indexLogOut); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (LockObtainFailedException lobfe) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("write lock on i= ndex. will reopen in > 50ms."); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try { Thread.sleep(50); } cat= ch (Exception e) {} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 attempt++; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writelock =3D true; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (CorruptIndexException cie) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new MessageSearchException("ind= ex appears to be > corrupt. please reindex the active volume."+cie.getMessage(),logger); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (IOException io) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new MessageSearchException("fai= led to write document > to index:"+io.getMessage(),logger); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0} while (writelock && attempt =A0 =A0 =A0 =A0 =A0if (attempt>=3D10000) > =A0 =A0 =A0 =A0 =A0 =A0throw new MessageSearchException("failed to open i= ndex writer > {location=3D'"+volume.getIndexPath()+"'}",lastError,logger); > =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 public void indexMessage(Email message) throws > MessageSearchException =A0{ > =A0 =A0 =A0 =A0 =A0 logger.debug("index message {"+message+"}"); > =A0 =A0 =A0 =A0 =A0 long s =3D (new Date()).getTime(); > =A0 =A0 =A0 =A0 =A0 if (message =3D=3D null) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new MessageSearchException("assertion f= ailure: null > message",logger); > =A0 =A0 =A0 =A0 =A0 Document doc =3D new Document(); > =A0 =A0 =A0 =A0 =A0 IndexInfo indexInfo =3D new IndexInfo(doc); > =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0DocumentIndex docIndex =3D new DocumentIndex(i= ndexer); > =A0 =A0 =A0 =A0 =A0 =A0 =A0String language =3D doc.get("lang"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0if (language=3D=3Dnull) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0language =3D indexer.getIndexLanguage(= ); > =A0 =A0 =A0 =A0 =A0 =A0 =A0docIndex.write(message,doc,indexInfo); > =A0 =A0 =A0 =A0 =A0 =A0 =A0queue.put(indexInfo); > =A0 =A0 =A0 =A0 =A0 =A0 =A0logger.debug("message indexed successfully > {"+message+",language=3D'"+language+"'}"); > =A0 =A0 =A0 =A0 =A0 } catch (MessagingException me) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0throw new MessageSearchException("failed to de= code message > during indexing",me,logger, ChainedException.Level.DEBUG); > =A0 =A0 =A0 =A0 =A0 } catch (IOException me) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new MessageSearchException("failed to i= ndex > message"+me.getMessage()+" {"+message+"}",me,logger, > ChainedException.Level.DEBUG); > =A0 =A0 =A0 =A0 =A0 } catch (ExtractionException ee) > =A0 =A0 =A0 =A0 =A0 { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 // we will want to continue indexing > =A0 =A0 =A0 =A0 =A0 =A0 =A0//throw new MessageSearchException("failed to = decode > attachments in message {"+message+"}",ee,logger, > ChainedException.Level.DEBUG); > =A0 =A0 =A0 =A0 =A0 } catch (AlreadyClosedException ace) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexMessage(message); > =A0 =A0 =A0 =A0 =A0 } catch (Throwable e) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new MessageSearchException("failed to i= ndex > message:"+e.getMessage(),e,logger, ChainedException.Level.DEBUG); > =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 logger.debug("indexing message end {"+message+"}"); > =A0 =A0 =A0 =A0 =A0 long e =3D (new Date()).getTime(); > =A0 =A0 =A0 =A0 =A0 logger.debug("indexing time {time=3D'"+(e-s)+"'}"); > =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 public class IndexProcessor extends Thread { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 public IndexProcessor() { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 setName("index processor"); > =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 public void run() { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 boolean exit =3D false; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 //ExecutorService documentPool; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 // we abandoned pool as it does not seem to o= ffer any major > performance benefit > =A0 =A0 =A0 =A0 =A0 =A0 =A0 IndexInfo indexInfo =3D null; > LinkedList pushbacks =3D new LinkedList(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while (!exit) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t= ry { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int maxIndexDocs =3D > Config.getConfig().getIndex().getMaxSimultaneousDocs(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //documentPool =3D > Executors.newFixedThreadPool(Config.getConfig().getArchiver().getArchiveT= hreads()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexInfo =3D null; =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexInfo =3D > (IndexInfo) queue.take(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (indexInfo=3D=3DEXIT_REQ) = { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("index e= xit req received. exiting"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit =3D true; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 indexLock.lock(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0openIndex(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logger.error("fail= ed to open > index:"+e.getMessage(),e); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (indexInfo=3D=3Dnull) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("index i= nfo is null"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int i =3D 0; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while(indexInfo!=3Dnull && i<= maxIndexDocs) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer.addDoc= ument(indexInfo.getDocument()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (IOException = io) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.error(= "failed to add document to > index:"+io.getMessage(),io); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (AlreadyClose= dException e) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pushbacks.add= (indexInfo); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } finally { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexInfo.cle= anup(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > > //documentPool.execute(new IndexDocument(indexInfo,pushbacks)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0i++; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (i =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0indexInfo = =3D (IndexInfo) queue.poll(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if > (indexInfo=3D=3Dnull) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 logger.debug("index info is null"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if > (indexInfo=3D=3DEXIT_REQ) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0logger.debug("index exit req > received. exiting (2)"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 exit =3D true; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 break; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 for (IndexInfo pushback : > pushbacks) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer.addDoc= ument(pushback.getDocument()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (IOException = io) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.error(= "failed to add document to > index:"+io.getMessage(),io); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (AlreadyClose= dException e) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pushbacks.add= (indexInfo); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } finally { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexInfo.cle= anup(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //documentPool.execut= e(new > IndexDocument(pushback,pushbacks)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 i++; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //documentPool.shutdown(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //documentPool.awaitTerminati= on(30,TimeUnit.MINUTES); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0} catch (Throwable ie) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logger.error("index write > interrupted:"+ie.getMessage()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} finally { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0closeIndex(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexLock.unlock(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 public class IndexDocument extend= s Thread { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IndexInfo= indexInfo =3D null; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 List pushbacks =3D null; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 p= ublic IndexDocument(IndexInfo > indexInfo,List pushbacks) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 this.indexInfo =3D indexInfo; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 this.pushbacks =3D pushbacks; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 setName("index document"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 public vo= id run() { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer.addDocument(in= dexInfo.getDocument()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (IOException io) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.error("failed = to add document to > index:"+io.getMessage(),io); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (AlreadyClosedExcepti= on e) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pushbacks.add(indexIn= fo); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }}; > =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 protected void closeIndex() { > =A0 =A0 =A0 =A0 =A0 =A0try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (writer!=3Dnull) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer.close(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("writer closed")= ; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer =3D null; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} catch (Exception io) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.error("failed to close index > writer:"+io.getMessage(),io); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 public void deleteIndex() throws MessageSearchExcepti= on { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logger.debug("delete index > {indexpath=3D'"+volume.getIndexPath()+"'}"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexLock.lock(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0try { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int maxIndexChars =3D > Config.getConfig().getIndex().getMaxIndexPerFieldChars(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 writer =3D new > IndexWriter(FSDirectory.getDirectory(volume.getIndexPath()),analyzer,true= ,new > IndexWriter.MaxFieldLength(maxIndexChars)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} catch (Exception cie) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logger.error("failed to de= lete index > {index=3D'"+volume.getIndexPath()+"'}",cie); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0MessageIndex.volumeIndexes.remove(= this); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } finally { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 closeIndex(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 indexLock.unlock(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 public void startup() { > =A0 =A0 =A0 =A0 =A0 logger.debug("volumeindex is starting up"); > =A0 =A0 =A0 =A0 =A0 File lockFile =3D new File(volume.getIndexPath()+File= .separatorChar > + "write.lock"); > =A0 =A0 =A0 =A0 =A0 if (lockFile.exists()) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.warn("The server lock file already exi= sts. Either > another indexer is running or the server was not shutdown correctly."); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.warn("If it is the latter, the lock fi= le must be > manually deleted at "+lockFile.getAbsolutePath()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (indexer.getMultipleIndexProcesses()) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("index lock file detecte= d on volumeindex > startup."); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.warn("index lock file detected= . the server was > shutdown incorrectly. automatically deleting lock file."); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.warn("indexer is configured to= deal with only one > indexer process."); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 logger.warn("if you are running more = than one indexer, > your index could be subject to corruption."); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 lockFile.delete(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 indexProcessor =3D new IndexProcessor(); > =A0 =A0 =A0 =A0 =A0 indexProcessor.start(); > =A0 =A0 =A0 =A0 =A0 Runtime.getRuntime().addShutdownHook(this); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 public vo= id shutdown() { > =A0 =A0 =A0 =A0 =A0 =A0 logger.debug("volumeindex is shutting down"); > =A0 =A0 =A0 =A0 =A0 =A0 queue.add(EXIT_REQ); > =A0 =A0 =A0 =A0 =A0 =A0 scheduler.shutdownNow(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 @Override > =A0 =A0 =A0 =A0 public void run() { > =A0 =A0 =A0 =A0 =A0 =A0 queue.add(EXIT_REQ); > =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0} > > > > > Is it possible a large merge is running? =A0By default IW.close waits > for outstanding merges to complete. =A0Can you post the stacktrace? > > Mike > > On Thu, Oct 8, 2009 at 5:22 PM, Jamie Band wrote= : >> >> Hi All >> >> I have a long running situation where our indexing thread is getting stu= ck >> indefinitely in IndexWriter's close method. Yourkit shows the thread to = be >> stuck in TIME_WAITING. Any idea's on what could be causing this? >> Could it be one of the streams or readers we passed to the document? >> >> I am running Lucene 2.9.0. >> >> Many thanks in advance >> >> Jamie >> >> >> >> --------------------------------------------------------------------- >> 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 > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org