[
https://issues.apache.org/jira/browse/OPENJPA-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12730114#action_12730114
]
Tim McConnell commented on OPENJPA-466:
---------------------------------------
Hi Milosz, here is what I've done over the past couple days. I have two
machines -- Windows XP, Windows 2003 -- each with MySQL (8.3 on one machine,
8.4 on the other machine), DB2 (8.2 and 9.5), and Oracle (10g on both)
installed on them. To reproduce the original problem I use 25000 entities, 6
iterations, and 8 threads in the TestSequence test program. With these settings
I can easily reproduce the failure on both machines on all three databases.
Here are the results of the various patches attached to this JIRA. Note that I
raised the number entities to 40000 to stress each patch (but still used 6
iterations and 8 threads):
1. Patch OPENJPA-466 (attached by you with the change to AbstractJDBCSeq.java):
Failures on all three databases on both machines. Note that the failures
manifest themselves differently on each database. For example the failures on
PostgreSQL show up as
ERROR: duplicate key value violates unique constraint
on Oracle as: ORA-00001: unique constraint (SYSTEM.SYS_C008294) violated
and finally on DB2 as: org.apache.openjpa.persistence.EntityExistsException:
DB2 SQL error: SQLCODE: -803, SQLSTATE: 23505
2. Patch volite.patch only (i.e., no other patches used): Failures on all three
databases on both machines
3. Patch OPENJPA-466-SYNCHRONIZED.patch only (which is a modified version of my
original patch but is what was originally committed to trunk): Success on all
three databases on both machines.
So here are my recommendations:
The OPENJPA-466-SYNCHRONIZED patch works in all scenarios that I've tested it
in. More importantly, it fixed the original problem reported by the user, and
has no adverse impact on performance. Please note as well that that user
environment was an extremely large, high-volume, multi-threaded, multi-core
installation. Not meaning to be overly brusque -- but it simply works in every
scenario that it's been used it. Until or unless someone (other than me as I
don't intend to spend any more time on this JIRA) can provide a scenario where
it does not work it should be committed to trunk and retrofitted to all
previous versions of OpenJPA, and any previously-committed patches should be
reverted. Thanks much
> Primary key constraint violated using (Oracle) sequence to generate ID in
> multithreaded app
> -------------------------------------------------------------------------------------------
>
> Key: OPENJPA-466
> URL: https://issues.apache.org/jira/browse/OPENJPA-466
> Project: OpenJPA
> Issue Type: Bug
> Affects Versions: 1.0.0, 1.0.1, 1.1.0, 1.2.0
> Environment: OpenJPA 1.0.0 (also tried 1.0.1 and 1.1.0-SNAPSHOT)
> Oracle XE 10g (JDBC driver 10.2.0.3.0)
> Windows XP Pro
> Reporter: Frank Le
> Assignee: Milosz Tylenda
> Priority: Blocker
> Fix For: 2.0.0
>
> Attachments: OPENJPA-466-SYNCRONIZED.patch, OPENJPA-466.patch,
> OPENJPA-466.patch, volatile.patch
>
>
> Here's how I annotate the ID:
> @Id
> @SequenceGenerator(name = "FooSeq", sequenceName = "seq_foo",
> allocationSize = 20)
> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "FooSeq")
> private Long id;
> Here's how I create the (Oracle) sequence:
> CREATE SEQUENCE seq_foo START WITH 1 INCREMENT BY 1;
> I get a primary key unique constraint violated in a multithreaded app i.e. it
> doesn't happen in single-threaded!
> You can simply reproduce this error by either create blocking queue or
> blocking thread pool say size 5 to insert 10000+ object.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.