You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by al...@apache.org on 2014/07/29 18:23:47 UTC

svn commit: r1614405 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: Compactor.java file/FileStore.java

Author: alexparvulescu
Date: Tue Jul 29 16:23:47 2014
New Revision: 1614405

URL: http://svn.apache.org/r1614405
Log:
OAK-2001 TarMk compaction can still cause repository growth


Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java?rev=1614405&r1=1614404&r2=1614405&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Compactor.java Tue Jul 29 16:23:47 2014
@@ -120,14 +120,16 @@ public class Compactor {
                 }
             }
 
-            NodeBuilder child = builder.setChildNode(name);
-            boolean success = EmptyNodeState.compareAgainstEmptyState(
-                    after, new CompactDiff(child));
-
-            if (success && id != null && child.getChildNodeCount(2) > 1) {
-                RecordId compactedId =
-                        writer.writeNode(child.getNodeState()).getRecordId();
-                map.put(id, compactedId);
+            NodeBuilder child = EmptyNodeState.EMPTY_NODE.builder();
+            boolean success = EmptyNodeState.compareAgainstEmptyState(after,
+                    new CompactDiff(child));
+
+            if (success) {
+                SegmentNodeState state = writer.writeNode(child.getNodeState());
+                builder.setChildNode(name, state);
+                if (id != null && state.getChildNodeCount(2) > 1) {
+                    map.put(id, state.getRecordId());
+                }
             }
 
             return success;
@@ -207,7 +209,8 @@ public class Compactor {
                 List<RecordId> ids = binaries.get(key);
                 if (ids != null) {
                     for (RecordId duplicateId : ids) {
-                        if (new SegmentBlob(duplicateId).equals(blob)) {
+                        if (new SegmentBlob(duplicateId).equals(sb)) {
+                            map.put(id, duplicateId);
                             return new SegmentBlob(duplicateId);
                         }
                     }
@@ -224,7 +227,7 @@ public class Compactor {
 
                 return sb;
             } catch (IOException e) {
-                log.warn("Failed to compcat a blob", e);
+                log.warn("Failed to compact a blob", e);
                 // fall through
             }
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java?rev=1614405&r1=1614404&r2=1614405&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java Tue Jul 29 16:23:47 2014
@@ -355,15 +355,15 @@ public class FileStore implements Segmen
                         cleanup();
                     }
                 }
-
-                // remove all obsolete tar generations
-                Iterator<File> iterator = toBeRemoved.iterator();
-                while (iterator.hasNext()) {
-                    File file = iterator.next();
-                    if (!file.exists() || file.delete()) {
-                        log.debug("TarMK GC: Removed old file {}", file);
-                        iterator.remove();
-                    }
+            }
+            // remove all obsolete tar generations
+            Iterator<File> iterator = toBeRemoved.iterator();
+            while (iterator.hasNext()) {
+                File file = iterator.next();
+                log.debug("TarMK GC: Attempting to remove old file {}", file);
+                if (!file.exists() || file.delete()) {
+                    log.debug("TarMK GC: Removed old file {}", file);
+                    iterator.remove();
                 }
             }
         }