[jboss-user] [JBossCache] - PojoCache 2.0: New tree structure, optimistic locking & conc

chasta do-not-reply at jboss.com
Wed Dec 20 10:25:17 EST 2006


Hi,
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();
  |       tx.begin();
  | 
  |       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
  |       otherThread.start();
  |       otherThread.join();
  | 
  |       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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995316#3995316

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995316



More information about the jboss-user mailing list