[jboss-user] [JBossCache] - Re: TreeCache/Hibernate/JBossAS optimistic locking problem

floefliep do-not-reply at jboss.com
Wed Jul 12 06:21:27 EDT 2006


Just checked out the latest Hibernate source from  http://anonhibernate.labs.jboss.com/trunk/Hibernate3, but I can't find a method testNoVersioningProvided() in there ... where should this be included?

Anyway, my guess is still remains: TreeCache doesn't work fine if you mix non-versioning and versioning calls in the same transaction. So either one could fix TreeCache such that DefaultDataVersion.ZERO is again correctly assigned to WorkSpaceNodeImpl when using a non-versioning call, either you pass in via OptimisticTreeCache a DefaultDataVersion.ZERO, as I tried.

Same way, problem nr 2 can be fixed by adding to writeUpdate() and writeLoad():

       if ( source != null ) {
  |                   ...
  | 	} else
  | 	  option.setDataVersion(DefaultDataVersion.ZERO);

and modifying :

	public boolean newerThan(DataVersion dataVersion) {
  | 	   if ( previousVersion == null ) {
  |   	      log.warn( "Unexpected optimistic lock check on inserted data" );
  |                       return false;
  | 	   }
  |                  ...

Replacing the null parameter in writeLoad to currentVersion may have the same effect.


But I'm still confused by the warning issued by the code above. Why shouldn't there be an optimistic lock check on inserted data? Based on what I read in the TreeCache documentation and from what I saw in the code, everything accessed by a transaction is put into it's workspace (both read/write, it seems). At commit time, everything in the workspace is being checked for newer versions against the cache (see org.jboss.cache.interceptors.OptimisticValidatorInterceptor.simpleValidate()) which, as I understand it, boils down to obtaining both optimistic read and write locks, which is neat and exactly what I want.

Being non-familiar with the JBoss code, I may be totally wrong or looking at the wrong root cause, but this is the only explanation IMHO I'm able to see.


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

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



More information about the jboss-user mailing list