jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1538644 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk: Commit.java MongoNodeStore.java
Date Mon, 04 Nov 2013 15:14:03 GMT
Author: mreutegg
Date: Mon Nov  4 15:14:03 2013
New Revision: 1538644

URL: http://svn.apache.org/r1538644
Log:
OAK-1080: MongoMK: improved concurrency
- always write back _lastRev in background thread to make sure it contains in fact the last
modified revision for this cluster instance

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java?rev=1538644&r1=1538643&r2=1538644&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/Commit.java
Mon Nov  4 15:14:03 2013
@@ -204,11 +204,6 @@ public class Commit {
         UpdateOp commitRoot = getUpdateOperationForNode(commitRootPath);
         for (String p : operations.keySet()) {
             UpdateOp op = operations.get(p);
-            if (baseBranchRevision == null) {
-                // only apply _lastRev for trunk commits, _lastRev for
-                // branch commits only become visible on merge
-                NodeDocument.setLastRev(op, revision);
-            }
             if (op.isNew()) {
                 NodeDocument.setDeleted(op, revision, false);
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java?rev=1538644&r1=1538643&r2=1538644&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
Mon Nov  4 15:14:03 2013
@@ -290,6 +290,9 @@ public final class MongoNodeStore
             n = new Node("/", headRevision);
             commit.addNode(n);
             commit.applyToDocumentStore();
+            commit.applyToCache(false);
+            // make sure _lastRev is written back to store
+            backgroundWrite();
         } else {
             // initialize branchCommits
             branches.init(store, this);
@@ -302,10 +305,6 @@ public final class MongoNodeStore
     }
 
     public void dispose() {
-        // force background write (with asyncDelay > 0, the root wouldn't be written)
-        // TODO make this more obvious / explicit
-        // TODO tests should also work if this is not done
-        asyncDelay = 0;
         runBackgroundOperations();
         if (!isDisposed.getAndSet(true)) {
             synchronized (isDisposed) {
@@ -658,26 +657,18 @@ public final class MongoNodeStore
             Revision branchRev = rev.asBranchRevision();
             unsaved = branches.getBranch(branchRev).getModifications(branchRev);
         }
-        // track unsaved modifications of nodes that were not
-        // written in the commit (implicitly modified parent)
-        // or any modification if this is a branch commit
-        if (!isWritten || isBranchCommit) {
-            Revision prev = unsaved.put(path, rev);
-            if (prev != null) {
-                if (isRevisionNewer(prev, rev)) {
-                    // revert
-                    unsaved.put(path, prev);
-                    String msg = String.format("Attempt to update " +
-                            "unsavedLastRevision for %s with %s, which is " +
-                            "older than current %s.",
-                            path, rev, prev);
-                    throw new MicroKernelException(msg);
-                }
+        // write back _lastRev with background thread
+        Revision prev = unsaved.put(path, rev);
+        if (prev != null) {
+            if (isRevisionNewer(prev, rev)) {
+                // revert
+                unsaved.put(path, prev);
+                String msg = String.format("Attempt to update " +
+                        "unsavedLastRevision for %s with %s, which is " +
+                        "older than current %s.",
+                        path, rev, prev);
+                throw new MicroKernelException(msg);
             }
-        } else {
-            // the document was updated:
-            // we no longer need to update it in a background process
-            unsaved.remove(path);
         }
         String key = path + "@" + rev;
         Node.Children c = nodeChildrenCache.getIfPresent(key);
@@ -1113,7 +1104,6 @@ public final class MongoNodeStore
 
         });
 
-        long now = Revision.getCurrentTimestamp();
         UpdateOp updateOp = null;
         Revision lastRev = null;
         List<String> ids = new ArrayList<String>();
@@ -1123,12 +1113,6 @@ public final class MongoNodeStore
             if (r == null) {
                 continue;
             }
-            // FIXME: with below code fragment the root (and other nodes
-            // 'close' to the root) will not be updated in MongoDB when there
-            // are frequent changes.
-            if (Revision.getTimestampDifference(now, r.getTimestamp()) < asyncDelay) {
-                continue;
-            }
             int size = ids.size();
             if (updateOp == null) {
                 // create UpdateOp



Mime
View raw message