You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by lu...@sohu.com on 2010/02/25 09:15:14 UTC

problem about backup index file

I want backup my index file,but I get the follow error.
java.io.IOException: another program lock the file! at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(Unknown Source) at com.common.Utils.copyDirectory(Utils.java:149) at com.common.Utils.copyDirectory(Utils.java:138) at com.common.Utils.copyDirectory(Utils.java:138) at com.index.IndexManager.backDataPolicy(IndexManager.java:398) at com.index.IndexManager.indexLoop(IndexManager.java:222) at com.Main$1.run(Main.java:48) at java.lang.Thread.run(Unknown Source)
 
How can I backup lucene file in IR thread.

答复: problem about backup index file

Posted by luocanrao <lu...@sohu.com>.
Thanks ,Uwe Schindler
In linux,it works fine!
I

-----邮件原件-----
发件人: Uwe Schindler [mailto:uwe@thetaphi.de] 
发送时间: 2010年2月25日 16:30
收件人: java-user@lucene.apache.org
主题: RE: problem about backup index file

In Windows you have no chance to do that without closing all IndexWriters and IndexReaders that modify indexes.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: luocan19826164@sohu.com [mailto:luocan19826164@sohu.com]
> Sent: Thursday, February 25, 2010 9:15 AM
> To: java-user
> Subject: problem about backup index file
> 
> I want backup my index file,but I get the follow error.
> java.io.IOException:&nbsp;another program lock the file!&nbsp;at
> java.io.FileInputStream.readBytes(Native Method)&nbsp;at
> java.io.FileInputStream.read(Unknown Source)&nbsp;at
> com.common.Utils.copyDirectory(Utils.java:149)&nbsp;at
> com.common.Utils.copyDirectory(Utils.java:138)&nbsp;at
> com.common.Utils.copyDirectory(Utils.java:138)&nbsp;at
> com.index.IndexManager.backDataPolicy(IndexManager.java:398)&nbsp;at
> com.index.IndexManager.indexLoop(IndexManager.java:222)&nbsp;at
> com.Main$1.run(Main.java:48)&nbsp;at java.lang.Thread.run(Unknown
> Source)
> &nbsp;
> How can I backup lucene file in IR thread.


---------------------------------------------------------------------
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


RE: problem about backup index file

Posted by Uwe Schindler <uw...@thetaphi.de>.
In Windows you have no chance to do that without closing all IndexWriters and IndexReaders that modify indexes.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: luocan19826164@sohu.com [mailto:luocan19826164@sohu.com]
> Sent: Thursday, February 25, 2010 9:15 AM
> To: java-user
> Subject: problem about backup index file
> 
> I want backup my index file,but I get the follow error.
> java.io.IOException:&nbsp;another program lock the file!&nbsp;at
> java.io.FileInputStream.readBytes(Native Method)&nbsp;at
> java.io.FileInputStream.read(Unknown Source)&nbsp;at
> com.common.Utils.copyDirectory(Utils.java:149)&nbsp;at
> com.common.Utils.copyDirectory(Utils.java:138)&nbsp;at
> com.common.Utils.copyDirectory(Utils.java:138)&nbsp;at
> com.index.IndexManager.backDataPolicy(IndexManager.java:398)&nbsp;at
> com.index.IndexManager.indexLoop(IndexManager.java:222)&nbsp;at
> com.Main$1.run(Main.java:48)&nbsp;at java.lang.Thread.run(Unknown
> Source)
> &nbsp;
> How can I backup lucene file in IR thread.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: problem about backup index file

Posted by Michael McCandless <lu...@mikemccandless.com>.
Well, lucene is "write once" and then, eventually, "delete once" ;)

Ie files are eventually deleted (when they are merged away).

So when you do the incremental backup, any file not listed in the
current commit can be removed from your backup (assuming you only want
to backup the last commit).

Don't delete the files in your last backup... keep the ones that are
"in common" with your new backup as you don't need to recopy them
(they will not have changed).

Mike

