jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r637865 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/version/ test/java/org/apache/jackrabbit/core/ test/java/org/apache/jackrabbit/core/integration/ test/java/org/apache/jackrabbit/core/integration/rando...
Date Mon, 17 Mar 2008 12:47:40 GMT
Author: mreutegg
Date: Mon Mar 17 05:47:35 2008
New Revision: 637865

URL: http://svn.apache.org/viewvc?rev=637865&view=rev
Log:
JCR-1480: Deadlock when executing Version operations

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/AbstractConcurrencyTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/RandomOperationTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/CreateNodes.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/OperationFactory.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?rev=637865&r1=637864&r2=637865&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Mon Mar 17 05:47:35 2008
@@ -463,7 +463,9 @@
      * Delegate the call to our XA item state manager.
      */
     public void prepare(TransactionContext tx) throws TransactionException {
-        ((XAItemStateManager) stateMgr).prepare(tx);
+        if (vmgrLocked) {
+            ((XAItemStateManager) stateMgr).prepare(tx);
+        }
     }
 
     /**
@@ -473,9 +475,11 @@
      * global repository manager to update its caches.
      */
     public void commit(TransactionContext tx) throws TransactionException {
-        ((XAItemStateManager) stateMgr).commit(tx);
-        Map xaItems = (Map) tx.getAttribute(ITEMS_ATTRIBUTE_NAME);
-        vMgr.itemsUpdated(xaItems.values());
+        if (vmgrLocked) {
+            ((XAItemStateManager) stateMgr).commit(tx);
+            Map xaItems = (Map) tx.getAttribute(ITEMS_ATTRIBUTE_NAME);
+            vMgr.itemsUpdated(xaItems.values());
+        }
     }
 
     /**
@@ -484,7 +488,9 @@
      * Delegate the call to our XA item state manager.
      */
     public void rollback(TransactionContext tx) {
-        ((XAItemStateManager) stateMgr).rollback(tx);
+        if (vmgrLocked) {
+            ((XAItemStateManager) stateMgr).rollback(tx);
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/AbstractConcurrencyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/AbstractConcurrencyTest.java?rev=637865&r1=637864&r2=637865&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/AbstractConcurrencyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/AbstractConcurrencyTest.java
Mon Mar 17 05:47:35 2008
@@ -108,7 +108,7 @@
         boolean stacksDumped = false;
         for (int i = 0; i < threads.length; i++) {
             try {
-                long wait = Math.max(timeout - System.currentTimeMillis(), 1);
+                long wait = Math.max(timeout - System.currentTimeMillis(), 1000);
                 threads[i].join(wait);
                 if (threads[i].isAlive()) {
                     if (!stacksDumped) {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/RandomOperationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/RandomOperationTest.java?rev=637865&r1=637864&r2=637865&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/RandomOperationTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/RandomOperationTest.java
Mon Mar 17 05:47:35 2008
@@ -24,7 +24,9 @@
 
 /**
  * <code>RandomOperationTest</code> executes randomly chosen operations using
- * multiple threads.
+ * multiple threads. Each thread operates on its own subtree to avoid
+ * conflicting changes.
+ * <p/>
  * Please note that this test is disabled by default!
  * You can enable them by setting {@link #NUM_THREADS} to 1 or higher.
  */
@@ -55,6 +57,11 @@
      */
     private static final int NODES_PER_LEVEL = 3;
 
+    /**
+     * While creating nodes, save whenever 1000 nodes have been created.
+     */
+    private static final int SAVE_INTERVAL = 1000;
+
     private long end;
 
     protected void setUp() throws Exception {
@@ -63,46 +70,56 @@
     }
 
     public void testRandomContentOperations() throws RepositoryException {
-        runTask(new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL, end), NUM_THREADS);
+        runTask(new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL, SAVE_INTERVAL, end),
NUM_THREADS);
     }
 
     public void testRandomContentOperationsXA() throws RepositoryException {
-        ContentOperationsTask task = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
end);
+        ContentOperationsTask task = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
SAVE_INTERVAL, end);
         task.setUseXA(true);
         runTask(task, NUM_THREADS);
     }
 
     public void testRandomVersionOperations() throws RepositoryException {
-        runTask(new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL, end), NUM_THREADS);
+        runTask(new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL, SAVE_INTERVAL, end),
NUM_THREADS);
     }
 
     public void testRandomVersionOperationsXA() throws RepositoryException {
-        VersionOperationsTask task = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
end);
+        VersionOperationsTask task = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
SAVE_INTERVAL, end);
         task.setUseXA(true);
         runTask(task, NUM_THREADS);
     }
 
     public void testContentAndVersionOperations() throws RepositoryException {
         runTasks(new Task[]{
-            new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL, end),
-            new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL, end)
+            new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL, SAVE_INTERVAL, end),
+            new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL, SAVE_INTERVAL, end)
         }, NUM_THREADS, end + MAX_WAIT_SECONDS * 1000);
     }
 
     public void testContentAndVersionOperationsXA() throws RepositoryException {
-        ContentOperationsTask task1 = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
end);
+        ContentOperationsTask task1 = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
SAVE_INTERVAL, end);
         task1.setUseXA(true);
