Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 1351 invoked from network); 4 Mar 2009 11:18:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Mar 2009 11:18:58 -0000 Received: (qmail 90387 invoked by uid 500); 4 Mar 2009 11:18:57 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 90291 invoked by uid 500); 4 Mar 2009 11:18:57 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 90262 invoked by uid 99); 4 Mar 2009 11:18:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Mar 2009 03:18:56 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Wed, 04 Mar 2009 11:18:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 002BE2388A0E; Wed, 4 Mar 2009 11:18:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r749965 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java Date: Wed, 04 Mar 2009 11:18:35 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090304111836.002BE2388A0E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Wed Mar 4 11:18:35 2009 New Revision: 749965 URL: http://svn.apache.org/viewvc?rev=749965&view=rev Log: JCR-2000: Deadlock on concurrent commits Create test nodes within a transaction to avoid mixing transactional and non-transactional writes. Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java?rev=749965&r1=749964&r2=749965&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningWithTransactionsTest.java Wed Mar 4 11:18:35 2009 @@ -46,6 +46,27 @@ */ private static final int NUM_OPERATIONS = 100; + /** + * Creates the named test node. The node is created within a transaction + * to avoid mixing transactional and non-transactional writes within a + * concurrent test run. + */ + private static synchronized Node createParentNode(Node test, String name) + throws RepositoryException { + try { + UserTransaction utx = new UserTransactionImpl(test.getSession()); + utx.begin(); + Node parent = test.addNode(name); + test.save(); + utx.commit(); + return parent; + } catch (RepositoryException e) { + throw e; + } catch (Exception e) { + throw new RepositoryException("Failed to add node: " + name, e); + } + } + public void testConcurrentAddVersionableInTransaction() throws RepositoryException { runTask(new Task() { @@ -53,11 +74,7 @@ throws RepositoryException { // add versionable nodes final String threadName = Thread.currentThread().getName(); - Node parent; - synchronized (ConcurrentVersioningWithTransactionsTest.class) { - parent = test.addNode(threadName); - test.save(); - } + Node parent = createParentNode(test, threadName); for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) { try { final UserTransaction utx = new UserTransactionImpl(test.getSession());