[OJB-developers] High Low Sequence
Brought to you by:
thma
From: Bischof, R. <rai...@ed...> - 2002-03-20 20:51:20
|
All, I just discovered some strange behaviour for the SequenceManagerHighLowImpl : Instances of HighLowSequence are just normal objects, so they are cached. When the system has worked under high load for some time (i.e. used some memory) the Sequence objects may be removed from the default cache because the GC collects them. So they need to be reloaded the next time an identity is generated, and upon reload they are inititlaized with the latest state from the DB. This creates the Sequence objects with a new High value and thus reserves the next set of IDs although the last one was not fully used. This may cause some holes in the sequence, so when you have a grabsize of 5 you may have the following sequence: 1,6,11,16, 21,... The strange looking thing is that you may have chaotic sequences like: 1,2,3,4,6,11,16,21,22,26,... So there is a need to tell PB to cache instances of HighLowSequence forever without giving the GC a chance to collect them. There is a MetaObjectCacheImpl and a PermanentObjectCacheImpl which can be used together to solve this. Just configure PB to use the MetaObjectCacheImpl instead of the default one and initialize the cache with the following code: ( ( MetaObjectCacheImpl ) ObjectCacheFactory.getObjectCache() ).setClassCache( HighLowSequence.class, new PermanentObjectCacheImpl() ); Now you are tied to the given MetaObjectCache, though :-( A better solution would be to implement a Set in the HighLowSequence where all new instances are added so that these objects are not eligible for GC even if the cache reference is only a SoftReference. Regards Rainer Rainer Bischof EDS - Electronic Data Systems European Automotive Solution Center - Distributed Solutions Email: rai...@ed... <mailto:rai...@ed...> Tel: +49 (0) 6142 / 802975 Dial8: 8-969-2975 |