Hi,

We are encountering a problem with our cache materializing half-baked objects
when under a heavy multi-user load.

We are currently using OJB RC5 and are not in a position to move to 1.0.1 yet,
although in the future we would like to.  We also have a JCS cache configured.

Our problem occurs when you have an object that contains references to 2 or more
collections of other objects.  The code in question is in the
RsIterator.getObjectFromResultSet() method.  A snippet of the code is shown below.
   synchronized (result)
   {
      getCache().enableMaterializationCache();
      getCache().cache(oid, result);
      /*
         * arminw: move LoadedObjectsRegistry to odmg-layer
         */
      // LoadedObjectsRegistry.register(result);
      /**
       * MBAIRD if you have multiple classes mapped to a
       * table, and you query on the base class you could get
       * back NON base class objects, so we shouldn't pass
       * m_cld, but rather the class descriptor for the
       * actual class.
       */
      // fill reference and collection attributes
      ClassDescriptor cld = 
         
getQueryObject().getClassDescriptor().getRepository().getDescriptorFor(result.getClass());
                        // don't force loading of reference
      final boolean unforced = false;
      // Maps ReferenceDescriptors to HashSets of owners
      getBroker().getReferenceBroker().retrieveReferences(result, cld, unforced);
      getBroker().getReferenceBroker().retrieveCollections(result, cld, unforced);
      getCache().disableMaterializationCache();
   }
When we have our object being materialized, it has 2 collections of persistent
objects.  When getCache().cache(oid, result); is called, the object is placed
into a 'local' cache.  When retrieveCollections() is called, it is quite possible
that this same method (getObjectFromResultSet) will be called during the collection
object's materialization.  The materialization of the collection object then
calls getCache().disableMaterializationCache(), which at this point the 'local'
cache contains objects from only one of the collections (the one currently being
processed) plus the original object being materialized.  The
disableMaterializationCache() causes any of the objects in the 'local' cache to
be 'pushed' to the 'real' cache.  But the problem comes because the original
object we are materializing has two collections, one collection has been
retrieved, we are about to retrieve the other, but the original object and
only one of its collections has been pushed to the real cache.  Another thread
may come and steal this invalid data out of the real cache and do nasty things.

Is there a handy solution to this problem?

I am very very sorry for the long post...

Paul Nase


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to