Re: Duplicate Key Problem

From: Christian Mittendorf (christian.mittendor..reenet.de)
Date: Fri Jul 21 2006 - 11:55:38 EDT

  • Next message: Øyvind Harboe: "Re: UUID as primary key"

    Am 21.07.2006 um 17:16 schrieb Gentry, Michael ((Contractor)):

    > Glad it is working right now. Are you using the new MySQL adapter
    > Andrus put together for you?

    No, not yet. We thought we will give it a try next week.

    > Yes, Cayenne will catch the exception for the lost connection and
    > try to
    > automatically reconnect. That might be better than the JDBC driver
    > auto-reconnecting, since Cayenne will know something "bad"
    > happened. I
    > don't know that this feature is documented anywhere. I discovered
    > it by
    > accident. I was testing my application on my laptop and had left it
    > running inside Eclipse. When I went home, I put the laptop in standby
    > mode totally forgetting about the application. Came back the next
    > morning and tried using the application again and saw an exception
    > with
    > Cayenne handling it and automatically reconnecting. This also works
    > well in deployment, since it will auto-reconnect when the DB server is
    > rebooted.

    That behaviour does fit perfectly to the picture we experienced. It
    seems as if
    the mysql connection is lost from time to time and that the mysql jdbc
    driver did reconnect "in the background" automatically. Giving
    Cayenne no
    chance to recognize the lost. Cayenne would in that case continue to
    work
    and in the meantime some other process grabbed the same package of
    primary keys
    and our problems started.

    Besides, I still haven't seen any "Duplicate key" messages from our
    systems!

    Thanks to all for this helpful discussion!

    Christian

    > /dev/mrg
    >
    >
    > -----Original Message-----
    > From: Christian Mittendorf [mailto:christian.mittendor..reenet.de]
    > Sent: Friday, July 21, 2006 11:09 AM
    > To: cayenne-use..ncubator.apache.org
    > Subject: Re: Duplicate Key Problem
    >
    >
    >
    > Am 21.07.2006 um 16:14 schrieb Gentry, Michael ((Contractor)):
    >
    >> 4.0.12 of MySQL. I think autoReconnect=false is a good thing to try,
    >> since Cayenne will catch connection exceptions and try to
    >> reconnect on
    >> its own.
    >
    > From what I can see so far, after we updated all apps some hours
    > ago, it
    > seems to be working fine.
    >
    > How would Cayenne handle a lost connection? Would that result into an
    > Exception or would Cayenne take care, try to reconnect and try to
    > work as
    > expected?
    >
    > Is there some documentation available or do I have to play "Read the
    > source, Luke", as Obi-Wan liked to say ;-)
    >
    > Thanks and have a nice weekend!
    >
    > Christian
    >
    >
    >
    >
    >>
    >> Thanks,
    >>
    >> /dev/mrg
    >>
    >>
    >>
    >> -----Original Message-----
    >> From: Christian Mittendorf [mailto:christian.mittendor..reenet.de]
    >> Sent: Friday, July 21, 2006 9:56 AM
    >> To: cayenne-use..ncubator.apache.org
    >> Subject: Re: Duplicate Key Problem
    >>
    >>
    >> Am 13.07.2006 um 20:35 schrieb Andrus Adamchik:
    >>
    >>> BTW, I tried to reproduce PK generator getting an incorrect PK
    >>> range on MySQL by emulating some load via JMeter. It never happens
    >>> (at least on a single VM instance). I wrote a test case that throws
    >>> an exception randomly on committing the user transaction. Still the
    >>> application was able to recover from failed transactions and carry
    >>> on processing other requests.
    >>
    >> May it be that the version of MySQL has some affects on what we
    >> experience? We are currently using 5.0.18.
    >>
    >>
    >>> I am curious what Michael finds in his tests.
    >>
    >> Me too, are there any results available?
    >>
    >>
    >>> Anyways, I went ahead and added an explicit commit to the PK
    >>> generator (that code, although I couldn't make it fail, still
    >>> looked suspect) and posted new jars here:
    >>>
    >>> http://dev.objectstyle.org/~andrus/cayenne-07132006/
    >>>
    >>> Christian, I would appreciate if you could try this in your
    >>> application and see if you still get those errors.
    >>
    >> We will update some applications in the next week, we haven't found
    >> the time to do so this week.
    >>
    >> But there was some other idea we had discussed recently. At the
    >> moment all of our apps use the "autoReconnect=true" feature of the
    >> jdbc driver and after some discussions with colleagues we updated the
    >> config to use "autoReconnect=false". If our problem is related to
    >> MySQL loosing the connection I would expect to get some kind of "Lost
    >> connection" errors instead of duplicate key messages.
    >>
    >>
    >> Christian
    >>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Fri Jul 21 2006 - 11:56:05 EDT