Re: PK problem with Postgre

From: Jeff de Vries (jdevrie..frog.com)
Date: Sat Apr 22 2006 - 16:41:51 EDT

  • Next message: Joel Trunick: "Null Pointer Exception"

    We haven't upgraded to M12-B1 yet. We'll do that and see what happens.

    This has only happened maybe 3-4 times, under very light load
    (basically a single user doing web interaction testing, though each
    interaction would hit maybe 5-6 interrelated tables).

    Naturally, it occurred once during a demo to upper management! :-(

    Jeff

    On Apr 22, 2006, at 12:23 AM, Andrus Adamchik wrote:

    > Jeff,
    >
    > I am not sure if there was a race condition before, but since ~ M12-
    > B1 PK generator operates under slightly different conditions, being
    > tied to the commit transaction in progress. So have you seen this
    > problem recently?
    >
    > Andrus
    >
    >
    > On Apr 22, 2006, at 9:32 AM, Jeff de Vries wrote:
    >
    >> I have had this problem as well. I'm using the "standard" value
    >> of 20 (meaning I haven't changed anything from the defaults), and
    >> I can see Cayenne query for the sequence value, followed by 20
    >> insertions using a value incremented by Cayenne, etc.
    >>
    >> When the problem happens, I've gone and looked at the sequence
    >> value in the database, and found, say, a value of 740, but there
    >> is already an existing record with a value of 740 as a primary
    >> key, so when Cayenne fetches the db sequence value of 740 and
    >> tries to use it, I get the "duplicate key" error below.
    >>
    >> At this point I haven't been able to pinpoint any particular set
    >> of events leading up to the problem (other than occasionally we
    >> crash [for other reasons] and perhaps that leaves something funky?).
    >>
    >> In my pre-Cayenne days I always left the primary key field
    >> unspecified and let PostgreSQL handle the incrementing.
    >>
    >> Jeff
    >>
    >>
    >> On Apr 20, 2006, at 6:43 AM, WONDER wrote:
    >>
    >>> Hi,
    >>>
    >>> I have problem with PostGreSQL ver 8.1.3 using JDBC ver
    >>> 8.2dev-501 JDBC 3
    >>> and Cayenne 1.2.B2.
    >>>
    >>> I use the Default Strategy to create the PKs using Cayenne. in
    >>> the DB, i
    >>> created the SEQ : pk_TableName. like pk_image for Table image.
    >>>
    >>> Sometimes I get the following error and sometimes it just work.
    >>> Till now, I coulding find the logic behind.
    >>>
    >>> Anybody can help?
    >>> Thanks.
    >>>
    >>> -------------------------------------------------
    >>> Priority : INFO
    >>>
    >>> Class.Method(line):
    >>> org.objectstyle.cayenne.access.QueryLogger.logQueryError
    >>> (QueryLogger.java:43
    >>> 9)
    >>>
    >>> Message: *** error.
    >>>
    >>> org.postgresql.util.PSQLException: ERROR: duplicate key violates
    >>> unique
    >>> constraint "image_pk"
    >>>
    >>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Sat Apr 22 2006 - 16:42:28 EDT