openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Ward (JIRA)" <>
Subject [jira] Commented: (OPENJPA-324) The MetaDataRepository class is not thread safe. Initialization under heavy load on a multi CPU/Core systems throws exceptions.
Date Wed, 22 Aug 2007 17:34:30 GMT


Chris Ward commented on OPENJPA-324:

I have tried listing and not list the types in the persistence unit with the same result.
 If you access the EM before doing any real work then it is not a problem, because you have
a single thead that is triggering the load of data into the MetaDataRepository.  I am using
OpenJPA within a web service and I can potentialy have several threads accessing an EMF to
acquire an EM per thread at the same time and performing real work.  Since the metadata is
lazy loaded into the MetaDataRepository you can have multiple threads triggering the load
at the same time.  After looking at the code I was able to exaggerate the problem by adding
a sleep call within the MetaDataRepository to consistently reproduce the problem.  I left
that line commented out in the attached java file.  If you put the line in the same spot in
the old code you should be able to reproduce the problem on a multi core machine.

The first thread to try to load the meta data always succeeds, and all other threads concruently
trying to load the meta data always fail.  Once the meta data has been loaded, all new requests
coming in succeed.  It is only a problem durring the load.

> The MetaDataRepository class is not thread safe.  Initialization under heavy load on
a multi CPU/Core systems throws exceptions.
> --------------------------------------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-324
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 0.9.6, 0.9.7
>         Environment: I have reproduced the problem in Windows and in Solaris.  It only
affects multi core/CPU systems.  I haven't reproduced the problem on single core systems.
> I am using Spring 2.0.2 and OpenJPA 0.9.6 with an Oracle 10g database.
>            Reporter: Chris Ward
>         Attachments:
> OpenJPA's MetaDataRepository fails to load metadata for classess when multiple threads
use the same EntityManagerFactory class to resolve the metadata.  The MetaDataRepository implementation
is not thread safe.The problem only occurrs on multi core or multi processor machines that
can concurrently try to initialize meta data for classes.
> To reproduce the problem I have inserted a sleep statement within the code to help reproduce
the problem consistently.  I have commented out the sleep statement in my deployed version
of the class.
> This bug is sort of related to issue 250.  I have cleaned up all of the synchronization
in the class.  There should be less contention, however it could still be better if a ReentrantReadWriteLock
was used.  I noticed that someone had posted a new MetaDataRepository with a ReentrantReadWriteLock,
but too seems to have the same issues.

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

View raw message