Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle 10 + Sun App Server 7: Unique Constraint Violation?!?

Re: Oracle 10 + Sun App Server 7: Unique Constraint Violation?!?

From: <joeNOSPAM_at_BEA.com>
Date: 15 Nov 2006 08:46:56 -0800
Message-ID: <1163609216.809607.247860@i42g2000cwa.googlegroups.com>

On Nov 15, 12:25 am, "ndamianov" <ndamia..._at_gmail.com> wrote:
> Hi All,
>
> For about a week and a half I have been trying to solve a mysterious
> issue with unique constraint violations on our database server without
> any luck.
>
> We basically have a simple table with a unique primary key (number) and
> a few string columns that aren't part of the key.
>
> With J2EE on the Sun App Server 7, we always make sure we get the
> nextval from the table's sequence before inserting it into the table. I
> have checked this numerous times.
>
> The Oracle DB doesn't have any triggers or other procedures accessing
> the table in any way.
>
> >From time to time, we get a bunch of unique constraint key violationsin spaces of about 30 minutes after which its all good again...
>
> Has anybody heard of this issue or know how to fix it?
>
> Regards,
>
> Nikk

Hi. It sounds like a thread safety issue. If multiple client threads all ask the DBMS what the nextval is, and get the same value, and then all try to send back a new row with that value, you'll get your problem. You could run an experiment where you add a string column, and inert the appserver's java thread ID and a timestamp. Whenever your app gets the unique key violation, query the row for what thread beat you to it, and when.

Joe Weinstein at BEA Systems Received on Wed Nov 15 2006 - 10:46:56 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US