jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1415211 - in /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl: action/FetchCommitsAction.java command/CommitCommand.java command/NodeExistsCommand.java instruction/CommitCommandInstructionVisitor.java
Date Thu, 29 Nov 2012 15:31:04 GMT
Author: meteatamel
Date: Thu Nov 29 15:31:03 2012
New Revision: 1415211

URL: http://svn.apache.org/viewvc?rev=1415211&view=rev
Log:
OAK-488 - Concurrency issue with FetchCommitsAction

Tweaks to the fix after more testing.

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/NodeExistsCommand.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java?rev=1415211&r1=1415210&r2=1415211&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
Thu Nov 29 15:31:03 2012
@@ -132,27 +132,7 @@ public class FetchCommitsAction extends 
                 : commitCollection.find(query).sort(orderBy);
     }
 
-    // FIXME - Revisit this method to make sure it works correctly in concurrent scenarios.
-    // The old method tried to read all commits reachable from current rev but the problem
-    // with that approach is that the current rev can end up being invalid later on which
-    // causes previous valid but unreachable commits to be missed. The new method simply
grabs all
-    // valid commits at the moment in order to not miss any legitimate valid commits but
-    // not sure if this is the right thing to do in all scenarios.
     private List<MongoCommit> convertToCommits(DBCursor dbCursor) {
-        List<MongoCommit> commits = new LinkedList<MongoCommit>();
-        while (dbCursor.hasNext()) {
-            MongoCommit commit = (MongoCommit) dbCursor.next();
-            commits.add(commit);
-        }
-
-        LOG.debug("Found list of valid revisions for max revision {}: {}",
-                toRevisionId, commits);
-
-        return commits;
-    }
-
-    // Keeping this until we're sure that the new method is correct.
-    private List<MongoCommit> convertToCommitsOld(DBCursor dbCursor) {
         Map<Long, MongoCommit> commits = new HashMap<Long, MongoCommit>();
         while (dbCursor.hasNext()) {
             MongoCommit commitMongo = (MongoCommit) dbCursor.next();

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java?rev=1415211&r1=1415210&r2=1415211&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
Thu Nov 29 15:31:03 2012
@@ -96,7 +96,7 @@ public class CommitCommand extends BaseC
     }
 
     private void readValidCommits() {
-        validCommits = new FetchCommitsAction(nodeStore, revisionId).execute();
+        validCommits = new FetchCommitsAction(nodeStore, mongoSync.getHeadRevisionId()).execute();
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/NodeExistsCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/NodeExistsCommand.java?rev=1415211&r1=1415210&r2=1415211&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/NodeExistsCommand.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/NodeExistsCommand.java
Thu Nov 29 15:31:03 2012
@@ -17,14 +17,15 @@
 package org.apache.jackrabbit.mongomk.impl.command;
 
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
 import org.apache.jackrabbit.mongomk.impl.action.FetchNodesAction;
+import org.apache.jackrabbit.mongomk.impl.model.MongoCommit;
 import org.apache.jackrabbit.mongomk.impl.model.MongoNode;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-//import org.apache.jackrabbit.mongomk.api.model.Node;
 
 /**
  * {@code Command} for {@code MongoMicroKernel#nodeExists(String, String)}
@@ -33,8 +34,8 @@ public class NodeExistsCommand extends B
 
     private Long revisionId;
     private String branchId;
-    //private Node parentNode;
     private String path;
+    private List<MongoCommit> validCommits;
 
     /**
      * Constructs a new {@code NodeExistsCommandMongo}.
@@ -58,6 +59,16 @@ public class NodeExistsCommand extends B
         this.branchId = branchId;
     }
 
+    /**
+     * Sets the last valid commits if already known. This is an optimization to
+     * speed up the fetch nodes action.
+     *
+     * @param commits The last valid commits.
+     */
+    public void setValidCommits(List<MongoCommit> validCommits) {
+        this.validCommits = validCommits;
+    }
+
     @Override
     public Boolean execute() throws Exception {
         if (PathUtils.denotesRoot(path)) {
@@ -86,7 +97,7 @@ public class NodeExistsCommand extends B
         }
         FetchNodesAction action = new FetchNodesAction(nodeStore, paths, revisionId);
         action.setBranchId(branchId);
-        //action.setValidCommits(validCommits);
+        action.setValidCommits(validCommits);
 
         Map<String, MongoNode> pathAndNodeMap = action.execute();
         String currentPath = this.path;

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java?rev=1415211&r1=1415210&r2=1415211&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/instruction/CommitCommandInstructionVisitor.java
Thu Nov 29 15:31:03 2012
@@ -252,6 +252,7 @@ public class CommitCommandInstructionVis
         NodeExistsCommand existCommand = new NodeExistsCommand(nodeStore,
                 path, headRevisionId);
         existCommand.setBranchId(branchId);
+        existCommand.setValidCommits(validCommits);
         boolean exists = false;
         try {
             exists = existCommand.execute();



Mime
View raw message