Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 68354 invoked from network); 7 Apr 2010 10:04:59 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Apr 2010 10:04:59 -0000 Received: (qmail 39451 invoked by uid 500); 7 Apr 2010 10:04:59 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 39431 invoked by uid 500); 7 Apr 2010 10:04:58 -0000 Mailing-List: contact dev-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 dev@jackrabbit.apache.org Received: (qmail 39424 invoked by uid 99); 7 Apr 2010 10:04:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Apr 2010 10:04:57 +0000 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.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Apr 2010 10:04:54 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 71FC3234C4AB for ; Wed, 7 Apr 2010 10:04:33 +0000 (UTC) Message-ID: <69927466.39391270634673465.JavaMail.jira@brutus.apache.org> Date: Wed, 7 Apr 2010 10:04:33 +0000 (UTC) From: "Jukka Zitting (JIRA)" To: dev@jackrabbit.apache.org Subject: [jira] Updated: (JCR-2579) InvalidItemStateException when attempting concurrent, non conflicting writes In-Reply-To: <705547173.404501269270328748.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/JCR-2579?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jukka Zitting updated JCR-2579: ------------------------------- Fix Version/s: 2.1.0 Assignee: Jukka Zitting > InvalidItemStateException when attempting concurrent, non conflicting writes > ---------------------------------------------------------------------------- > > Key: JCR-2579 > URL: https://issues.apache.org/jira/browse/JCR-2579 > Project: Jackrabbit Content Repository > Issue Type: Bug > Components: jackrabbit-core > Affects Versions: 1.6.1 > Reporter: Dan Diephouse > Assignee: Jukka Zitting > Fix For: 2.1.0 > > > I'm having some problems doing concurrent addition of nodes to a parent node in Jackrabbit. I've attached a simple test which starts up a bunch of threads which add nodes to a parent node concurrently. If I add in locks I can get this to work, however according to the mailing list this should work without locks. However, the test always fails with this: > javax.jcr.InvalidItemStateException: Item cannot be saved because it has been modified externally: node /testParent > at org.apache.jackrabbit.core.ItemImpl.getTransientStates(ItemImpl.java:281) > at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:939) > at org.mule.galaxy.impl.JackrabbitConcurrentWriteTest$1.run(JackrabbitConcurrentWriteTest.java:71) > I'm using Jackrabbit 1.6.1. Here is my (verbose) node type: > isMixin="false" > hasOrderableChildNodes="false" > primaryItemName=""> > > > > > nt:base > mix:referenceable > mix:lockable > > > And my test: > package org.mule.galaxy.impl; > import java.io.File; > import java.io.IOException; > import java.io.InputStream; > import java.util.ArrayList; > import java.util.List; > import java.util.UUID; > import java.util.concurrent.CountDownLatch; > import java.util.concurrent.TimeUnit; > import javax.jcr.LoginException; > import javax.jcr.Node; > import javax.jcr.Repository; > import javax.jcr.RepositoryException; > import javax.jcr.Session; > import javax.jcr.SimpleCredentials; > import junit.framework.TestCase; > import org.apache.commons.io.FileUtils; > import org.apache.jackrabbit.api.JackrabbitNodeTypeManager; > import org.apache.jackrabbit.core.RepositoryImpl; > import org.apache.jackrabbit.core.TransientRepository; > import org.apache.jackrabbit.core.config.RepositoryConfig; > public class JackrabbitConcurrentWriteTest extends TestCase { > > private Repository repository; > private Session session; > private String parentUUID; > private boolean continueLoop = true; > > public void setUp() throws Exception { > FileUtils.deleteDirectory(new File("repository")); > File repoDir = new File("repository"); > repoDir.mkdirs(); > RepositoryConfig config = RepositoryConfig.create(new File("src/test/resources/META-INF/jackrabbit-repo-test.xml"), repoDir); > repository = RepositoryImpl.create(config); > session = createSession(); > > createCustomNodeTypes(session); > > parentUUID = session.getRootNode().addNode("testParent", "galaxy:noSiblings").getUUID(); > session.save(); > session.logout(); > } > private Session createSession() throws LoginException, RepositoryException { > return repository.login(new SimpleCredentials("username", "password".toCharArray())); > } > > public void testConcurrency() throws Exception { > final List exceptions = new ArrayList(); > int threadCount = 20; > final CountDownLatch latch = new CountDownLatch(threadCount); > > for (int i = 0; i < threadCount; i++) { > Thread thread = new Thread() { > @Override > public void run() { > try { > while (continueLoop) { > Session session = createSession(); > try { > Node node = session.getNodeByUUID(parentUUID); > node.addNode(UUID.randomUUID().toString()); > node.save(); > session.save(); > } finally { > session.logout(); > } > } > } catch (RepositoryException e) { > exceptions.add(e); > continueLoop = false; > } > latch.countDown(); > } > > }; > thread.start(); > } > > latch.await(10, TimeUnit.SECONDS); > continueLoop = false; > > for (Exception e : exceptions) { > e.printStackTrace(); > } > assertEquals(0, exceptions.size()); > } > > public void createCustomNodeTypes(Session session) throws RepositoryException, IOException { > // Get the JackrabbitNodeTypeManager from the Workspace. > // Note that it must be cast from the generic JCR NodeTypeManager to > // the Jackrabbit-specific implementation. > // (see: http://jackrabbit.apache.org/node-types.html) > JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager) session.getWorkspace().getNodeTypeManager(); > // Register the custom node types defined in the CND file > InputStream is = Thread.currentThread().getContextClassLoader() > .getResourceAsStream("org/mule/galaxy/impl/jcr/nodeTypes.xml"); > manager.registerNodeTypes(is, JackrabbitNodeTypeManager.TEXT_XML); > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.