db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: Mixture of optimistic and pessimistic transactions?
Date Fri, 14 Apr 2006 01:49:48 GMT
Hi Jörg,

On Apr 5, 2006, at 2:27 PM, Jörg von Frantzius wrote:

> Hello,
> as it is possible to switch

I think you must mean "to mix", as you cannot change transaction  
types during a transaction.

> transactions between optimistic and pessimistic during runtime,  
> there could theoretically be one pessimistic and one optimistic  
> transaction updating the same table at the same time. The  
> optimistic one would then rely on the pessimistic one to also  
> update any version information.
> Is this scenario supposed to be supported by the spec?

Yes. The usage of the application determines whether optimistic or  
datastore transactions are used, for each transaction.
> We have mappings for version information, but we currently run only  
> pessimistic transactions. JPOX always updates version information  
> when it is mapped in the metadata, be it within an optimistic or  
> pessimistic transaction, supporting the above use case. The  
> updating of the version information causes high probability of  
> database deadlocks for us, though, so I wonder if the version  
> information really must be updated in pessimistic transactions.

In order to detect conflicts, the version information must be updated  
either automatically by the datastore (via triggers on commit) or by  
the JDO implementation. So I'd say the JPOX implementation got it right.

I would wonder about the high probability of deadlocks, though. In my  
experience, this is usually due to improper ordering of database  
updates. What I've found works most reliably is for the JDO  
implementation to keep track of the order of update of instances and  
apply the datastore changes in the same order. [Of course, some re- 
ordering must be done in order not to violate constraints.]

> And yes, we could also remove version information mapping from the  
> metadata.

That's certainly an option if you are using only datastore  
transactions with isolation levels of read-committed or higher.

> Thanks for any hints,
> Jörg

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!

View raw message