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

Julian Reschke commented on OAK-9170:
-------------------------------------

The change below appears to fix it:

{noformat}
Index: 
src/main/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/PersistentDiskCache.java
===================================================================
--- 
src/main/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/PersistentDiskCache.java
     (revision 1881056)
+++ 
src/main/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/PersistentDiskCache.java
     (working copy)
@@ -141,6 +141,7 @@
             if (writesPending.add(segmentId)) {
                 try (FileChannel channel = new 
FileOutputStream(tempSegmentFile).getChannel()) {
                     int fileSize = bufferCopy.write(channel);
+                    channel.close();
                     try {
                         Files.move(tempSegmentFile.toPath(), 
segmentFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
                     } catch (AtomicMoveNotSupportedException e) {
{noformat}

> Make loading segment disk cache fail safe in case when write operation is 
> interrupted by failure
> ------------------------------------------------------------------------------------------------
>
>                 Key: OAK-9170
>                 URL: https://issues.apache.org/jira/browse/OAK-9170
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: segment-tar
>            Reporter: Miroslav Smiljanic
>            Assignee: Andrei Dulceanu
>            Priority: Major
>             Fix For: 1.34.0
>
>         Attachments: OAK-9170.patch
>
>
> Failure while writing the segment to disk cache, can leave content of the 
> segment partially persisted. That will cause the problems when that same file 
> is later loaded. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to