[OJB-developers] High Low Sequence
Brought to you by:
thma
From: <Joa...@tp...> - 2002-03-21 11:10:07
|
[snip HighLowSequence objects being GCed, resulting in strange ID sequences] this doesn't result in incorrect behaviour, but I agree that it wastes key-space unnecessarily, which is A Bad Thing. > So there is a need to tell PB to cache instances of HighLowSequence > forever without giving the GC a chance to collect them. > [snip MetaObjectCache solution] > > 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. hm ... such a Set exists. To be more precise, there is a Hashtable in SequenceManagerHighLowImpl that holds all HighLowSequence objects that the SequenceManager has ever used, so they can't be GCed. So I can't see how this behaviour could possibly happen (of course I don't doubt that you saw it, I just can't explain why), unless the SequenceManagerHighLowImpl itself get GCed and re-created (or there are several instances of it). Maybe you're working with the client/server model. 'Cause then there are several singlevm PersistenceBrokers on the server and you get to use a new one each time you issue an command (unless you use and transaction). And since each of these PersistenceBrokers has its own SequenceManager this could result in equally confusing id-sequences (or even more confusing ones, like 1,6,11,2,16,7,3,12,...) Another possible problem with the SequenceManagerHighLowImpl (and possibly the DefaultImpl as well) is that if several PersistenceBroker acessed the same DB there could be race conditions, so we'd need to lock the obj_hl_seq table (or at least one row). The question is wether it is possible/good style to use the ODMG API (which seems the only way to do locking in OJB) within a core class. (I've never actually seen such a race condition and haven't run any tests, but I once noticed it and there don't seem to be any pre-cautions for this; please correct me if I'm wrong). > Regards Rainer regards Joachim Sauer |