-        VersionOperationsTask task2 = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
end);
+        VersionOperationsTask task2 = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
SAVE_INTERVAL, end);
         task2.setUseXA(true);
         runTasks(new Task[]{task1, task2}, NUM_THREADS, end + MAX_WAIT_SECONDS * 1000);
     }
 
     public void testContentAndVersionOperationsXAMixed() throws RepositoryException {
-        ContentOperationsTask task1 = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
end);
-        ContentOperationsTask task2 = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
end);
+        ContentOperationsTask task1 = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
SAVE_INTERVAL, end);
+        ContentOperationsTask task2 = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
SAVE_INTERVAL, end);
+        task2.setUseXA(true);
+        VersionOperationsTask task3 = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
SAVE_INTERVAL, end);
+        VersionOperationsTask task4 = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
SAVE_INTERVAL, end);
+        task4.setUseXA(true);
+        runTasks(new Task[]{task1, task2, task3, task4}, NUM_THREADS, end + MAX_WAIT_SECONDS
* 1000);
+    }
+
+    public void testContentAndVersionOperationsXAMixedShortSaveInterval() throws RepositoryException
{
+        ContentOperationsTask task1 = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
1, end);
+        ContentOperationsTask task2 = new ContentOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
1, end);
         task2.setUseXA(true);
-        VersionOperationsTask task3 = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
end);
-        VersionOperationsTask task4 = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
end);
+        VersionOperationsTask task3 = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
1, end);
+        VersionOperationsTask task4 = new VersionOperationsTask(NUM_LEVELS, NODES_PER_LEVEL,
1, end);
         task4.setUseXA(true);
         runTasks(new Task[]{task1, task2, task3, task4}, NUM_THREADS, end + MAX_WAIT_SECONDS
* 1000);
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/CreateNodes.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/CreateNodes.java?rev=637865&r1=637864&r2=637865&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/CreateNodes.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/CreateNodes.java
Mon Mar 17 05:47:35 2008
@@ -38,15 +38,19 @@
 
     private final String[] mixins;
 
+    private final int saveInterval;
+
     public CreateNodes(Session s,
                        String path,
                        int numLevels,
                        int nodesPerLevel,
-                       String[] mixins) {
+                       String[] mixins,
+                       int saveInterval) {
         super(s, path);
         this.numLevels = numLevels;
         this.nodesPerLevel = nodesPerLevel;
         this.mixins = mixins;
+        this.saveInterval = saveInterval;
     }
 
     /**
@@ -64,9 +68,10 @@
         levels--;
         for (int i = 0; i < nodesPerLevel; i++) {
             Node child = n.addNode("node" + i);
+            count++;
             addMixins(child);
             log.info("Create node {}", child.getPath());
-            if (count % 1000 == 0) {
+            if (count % saveInterval == 0) {
                 getSession().save();
                 log.debug("Created " + (count / 1000) + "k nodes");
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/OperationFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/OperationFactory.java?rev=637865&r1=637864&r2=637865&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/OperationFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/operation/OperationFactory.java
Mon Mar 17 05:47:35 2008
@@ -175,8 +175,10 @@
     public Operation createNodes(String path,
                                  int numLevels,
                                  int nodesPerLevel,
-                                 String[] mixins) {
-        return new CreateNodes(session, path, numLevels, nodesPerLevel, mixins);
+                                 String[] mixins,
+                                 int saveInterval) {
+        return new CreateNodes(session, path, numLevels,
+                nodesPerLevel, mixins, saveInterval);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java?rev=637865&r1=637864&r2=637865&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/ContentOperationsTask.java
Mon Mar 17 05:47:35 2008
@@ -26,8 +26,9 @@
  */
 public class ContentOperationsTask extends RandomOperationsTask {
 
-    public ContentOperationsTask(int numLevels, int nodesPerLevel, long end) {
-        super(new String[0], numLevels, nodesPerLevel, end);
+    public ContentOperationsTask(int numLevels, int nodesPerLevel,
+                                 int saveInterval, long end) {
+        super(new String[0], numLevels, nodesPerLevel, saveInterval, end);
     }
 
     protected Operation getRandomOperations(OperationFactory f,

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java?rev=637865&r1=637864&r2=637865&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/RandomOperationsTask.java
Mon Mar 17 05:47:35 2008
@@ -36,14 +36,18 @@
 
     private final int nodesPerLevel;
 
+    private final int saveInterval;
+
     private final long end;
 
     private boolean useXA = false;
 
-    public RandomOperationsTask(String mixins[], int numLevels, int nodesPerLevel, long end)
{
+    public RandomOperationsTask(String mixins[], int numLevels,
+                                int nodesPerLevel, int saveInterval, long end) {
         this.mixins = mixins;
         this.numLevels = numLevels;
         this.nodesPerLevel = nodesPerLevel;
+        this.saveInterval = saveInterval;
         this.end = end;
     }
 
@@ -51,7 +55,8 @@
         try {
             OperationFactory f = new OperationFactory(session);
             // create nodes
-            f.createNodes(test.getPath(), numLevels, nodesPerLevel, mixins).execute();
+            f.createNodes(test.getPath(), numLevels, nodesPerLevel,
+                    mixins, saveInterval).execute();
             // save nodes
             f.save(test.getPath()).execute();
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java?rev=637865&r1=637864&r2=637865&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/random/task/VersionOperationsTask.java
Mon Mar 17 05:47:35 2008
@@ -26,8 +26,10 @@
  */
 public class VersionOperationsTask extends RandomOperationsTask {
 
-    public VersionOperationsTask(int numLevels, int nodesPerLevel, long end) {
-        super(new String[]{"mix:versionable"}, numLevels, nodesPerLevel, end);
+    public VersionOperationsTask(int numLevels, int nodesPerLevel,
+                                 int saveInterval, long end) {
+        super(new String[]{"mix:versionable"}, numLevels, nodesPerLevel,
+                saveInterval, end);
     }
 
     protected Operation getRandomOperations(OperationFactory f,



Mime
View raw message