[hibernate-dev] Exceptions thrown in a tx synchronization are eaten

Sanne Grinovero sanne.grinovero at gmail.com
Wed Mar 24 17:25:15 EDT 2010


interesting,
Hibernate Search is affected by this, but I thought the current
problem was due to the fact that work is being executed in another
thread.
We were planning to fix it by collecting the underlying exception and
rethrow it to the main thread, or optionally have it logged in case of
async work:
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-421

but as far as I remember, this was working properly in the pre-3.1
times when Search was depending on Hibernate 3.2.x - I might be wrong.

Emmanuel made a great point in the book about the fact that you
probably don't want to rollback your business operations on the
database in case of indexing failures - I totally agree with that, so
that sets Search in a special corner regarding this.

Sanne

2010/3/24 Adam Warski <adam at warski.org>:
> Hello,
>
> if a transaction synchronization throws an exception, is it only logged, and not thrown further (see org.hibernate.transaction.JDBCTransaction, line 273). Is there some reason for this?
>
> As Envers uses tx synchronizations quite extensively, when an exception is thrown in the synchronization, I roll back the transaction manually. So, no data is persisted (which is the desired behavior), but the client isn't notified in any way that something went wrong; for the client, the operation behaves as if the tx commited successfully.
>
> I suspect that maybe some applications rely on the fact that the exception is eaten and not re-thrown. If there are no contra-arguments to throw the exceptions, maybe a good solution would be to re-throw the exception is the transaction is already marked for rollback? Or if it was marked for rollback in the synchronization?
>
> The related JIRA issues are:
> http://opensource.atlassian.com/projects/hibernate/browse/HHH-3543
> http://opensource.atlassian.com/projects/hibernate/browse/HHH-4721
>
> By the way, how does Hibernate Search deal with such situations? I looked at PostTransactionWorkQueueSynchronization, and it seems that it's possible that the transaction commits, but the data isn't indexed properly, if the queueingProcessor.performWorks throws an exception?
>
> --
> Adam Warski
> http://www.warski.org
> http://www.softwaremill.eu
>
>
>
>
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>




More information about the hibernate-dev mailing list