lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: Concurrent access IndexReader / IndexWriter - FileNotFoundException
Date Sat, 09 Jan 2010 17:54:09 GMT
Can you double check that you're not creating 2 writers on the same
directory, somehow?

Or: is there any other process that removes files from this directory?

Answering your original questions...: commit/read does not require any
external synchronization or locking.  You should generally keep your
IW open indefinitely and just periodically commit and/or get a new
reader (IndexWriter.getReader()) as needed.

Mike

On Sat, Jan 9, 2010 at 10:06 AM, legrand thomas
<thomaslegrand14@yahoo.fr> wrote:
>
> Here are two stack traces: add+remove a document:
>
> Tom
>
> ---
>
> Remove a document:
>
> java.io.FileNotFoundException: /home/ia/prod/current-deployment/indexes/advertisement/_0.cfs
(No such file or directory)
>         at java.io.RandomAccessFile.open(Native Method)
>         at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
>         at org.apache.lucene.store.FSDirectory$FSIndexInput$Descriptor.<init>(FSDirectory.java:552)
>         at org.apache.lucene.store.FSDirectory$FSIndexInput.<init>(FSDirectory.java:582)
>         at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:488)
>         at org.apache.lucene.index.CompoundFileReader.<init>(CompoundFileReader.java:70)
>         at org.apache.lucene.index.SegmentReader.initialize(SegmentReader.java:321)
>         at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:306)
>         at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:236)
>         at org.apache.lucene.index.DocumentsWriter.applyDeletes(DocumentsWriter.java:915)
>         at org.apache.lucene.index.IndexWriter.applyDeletes(IndexWriter.java:4339)
>         at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3579)
>         at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3450)
>         at org.apache.lucene.index.IndexWriter.prepareCommit(IndexWriter.java:3363)
>         at org.apache.lucene.index.IndexWriter.commit(IndexWriter.java:3408)
>         at com.encheromax.business.advertisement.implementation.AdvertisementManager.commitIndexWriter(AdvertisementManager.java:1728)
>         at com.encheromax.business.advertisement.implementation.AdvertisementManager.removeAdvertisementFromIndex(AdvertisementManager.java:635)
>         at com.encheromax.api.implementation.admin.ApiAdminBurnAdvertisement.executeRequest(ApiAdminBurnAdvertisement.java:210)
>         at com.encheromax.controller.admin.Rule.doReqFinal(Rule.java:100)
>         at net.tmp.fwk.fw1.controller.Action.process(Action.java:302)
>         at net.tmp.fwk.fw1.controller.Action.doPost(Action.java:87)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>         at com.encheromax.servlet.filter.EncheromaxBeanFilter.doFilter(EncheromaxBeanFilter.java:53)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
>         at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
>         at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
>         at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
>         at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
>         at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
>         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
>
> Add a document:
>
> java.io.FileNotFoundException: /home/ia/prod/current-deployment/indexes/advertisement/_v.cfs
(No such file or directory)
>         at java.io.RandomAccessFile.open(Native Method)
>         at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
>         at org.apache.lucene.store.FSDirectory$FSIndexInput$Descriptor.<init>(FSDirectory.java:552)
>         at org.apache.lucene.store.FSDirectory$FSIndexInput.<init>(FSDirectory.java:582)
>         at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:488)
>         at org.apache.lucene.index.CompoundFileReader.<init>(CompoundFileReader.java:70)
>         at org.apache.lucene.index.SegmentReader.initialize(SegmentReader.java:321)
>         at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:306)
>         at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:236)
>         at org.apache.lucene.index.DocumentsWriter.applyDeletes(DocumentsWriter.java:915)
>         at org.apache.lucene.index.IndexWriter.applyDeletes(IndexWriter.java:4339)
>         at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3579)
>         at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3450)
>         at org.apache.lucene.index.IndexWriter.prepareCommit(IndexWriter.java:3363)
>         at org.apache.lucene.index.IndexWriter.commit(IndexWriter.java:3408)
>         at com.encheromax.business.advertisement.implementation.AdvertisementManager.commitIndexWriter(AdvertisementManager.java:1728)
>         at com.encheromax.business.advertisement.implementation.AdvertisementManager.addAdvertisementDocument(AdvertisementManager.java:536)
>         at com.encheromax.business.advertisement.implementation.AdvertisementManager.appendFullAdvertisementToIndex(AdvertisementManager.java:713)
>         at com.encheromax.api.implementation.ApiFinalizeAdvertisement.executeRequest(ApiFinalizeAdvertisement.java:224)
>         at com.encheromax.controller.advertisement.CreateAdvertisement.doReq(CreateAdvertisement.java:294)
>         at net.tmp.fwk.fw1.controller.Security.doReqFinal(Security.java:135)
>         at net.tmp.fwk.fw1.controller.Action.process(Action.java:302)
>         at net.tmp.fwk.fw1.controller.Action.doPost(Action.java:87)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>         at com.encheromax.servlet.filter.EncheromaxBeanFilter.doFilter(EncheromaxBeanFilter.java:53)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
>         at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
>         at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
>         at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
>         at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
>         at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
>         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
>         at java.lang.Thread.run(Thread.java:619)
>
>
>
>
>
>
> --- En date de : Sam 9.1.10, Michael McCandless <lucene@mikemccandless.com> a écrit
:
>
> De: Michael McCandless <lucene@mikemccandless.com>
> Objet: Re: Concurrent access IndexReader / IndexWriter -  FileNotFoundException
> À: java-user@lucene.apache.org
> Date: Samedi 9 Janvier 2010, 14h51
>
> Can you post the full FNFE stack trace?
>
> Mike
>
> On Fri, Jan 8, 2010 at 5:35 AM, legrand thomas <thomaslegrand14@yahoo.fr> wrote:
>> Hi,
>>
>> I often get a FileNotFoundException when my single IndexWriter commits while the
IndexReader also tries to read. My application is multithreaded (Tomcat uses the business
APIs); I firstly thought the read/write access was thread-safe but I probably forget something.
>>
>>  Please help me to understand my mistakes:
>>
>> - When should I close the IndexWriter ? Each time I add/update a document or never
?
>> - Should my java commit/read methods be synchronized ?
>> - Should I lock the directory and what's the best way to do it ?
>>
>> I referred to the Lucene FAQ ("why do I sometimes get a FileNotFoundException when
I search and update my index at the same time?") but I did not disable any locking for processes
searching or updating the index.
>>
>> I use lucene-2.4.1.
>>
>> Thanks in advance,
>> Tom
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message