jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1452406 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
Date Mon, 04 Mar 2013 17:15:18 GMT
Author: jukka
Date: Mon Mar  4 17:15:18 2013
New Revision: 1452406

URL: http://svn.apache.org/r1452406
Log:
OAK-633: SegmentMK: Hierarchy of journals

Make sure that branch state is restore before bailing out due to system overload

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java?rev=1452406&r1=1452405&r2=1452406&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
Mon Mar  4 17:15:18 2013
@@ -99,23 +99,27 @@ class SegmentNodeStoreBranch implements 
             if (journal.setHead(baseId, headId)) {
                 baseId = headId;
                 rootId = headId;
-            } else if (backoff < 10000) {
-                // someone else was faster, so try again later
+            } else {
+                // someone else was faster, so restore state and retry later
+                baseId = originalBaseId;
+                rootId = originalRootId;
+
                 // use exponential backoff to reduce contention
-                try {
-                    Thread.sleep(backoff, RANDOM.nextInt(1000000));
-                    backoff *= 2;
-                } catch (InterruptedException e) {
-                    throw new CommitFailedException("Commit was interrupted", e);
+                if (backoff < 10000) {
+                    try {
+                        Thread.sleep(backoff, RANDOM.nextInt(1000000));
+                        backoff *= 2;
+                    } catch (InterruptedException e) {
+                        throw new CommitFailedException(
+                                "Commit was interrupted", e);
+                    }
+                } else {
+                    throw new CommitFailedException(
+                            "System overloaded, try again later");
                 }
 
                 // rebase to latest head before trying again
-                baseId = originalBaseId;
-                rootId = originalRootId;
                 rebase();
-            } else {
-                // 
-                throw new CommitFailedException("System overloaded, try again later");
             }
         }
 



Mime
View raw message