openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey (JIRA)" <>
Subject [jira] Resolved: (OPENJPA-265) datacache does not get committed when application commit after a query
Date Mon, 25 Jun 2007 08:19:25 GMT


Patrick Linskey resolved OPENJPA-265.

    Resolution: Invalid

OpenJPA's data cache implementation as currently implemented is updated outside the bounds
of the transaction. As such, it is not an XA resource, and does not participate in the transaction
per se. It receives notifications of committed data during an afterCompletion() callback.

Since the cache never receives updates until after a transaction has successfully completed,
there is no opportunity for the cache to be populated with invalid data. However, since the
cache update is not part of the commit itself, it is possible for a cache to have stale data,
if somehow an exception is raised between the commit to the database and the cache update
logic. Since the OpenJPA cache is designed primarily for the optimistic transaction model,
and the cache already handles self-healing in the face of optimistic transaction failures
and stale data, this increased staleness opportunity is unfortunate but not fatal.

It would be possible to change the current implementation (or create a new implementation)
that is transactional. However, there is a significant additional cost to doing this, as all
transactions would then need to be XA transactions. Further, OpenJPA would be taking up two
XA slots, meaning that the two-resource XA optimization would not be available if any other
data sources were added to the XA tx.

DataCache.commit() would be better-named DataCache.notifyOfCommit().

> datacache does not get committed when application commit after a query
> ----------------------------------------------------------------------
>                 Key: OPENJPA-265
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: datacache
>    Affects Versions: 1.0.0
>            Reporter: Daniel Lee
> I'm that sure whether this is a bug or not but what is observed is that the application
commit in the following code does not trigger commit on the datacache.
> =============================================================
>     EntityManagerFactory emf = Persistence.createEntityManagerFactory("demo");
>     EntityManager em = emf.createEntityManager();
>     em.getTransaction().begin();
>     Customer c = (Customer) em.createQuery("select c from Customer c where'Harry
>     em.getTransaction().commit();
> =============================================================
> Is this normal because there is no update?  It make sense that there is no need to flush
on the database, but the datacache has been newly loaded with the customer "Harry Auto" and
the objects that are eagerly related to "Harry Auto".  If datacache is not committed, another
transaction does not see the loaded data in the data cache and will redundantly query the
database again.  Is this a bug or working as design?  Many thanks.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message