gianm commented on a change in pull request #6677: FileUtils: Sync directory 
entry too on writeAtomically.
URL: https://github.com/apache/incubator-druid/pull/6677#discussion_r237236007
 
 

 ##########
 File path: 
core/src/main/java/org/apache/druid/java/util/common/CompressionUtils.java
 ##########
 @@ -78,16 +78,12 @@ public static long zip(File directory, File outputZipFile, 
boolean fsync) throws
       log.warn("No .zip suffix[%s], putting files from [%s] into it anyway.", 
outputZipFile, directory);
     }
 
-    try (final FileOutputStream out = new FileOutputStream(outputZipFile)) {
-      long bytes = zip(directory, out);
-
-      // For explanation of why fsyncing here is a good practice:
-      // 
https://github.com/apache/incubator-druid/pull/5187#pullrequestreview-85188984
-      if (fsync) {
-        out.getChannel().force(true);
+    if (fsync) {
+      return FileUtils.writeAtomically(outputZipFile, out -> zip(directory, 
out));
+    } else {
+      try (final FileOutputStream out = new FileOutputStream(outputZipFile)) {
 
 Review comment:
   I see 5183 `io.druid.segment.QueryableIndexSegment` objects (loaded 
segments), 2.6 million `java.nio.DirectByteBufferR`, 140k 
`java.nio.DirectByteBuffer`, 7422 `sun.misc.Cleaner`, but no PhantomReferences. 
This is on OpenJDK 1.8.0_181 and Druid 0.12.3-iap8 (like 0.12.3, but with some 
extra patches, see https://docs.imply.io/2.7.9/on-prem/misc/release).
   
   In my JDK, Cleaner extends PhantomReference, so maybe that's why there are 
no explicit PhantomReference objects. The Cleaners _are_ PhantomReferences. It 
doesn't explain why you do see them though.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to