You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Dave Lamy <da...@gmail.com> on 2011/04/27 22:58:23 UTC

Exception/rollback behavior question

In a clustered project of ours we are sometimes seeing Postgres throw a
deadlock exception, most likely because two concurrent updates are trying to
update related rows in different orders.  According to the Postgres docs,
the "easy" thing to do in this case is to retry the transaction that threw
the deadlock.  Question is, if I catch the deadlock exception and then
recommit, are all of the modification states still intact?  Or is there an
intrinsic rollback that occurs before I have a chance to retry the commit?

Thanks in advance for your help--
Dave Lamy

Re: Exception/rollback behavior question

Posted by Michael Gentry <mg...@masslight.net>.
Hi Dave,

When you do a dataContext.commitChanges() and an exception is thrown,
your DataContext (and all the objects it manages) is left unchanged.
No implicit rollback is done by Cayenne.  (You can do an explicit one
yourself in the exception handler if you like or try to re-commit or
inform the user of the error or whatever else makes sense for your
use-case.)

mrg


On Wed, Apr 27, 2011 at 4:58 PM, Dave Lamy <da...@gmail.com> wrote:
> In a clustered project of ours we are sometimes seeing Postgres throw a
> deadlock exception, most likely because two concurrent updates are trying to
> update related rows in different orders.  According to the Postgres docs,
> the "easy" thing to do in this case is to retry the transaction that threw
> the deadlock.  Question is, if I catch the deadlock exception and then
> recommit, are all of the modification states still intact?  Or is there an
> intrinsic rollback that occurs before I have a chance to retry the commit?
>
> Thanks in advance for your help--
> Dave Lamy
>