jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1439798 - /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
Date Tue, 29 Jan 2013 09:36:21 GMT
Author: meteatamel
Date: Tue Jan 29 09:36:21 2013
New Revision: 1439798

URL: http://svn.apache.org/viewvc?rev=1439798&view=rev
Log:
OAK-585 - Reduce cost of commit retry

Check whether headRevId has been updated before saving nodes and commits in CommitCommand.

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java

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=1439798&r1=1439797&r2=1439798&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
Tue Jan 29 09:36:21 2013
@@ -97,13 +97,14 @@ public class CommitCommand extends BaseC
             prepareCommit();
             readAndMergeExistingNodes();
             prepareMongoNodes();
-            new SaveNodesAction(nodeStore, nodes.values()).execute();
-            new SaveCommitAction(nodeStore, commit).execute();
-            success = saveAndSetHeadRevision();
+            success = saveNodesAndCommits();
             if (success) {
-                cacheNodes();
-            } else {
-                retries++;
+                success = saveAndSetHeadRevision();
+                if (success) {
+                    cacheNodes();
+                } else {
+                    retries++;
+                }
             }
         } while (!success);
 
@@ -115,6 +116,17 @@ public class CommitCommand extends BaseC
         return revisionId;
     }
 
+    private boolean saveNodesAndCommits() throws Exception {
+        long headRevisionId = new FetchHeadRevisionIdAction(nodeStore, branchId).execute();
+        if (branchId == null && headRevisionId != mongoSync.getHeadRevisionId())
{
+            // Head revision moved on in trunk in the meantime, no need to save
+            return false;
+        }
+        new SaveNodesAction(nodeStore, nodes.values()).execute();
+        new SaveCommitAction(nodeStore, commit).execute();
+        return true;
+    }
+
     @Override
     public int getNumOfRetries() {
         return 100;
@@ -184,7 +196,6 @@ public class CommitCommand extends BaseC
         }
     }
 
-
 //    private void readExistingNodes() {
 //        FetchNodesAction action = new FetchNodesAction(nodeStore, affectedPaths,
 //                mongoSync.getHeadRevisionId());



Mime
View raw message