Yeah, so not great (doubling your file descriptor usage to protect
against this).  Still we could provide that as an option to
NIOFSDir...

We could at least attempt the reopen, in case the file is present.
This way, at least, one could make a (custom, app dependent) deletion
policy that ensure any commit point still being used by a reader is
not deleted.  Together that would make a viable (but, app dependent)
workaround.

The other obvious workaround is to not use Thread.interrupt (or things
that in turn use it, eg Future.cancel) with NIOFSDir.

Mike

On Thu, Jan 28, 2010 at 6:28 AM, Uwe Schindler <u...@thetaphi.de> wrote:
> From JavaDocs:
> The state of a file channel is intimately connected to that of the object 
> whose getChannel method returned the channel. Changing the channel's 
> position, whether explicitly or by reading or writing bytes, will change the 
> file position of the originating object, and vice versa. Changing the file's 
> length via the file channel will change the length seen via the originating 
> object, and vice versa. Changing the file's content by writing bytes will 
> change the content seen by the originating object, and vice versa.
>
> This can only work if the RandomAccessFile and the corresponding channel use 
> the same descriptor. So if you create a RandomAccessFile in the ctor and call 
> getChannel() later, just keep the RandomAccessFile open and close it at close.
>
> The current code uses File.openChannel().
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: u...@thetaphi.de
>
>
>> -----Original Message-----
>> From: Uwe Schindler [mailto:u...@thetaphi.de]
>> Sent: Thursday, January 28, 2010 12:23 PM
>> To: java-dev@lucene.apache.org
>> Subject: RE: Nasty NIO behavior makes NIOFSDirectory silently close
>> channel
>>
>> I am not sure, because RandomAccessFile has a getChannel method, so I
>> suspect that they share the descriptor. Maybe check it with lsof?
>>
>> Possibly we could wait until Simon provides a testcase that fails.
>>
>> -----
>> Uwe Schindler
>> H.-H.-Meier-Allee 63, D-28213 Bremen
>> http://www.thetaphi.de
>> eMail: u...@thetaphi.de
>>
>>
>> > -----Original Message-----
>> > From: Michael McCandless [mailto:luc...@mikemccandless.com]
>> > Sent: Thursday, January 28, 2010 12:08 PM
>> > To: java-dev@lucene.apache.org
>> > Subject: Re: Nasty NIO behavior makes NIOFSDirectory silently close
>> > channel
>> >
>> > On Thu, Jan 28, 2010 at 5:59 AM, Uwe Schindler <u...@thetaphi.de>
>> wrote:
>> > > But if you keep the underlying RandomAccessFile open?
>> >
>> > We could do that but... won't this consume 2 file descriptors?
>> >
>> > Mike
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
>> > For additional commands, e-mail: java-dev-h...@lucene.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
>> For additional commands, e-mail: java-dev-h...@lucene.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-dev-h...@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to