[OJB-developers] Re: Bug in SequenceManager!!
Brought to you by:
thma
|
From: Thomas M. <tho...@ho...> - 2001-11-03 17:20:43
|
Hi Satish, Sorry for the problems OJB is causing! This is really a severe bug. I'll have a look at it asap and will keep you updated. --Thomas sa...@na... wrote: > > Hi Thomas, > > I have run into a particularly simple but nasty bug with > SequenceManager very much on the same lines as the previous bugs I ran > into with stale connections. > > Basically, several database records have been overwritten (and have > several people annoyed at me right now) as follows: > > I use broker.getUniqueId(classname) to get the next id from OJB_SEQ > table. However, broker.getUniqueId(..) calls > m_Sequencemanager.getUniqueId(..) in > singlevm/PersistenceBrokerDefaultImpl.java. > > The m_SequenceManager in the broker instance is obtained by using > SequenceManagerFactory.getSequenceManager(this) in the broker > constructor. > > However, SequenceManagerFactory.getSequenceManager(broker) returns the > static SEQMAN that it has created the first time it was used. The > broker argument is not used except for the first time. So, SEQMAN uses > a broker instance that will potentially become stale due to idle > connection timeout in mysql. Even without the timeouts, > brokerInstance3.getUniqueId(..) will use brokerInstance1 for actually > reading the next id from the db which does not seem right. > > One fix that will be thread-safe is to add broker as an argument to > SequenceManager.getUniqueId(classname, fieldname, broker). > > Let me know what you think. > > If you do have a quick fix/workaround for this, please let me know. > I am under the gun right now. > > ----------------------------------------------------------------- > > Now if you are interested, here is how several records have been > overwritten due to this bug: > > After a while after the web server was started, the cached broker > instance in SEQMAN became stale and stopped updating (lets say > sequence number = 50), the OJB_SEQ table. However, due to poor > exception/error handling in SequenceManagerDefaultImpl.getNextId(), > getNextId() returned the in-memory copy of lastId+1 and hence > everything seemed to be ok and did not throw the exception back to the > application. > > Now, a few days later (lets say we were at seq# = 150 at this time), > the web server was restarted to update to ojb-0.5.200 and then the bad > value (50) was read from OJB_SEQ and was updated for a while. So, the > entries starting at 50 started getting overwritten. > > Thanks, > Satish. > > -- > Get your firstname@lastname email for FREE at http://Nameplanet.com/?su |