4 Replies Latest reply on Dec 22, 2006 11:53 AM by Itamar Rogel

    PojoCache 2.0: New tree structure, optimistic locking & conc

    Itamar Rogel Newbie

      I'm experiencing a problem which I believe might be related to the new tree structure in PojoCache (i.e., the structure that enables canonical locking). It seems that when using optimistic locking, since attaching an object to the PojoCache will cause a version increment on __JBossInternal__, any concurrent transaction to one that attaches an object (even one that is seemingly unrelated and deals with completely different objects) will fail.

      Consider the following code, out of a small unit test I've created for the purpose ("cache" was configured to use optimistic locking):

       UserTransaction tx = getTransaction();
       FamilyPerson father = createFamilyPerson("Rafael Gallardo", 55);
       cache.attach("/person/test1/father", father);
       Thread otherThread = new Thread () {
       public void run ()
       FamilyPerson otherPerson = createFamilyPerson("Katherine Brendel", 24);
       cache.attach("/other_person/test/1", otherPerson); // auto transactional commit (optimistic locking mode)
       // Start the other thread and make sure it finishes before we commit
       tx.commit() // Fails (RollbackException)

      What's your opinion? Is my suspicion correct? Is this a known issue (I didn't find it in JBoss.org JIRA), or perhaps the intended behaviour?