[Opensource] some doubts about transaction

Michael Rimov rimovm at centercomp.com
Sat Aug 3 00:09:25 PDT 2002


At 06:12 PM 8/2/2002 +0000, you wrote:
>Hello guys,
>
>here are some thoughts of mine about the transactions in expresso and the 
>DBObject.localConnection:
>I noticed that you now handle the presence of localConnectin in 
>DBObject.getValidValue(..). At least this is what
>if (o instanceof DBObject) {
>         DBObject dbo = (DBObject)o;
>         if (this.localConnection != null) {
>                 dbo.setConnection(this.localConnection);
>         }
>}...
>seems to do.
>There is another problem though. Let us say that I have started a 
>trasnaction. I create record int table A, then a record in table B that 
>uses some data from the record in A, then I update record A with the B.id 
>that is auto-increment field. However as the transaction is not completed 
>DBObject.getValuedDefault will tell you that such a record does not exist. 
>Why? Because those values must be either in the cash or in the DB. 
>getValuesDefault should use localConnection as well when a trasaction has 
>been started.
>
>if(localConnection!=null && !localConnection.getAutoCommit()) {
>//do not use cache
>} else {
>myValues = CacheManager.getItems(getDBName(), cacheName);
>}
>
>Now, contemplating on DBObject.getValuedDefault some doubts popped into my 
>head. What if someone has added a record in some table X and someone else 
>requests the ValidValues for X, and as these had been stored in the cash 
>already, the call to ValidValues brings outdated info?
>Maybe I am wrong but I just wanted to share my "fears" with you :-).

One thing that I'd check is that whenever a write occurs, the ValidValues 
listen to their particular objects.. if one of the valid value objects 
changes, then the whole cache is cleared.  Would that do what you're 
looking for?

Now, the code patch about if (localConnection != null && 
localConnection.getAutoCommit() I think is a good modification to take care 
of some of the situation you're describing and as a bug fix I'll get it 
committed to CVS.

Thanks for the feedback, and let me know if the CacheListeners accomplish 
what you're looking for!
                                         -Mike




More information about the Opensource mailing list