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:
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.
"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>"