[ 
https://issues.apache.org/jira/browse/LUCENE-3237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13965162#comment-13965162
 ] 

Michael McCandless commented on LUCENE-3237:
--------------------------------------------

bq. In fact, fsync syncs the whole file, because it relies on fsync() POSIX API 
or FlushFileBuffers() in Windows. Both really sync the file the descriptor is 
pointing to. Those functions don't sync the descriptor's buffers only.

This is my impression as well, and as Yonik said, it's hard to imagine any 
[sane] operating system doing it differently ... so this really is paranoia.

bq. {{FSDirectory.FSIndexOutput#sync()}} should call flush() before syncing the 
underlying file.

OK I'll move it there (I'm currently doing it in the first close "attempt").

bq. This does not do the for-loop we currently do to repeat the fsync 5 times 
if it fails.

I'll add an IOUtils.sync that takes an fd and does the retry thing.

bq. Also, I would not remove Directory.sync(), we should maybe leave this for 
LUCENE-5588 to sync the directory itsself.

Right, we should add it back, as a method taking no file args?  Its purpose 
would be LUCENE-5588.

> FSDirectory.fsync() may not work properly
> -----------------------------------------
>
>                 Key: LUCENE-3237
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3237
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/store
>            Reporter: Shai Erera
>         Attachments: LUCENE-3237.patch
>
>
> Spinoff from LUCENE-3230. FSDirectory.fsync() opens a new RAF, sync() its 
> FileDescriptor and closes RAF. It is not clear that this syncs whatever was 
> written to the file by other FileDescriptors. It would be better if we do 
> this operation on the actual RAF/FileOS which wrote the data. We can add 
> sync() to IndexOutput and FSIndexOutput will do that.
> Directory-wise, we should stop syncing on file names, and instead sync on the 
> IOs that performed the write operations.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

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

Reply via email to