jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1475711 - /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java
Date Thu, 25 Apr 2013 11:32:39 GMT
Author: mreutegg
Date: Thu Apr 25 11:32:39 2013
New Revision: 1475711

URL: http://svn.apache.org/r1475711
Log:
OAK-619 Lock-free MongoMK implementation
- MongoDocumentStore.findAndUpdate() must not perform an upsert, otherwise it may happen that
a unique key constraint is violated.

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java?rev=1475711&r1=1475710&r2=1475711&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/MongoDocumentStore.java
Thu Apr 25 11:32:39 2013
@@ -208,9 +208,10 @@ public class MongoDocumentStore implemen
     }
 
     @CheckForNull
-    private Map<String, Object> internalCreateOrUpdate(Collection collection,
-                                                       UpdateOp updateOp,
-                                                       boolean checkConditions) {
+    private Map<String, Object> findAndModifiy(Collection collection,
+                                               UpdateOp updateOp,
+                                               boolean upsert,
+                                               boolean checkConditions) {
         DBCollection dbCollection = getDBCollection(collection);
         QueryBuilder query = getByKeyQuery(updateOp.key);
 
@@ -277,7 +278,7 @@ public class MongoDocumentStore implemen
         try {
             DBObject oldNode = dbCollection.findAndModify(query.get(), null /*fields*/,
                     null /*sort*/, false /*remove*/, update, false /*returnNew*/,
-                    true /*upsert*/);
+                    upsert /*upsert*/);
             if (checkConditions && oldNode == null) {
                 return null;
             }
@@ -306,7 +307,7 @@ public class MongoDocumentStore implemen
                                               UpdateOp update)
             throws MicroKernelException {
         log("createOrUpdate", update);
-        Map<String, Object> map = internalCreateOrUpdate(collection, update, false);
+        Map<String, Object> map = findAndModifiy(collection, update, true, false);
         log("createOrUpdate returns ", map);
         return map;
     }
@@ -316,7 +317,7 @@ public class MongoDocumentStore implemen
                                              UpdateOp update)
             throws MicroKernelException {
         log("findAndUpdate", update);
-        Map<String, Object> map = internalCreateOrUpdate(collection, update, true);
+        Map<String, Object> map = findAndModifiy(collection, update, false, true);
         log("findAndUpdate returns ", map);
         return map;
     }



Mime
View raw message