AssertionFailure: Exception releasing cache locks upon After/BeforeTransactionCompletionProcess failure

Description

When a After/BeforeTransactionCompletionProcess fails, we get a stack trace looking like this:

This happens in particular when an exception is thrown upon indexing in Hibernate Search.

I think there are two problems with this behavior:

  1. org.hibernate.AssertionFailure is supposed to indicate "a possible bug in Hibernate". There's nothing here that indicates a bug. In fact, in the case of Hibernate Search, this could simply happen if the connection to Elasticsearch breaks suddenly.

  2. "Exception releasing cache locks" seems related to a specific use of After/BeforeTransactionCompletionProcess.

I think we should rather use a HibernateException with a more generic message, such as "Exception after transaction completion: <message of the exception>"

Environment

None

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Priority

Major
Configure