Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent fsync from creating 0-byte files #5746

Merged
merged 2 commits into from Apr 14, 2014
Merged

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Apr 9, 2014

This is related to LUCENE-5570 where fsync creates a 0-byte file
if the file does not exists. This commit adds the patched lucene
version using Java 7 APIs as well as a note to replace this method
with the upcomeing IOUtils#fsync in Lucene 4.8

@s1monw
Copy link
Contributor Author

s1monw commented Apr 12, 2014

@imotov if you have time I'd love if you could take a look at this again. I added a new commit that cleans up that writeBlob method and also tries to fsync the directory that we have written too.

if (innerSuccess) {
IOUtils.close(is, raf);
} else {
IOUtils.closeWhileHandlingException(is, raf);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is now an unused import for IOUtils in this file.

@imotov
Copy link
Contributor

imotov commented Apr 12, 2014

LGTM

@@ -75,11 +80,7 @@ public static int maxOpenFiles(File testDir) {
} catch (IOException ioe) {
int i = 0;
for (RandomAccessFile raf : files) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi I think you can IOUtils.closeWhileHandlingException(files) since its Iterable...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true man I am going to remove this method anyway soon

@rmuir
Copy link
Contributor

rmuir commented Apr 14, 2014

+1 for the fsync fix, I'm glad we factored this logic into a utility method in Lucene 4.8....

This is related to LUCENE-5570 where fsync creates a 0-byte file
if the file does not exists. This commit adds the patched lucene
version using Java 7 APIs as well as a note to replace this method
with the upcomeing IOUtils#fsync in Lucene 4.8

This commit cleans up FsImmutableBlobContainer#writeBlob to make
use of Java7 Auto-Closing features and ensures that the directory
the blob was written to is fsynced as well if possible.
@s1monw s1monw merged commit 0564c88 into elastic:master Apr 14, 2014
@s1monw s1monw deleted the fix_fsync branch April 14, 2014 20:24
@clintongormley clintongormley added the :Core/Infra/Core Core issues without another label label Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants