Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 90CE210E88 for ; Mon, 4 Nov 2013 15:16:42 +0000 (UTC) Received: (qmail 41342 invoked by uid 500); 4 Nov 2013 15:14:42 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 41288 invoked by uid 500); 4 Nov 2013 15:14:33 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 41091 invoked by uid 99); 4 Nov 2013 15:14:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Nov 2013 15:14:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Nov 2013 15:14:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 093F223888E7; Mon, 4 Nov 2013 15:14:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: oak-commits@jackrabbit.apache.org From: mreutegg@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131104151404.093F223888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 ids = new ArrayList(); @@ -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