[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-1087) Synchronization during JTA afterCompletion() incompatible with Hibernate-Core

Eli Colner (JIRA) noreply at atlassian.com
Tue Apr 3 19:42:48 EDT 2012


    [ https://hibernate.onjira.com/browse/HSEARCH-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46176#comment-46176 ] 

Eli Colner commented on HSEARCH-1087:
-------------------------------------

I modified line #80 of org.hibernate.search.backend.impl.EventSourceTransactionContext as a hack fix.

It went from:
eventSource.getTransaction().registerSynchronization(new BeforeCommitSynchronizationDelegator( synchronization ));

to:
synchronization.beforeCompletion();

I'm not sure if invoking the synchronization immediately rather than queuing it on the synchronizations list is allowed, but we're in the context of an in-progress transaction, so I assume it's ok.


> Synchronization during JTA afterCompletion() incompatible with Hibernate-Core
> -----------------------------------------------------------------------------
>
>                 Key: HSEARCH-1087
>                 URL: https://hibernate.onjira.com/browse/HSEARCH-1087
>             Project: Hibernate Search
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 4.0.0.Final
>            Reporter: Eli Colner
>            Priority: Critical
>              Labels: hibernate, search, transaction
>
> During synchronization Hibernate Core's SessionImpl.close() calls org.hibernate.engine.transaction.internal.TransactionCoordinator.close() which in-turns calls org.hibernate.engine.transaction.internal.TransactionCoordinator.reset().  During the reset the transactionCoordinator calls org.hibernate.engine.transaction.internal.SynchronizationRegistry.clearSynchronizations().  The synchronizations list is emptied and nulled.  This removes the BeforeCommitSynchronizationDelegator instance that was registered from org.hibernate.search.backend.impl.EventSourceTransactionContext.registerSynchronization() during the JTA transaction.  Clearing the synchronization list causes a ConcurrentModificationException to be thrown from org.hibernate.search.backend.impl.SynchronizationRegistryImpl.notifySynchronizationsAfterTransactionCompletion() because it is iterating the synchronization list and at the start it contains two Synchronization instances in this order (EntityManagerImpl.Synchronization, BeforeCommitSynchronizationDelegator).  So, basically the first Synchronization is removing the second Synchronization while in a loop...
> ARJUNA016029: SynchronizationImple.afterCompletion - failed for org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization at 192e31c with exception
> java.util.ConcurrentModificationException
> 	at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:373)
> 	at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java:384)
> 	at org.hibernate.engine.transaction.internal.SynchronizationRegistryImpl.notifySynchronizationsAfterTransactionCompletion(SynchronizationRegistryImpl.java:78)
> 	at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.sendAfterTransactionCompletionNotifications(TransactionCoordinatorImpl.java:335)
> 	at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.afterTransaction(TransactionCoordinatorImpl.java:147)
> 	at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.afterCompletion(SynchronizationCallbackCoordinatorImpl.java:126)
> 	at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.afterCompletion(RegisteredSynchronization.java:61)
> 	at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.afterCompletion(SynchronizationImple.java:117)
> 	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:403)
> 	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:104)
> 	at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:159)
> 	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1162)
> 	at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:119)
> 	at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1010)
> 	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
> 	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
> 	at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
> 	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list