On Fri, Feb 26, 2010 at 1:47 AM,  <lu...@sohu.com> wrote:
> thanks for your paper,Michael McCandlessI have one quetion about thisFor all other files, Lucene is "write once."This makes doing
> incremental backups very easy: Simply compare the file names.Once a
> file is written, it will never change; therefore, if you've already
> backed up that file, there's no need to copy it again.this means the number of files is growing more and more.never getting less.another question:I should delete the files previous I backup when I backup again. ----- 原文 ----- 发件人: Michael McCandless 主 题: Re: problem about backup index file时 间: 2010年2月25日  23:19:59This is likely happening because you're attempting to copy a file thatIndexWriter is currently writing?You shouldn't do that (copy files that are still being written) --that just wastes bytes (they aren't used by the index), and causesthis failure on Windows.Instead, you should use SnapshotDeletionPolicy -- it tells youspecifically which files make up the latest commit point.  Those fileswill not be opened for writing (only for reading, if you have anIndexReader open on that commit) and they should copy just fine onwindows.The "Hot backups with Lucene" article (NOTE: I'm the author) inupcoming Lucene in Action 2 revision shows how to do this -- it'savailable for download from http://manning.com/hatcher3.MikeOn Thu, Feb 25, 2010 at 3:15 AM,  &lt;luocan19826164@sohu.com&gt; wrote:&gt; I want backup my index file,but I get the follow error.&gt; java.io.IOException:&amp;nbsp;another program lock the file!&amp;nbsp;at java.io.FileInputStream.readBytes(Native Method)&amp;nbsp;at java.io.FileInputStream.read(Unknown Source)&amp;nbsp;at com.common.Utils.copyDirectory(Utils.java:149)&amp;nbsp;at com.common.Utils.copyDirectory(Utils.java:138)&amp;nbsp;at com.common.Utils.copyDirectory(Utils.java:138)&amp;nbsp;at com.index.IndexManager.backDataPolicy(IndexManager.java:398)&amp;nbsp;at com.index.IndexManager.indexLoop(IndexManager.java:222)&amp;nbsp;at com.Main$1.run(Main.java:48)&amp;nbsp;at java.lang.Thread.run(Unknown Source)&gt; &amp;nbsp;&gt; How can I backup lucene file in IR thread.---------------------------------------------------------------------To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.orgFor 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


Re: problem about backup index file

Posted by lu...@sohu.com.
thanks for your paper,Michael McCandlessI have one quetion about thisFor all other files, Lucene is "write once.”This makes doing
incremental backups very easy: Simply compare the file names.Once a
file is written, it will never change; therefore, if you've already
backed up that file, there's no need to copy it again.this means the number of files is growing more and more.never getting less.another question:I should delete the files previous I backup when I backup again. ----- 原文 ----- 发件人: Michael McCandless 主 题: Re: problem about backup index file时 间: 2010年2月25日  23:19:59This is likely happening because you're attempting to copy a file thatIndexWriter is currently writing?You shouldn't do that (copy files that are still being written) --that just wastes bytes (they aren't used by the index), and causesthis failure on Windows.Instead, you should use SnapshotDeletionPolicy -- it tells youspecifically which files make up the latest commit point.  Those fileswill not be opened for writing (only for reading, if you have anIndexReader open on that commit) and they should copy just fine onwindows.The "Hot backups with Lucene" article (NOTE: I'm the author) inupcoming Lucene in Action 2 revision shows how to do this -- it'savailable for download from http://manning.com/hatcher3.MikeOn Thu, Feb 25, 2010 at 3:15 AM,  &lt;luocan19826164@sohu.com&gt; wrote:&gt; I want backup my index file,but I get the follow error.&gt; java.io.IOException:&amp;nbsp;another program lock the file!&amp;nbsp;at java.io.FileInputStream.readBytes(Native Method)&amp;nbsp;at java.io.FileInputStream.read(Unknown Source)&amp;nbsp;at com.common.Utils.copyDirectory(Utils.java:149)&amp;nbsp;at com.common.Utils.copyDirectory(Utils.java:138)&amp;nbsp;at com.common.Utils.copyDirectory(Utils.java:138)&amp;nbsp;at com.index.IndexManager.backDataPolicy(IndexManager.java:398)&amp;nbsp;at com.index.IndexManager.indexLoop(IndexManager.java:222)&amp;nbsp;at com.Main$1.run(Main.java:48)&amp;nbsp;at java.lang.Thread.run(Unknown Source)&gt; &amp;nbsp;&gt; How can I backup lucene file in IR thread.---------------------------------------------------------------------To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.orgFor additional commands, e-mail: java-user-help@lucene.apache.org

Re: problem about backup index file

Posted by Michael McCandless <lu...@mikemccandless.com>.
This is likely happening because you're attempting to copy a file that
IndexWriter is currently writing?

You shouldn't do that (copy files that are still being written) --
that just wastes bytes (they aren't used by the index), and causes
this failure on Windows.

Instead, you should use SnapshotDeletionPolicy -- it tells you
specifically which files make up the latest commit point.  Those files
will not be opened for writing (only for reading, if you have an
IndexReader open on that commit) and they should copy just fine on
windows.

The "Hot backups with Lucene" article (NOTE: I'm the author) in
upcoming Lucene in Action 2 revision shows how to do this -- it's
available for download from http://manning.com/hatcher3.

Mike

On Thu, Feb 25, 2010 at 3:15 AM,  <lu...@sohu.com> wrote:
> I want backup my index file,but I get the follow error.
> java.io.IOException:&nbsp;another program lock the file!&nbsp;at java.io.FileInputStream.readBytes(Native Method)&nbsp;at java.io.FileInputStream.read(Unknown Source)&nbsp;at com.common.Utils.copyDirectory(Utils.java:149)&nbsp;at com.common.Utils.copyDirectory(Utils.java:138)&nbsp;at com.common.Utils.copyDirectory(Utils.java:138)&nbsp;at com.index.IndexManager.backDataPolicy(IndexManager.java:398)&nbsp;at com.index.IndexManager.indexLoop(IndexManager.java:222)&nbsp;at com.Main$1.run(Main.java:48)&nbsp;at java.lang.Thread.run(Unknown Source)
> &nbsp;
> How can I backup lucene file in IR thread.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org