Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 31795 invoked from network); 23 Sep 2008 08:35:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Sep 2008 08:35:44 -0000 Received: (qmail 66612 invoked by uid 500); 23 Sep 2008 08:35:35 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 66563 invoked by uid 500); 23 Sep 2008 08:35:35 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 66547 invoked by uid 99); 23 Sep 2008 08:35:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Sep 2008 01:35:35 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Sep 2008 08:34:43 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 3B557234C1E5 for ; Tue, 23 Sep 2008 01:34:47 -0700 (PDT) Message-ID: <1621345473.1222158887242.JavaMail.jira@brutus> Date: Tue, 23 Sep 2008 01:34:47 -0700 (PDT) From: "Michael McCandless (JIRA)" To: java-dev@lucene.apache.org Subject: [jira] Reopened: (LUCENE-1399) NullPointerException issue with single IndexWriter instance shared among multiple Thread In-Reply-To: <1818736335.1222067024281.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LUCENE-1399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Michael McCandless reopened LUCENE-1399: ---------------------------------------- > NullPointerException issue with single IndexWriter instance shared among multiple Thread > ---------------------------------------------------------------------------------------- > > Key: LUCENE-1399 > URL: https://issues.apache.org/jira/browse/LUCENE-1399 > Project: Lucene - Java > Issue Type: Bug > Components: Index > Affects Versions: 2.3.2 > Environment: Windows XP, JDK 1.6 > Reporter: Rudi Quark > Fix For: 2.4 > > > NullPointerException is thrown while indexing within multiple threads but using one single IndexWriter instance. According to "Lucene in Action" this should do: "...a single instance of either class can be shared among multiple threads, and all calls to its index-modifying methods will be properly synchronized so that index modifications are executed one after the other." > Following my exception trace: > java.lang.NullPointerException > at org.apache.lucene.index.IndexFileDeleter.decRef(IndexFileDeleter.java:475) > at org.apache.lucene.index.IndexWriter.commitTransaction(IndexWriter.java:1986) > at org.apache.lucene.index.IndexWriter.addIndexes(IndexWriter.java:2219) > at com.shi.marketingspy.test.SHILuceneWritingFromThreadsTest$testthread.run(SHILuceneWritingFromThreadsTest.java:48) > at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) > at java.lang.Thread.run(Thread.java:619) > Following my test program: > package com.shi.marketingspy.test; > import org.apache.lucene.analysis.Analyzer; > import org.apache.lucene.document.Document; > import org.apache.lucene.document.Field; > import org.apache.lucene.document.Field.Store; > import org.apache.lucene.index.IndexWriter; > public class SHILuceneWritingFromThreadsTest > { > public static void log(String s, com.shi.jipmisc misc) > { > misc.__Log(s); > } > public static class testthread implements Runnable > { > public org.apache.lucene.index.IndexWriter indexwriter; > public int iThread; > public boolean bWithOptimize; > public com.shi.jipmisc misc; > public testthread(org.apache.lucene.index.IndexWriter indexwriter, int iThread, boolean bWithOptimize, com.shi.jipmisc misc) > { > this.indexwriter = indexwriter; > this.iThread = iThread; > this.bWithOptimize = bWithOptimize; > this.misc = misc; > } > public void run() > { > try > { > Analyzer anal = new com.shi.lucene.index.SHIAnalyser(null,null); > org.apache.lucene.store.Directory tmpidxdirectory = new org.apache.lucene.store.RAMDirectory(); > org.apache.lucene.index.IndexWriter tempindexwriter = new IndexWriter(tmpidxdirectory, anal, true); > Document doc = new Document(); > for(int ifld=0; ifld < 9; ifld++) > { > doc.add(new Field("field_"+ifld, "iThread: "+iThread+" field: "+ifld+" "+System.currentTimeMillis()+" "+misc.getDateString()+" "+misc.getDateString2()+" "+com.shi.jipmisc.getTimeStamp()+" "+misc.getClass()+" "+misc.getDebug(), Store.COMPRESS, Field.Index.UN_TOKENIZED)); > } > tempindexwriter.addDocument(doc); > tempindexwriter.optimize(); > org.apache.lucene.store.Directory[] idxs = new org.apache.lucene.store.Directory[1]; > idxs[0] = tmpidxdirectory; > //todo: del-call... > this.indexwriter.addIndexes(idxs); > if (this.bWithOptimize) > this.indexwriter.optimize(); > } > catch(Throwable e) > { > log("testthread:run\tERR:2(bWithOpti:"+bWithOptimize+")(iThread:"+iThread+"):"+e.getMessage()+"\n\t"+com.shi.jipmisc.stack2string(e), misc); > } > } > } > public SHILuceneWritingFromThreadsTest() > { > } > public static void main(String[] args) > { > testluceneconcurrency(false); > testluceneconcurrency(true ); > } > public static java.util.concurrent.ExecutorService threadpool_optimized = java.util.concurrent.Executors.newFixedThreadPool(9999999); > public static java.util.concurrent.ExecutorService threadpool_not_optimized = java.util.concurrent.Executors.newFixedThreadPool(9999999); > public static void testluceneconcurrency(boolean bWithOptimize) > { > com.shi.jipmisc.createDir("temp", "c:"); > com.shi.jipmisc.createDir("testluceneconcurrency", "c:/temp"); > com.shi.jipmisc.createDir(""+bWithOptimize, "c:/temp/testluceneconcurrency"); > com.shi.jipmisc misc = new com.shi.jipmisc(); > misc.setMyPath("C:/temp/testluceneconcurrency"); > misc.setDebug(true); > misc.emptyDir("c:/temp/testluceneconcurrency/"+bWithOptimize); > Analyzer anal = new com.shi.lucene.index.SHIAnalyser(null,null); > org.apache.lucene.index.IndexWriter indexwriter = null; > try > { > indexwriter = new IndexWriter("c:/temp/testluceneconcurrency/"+bWithOptimize, anal, true); > } > catch(Throwable e) > { > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tERR:0("+bWithOptimize+"):"+e.getMessage(), misc); > return; > } > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tINF:step0("+bWithOptimize+")(BEGIN)-------------------------------------", misc); > for(int idoc=0; idoc < 9999; idoc++) > { > Document doc = new Document(); > for(int ifld=0; ifld < 9; ifld++) > { > doc.add(new Field("field_"+ifld, "doc: "+idoc+" field: "+ifld+" "+System.currentTimeMillis()+" "+misc.getDateString()+" "+misc.getDateString2()+" "+com.shi.jipmisc.getTimeStamp()+" "+misc.getClass()+" "+misc.getDebug(), Store.COMPRESS, Field.Index.UN_TOKENIZED)); > } > try > { > indexwriter.addDocument(doc); > } > catch(Throwable e) > { > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tERR:1("+bWithOptimize+"):"+e.getMessage(), misc); > return; > } > } > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tINF:step1("+bWithOptimize+")", misc); > try > { > indexwriter.optimize(); > } > catch(Throwable e) > { > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tERR:2("+bWithOptimize+"):"+e.getMessage(), misc); > return; > } > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tINF:step2("+bWithOptimize+")", misc); > java.util.concurrent.ExecutorService threadpool = bWithOptimize ? threadpool_optimized : threadpool_not_optimized; > for(int it=0; it < 999; it++) > { > threadpool.execute(new testthread(indexwriter, it, bWithOptimize, misc)); > } > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tINF:step3("+bWithOptimize+")", misc); > threadpool.shutdown(); //=execute threads and wait til all threads finish > com.shi.jipmisc.wait(999, misc); > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tINF:step4("+bWithOptimize+")", misc); > try > { > //indexwriter.optimize(); > //indexwriter.close(); > } > catch(Throwable e) > { > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tERR:9("+bWithOptimize+"):"+e.getMessage(), misc); > return; > } > log("SHILuceneWritingFromThreadsTest:testluceneconcurrency\tINF:step5("+bWithOptimize+")(END)-----------------------------", misc); > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org