[ https://issues.apache.org/jira/browse/OPENJPA-1716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887817#action_12887817 ]
Stefan Wokusch commented on OPENJPA-1716: ----------------------------------------- Ok, here are two Threads locking each other :: Thread [main] (Suspended) Unsafe.park(boolean, long) line: not available [native method] LockSupport.park(Object) line: 158 ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterrupt() line: 747 ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(AbstractQueuedSynchronizer$Node, int) line: 778 ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int) line: 1114 ReentrantLock$NonfairSync.lock() line: 186 ReentrantLock.lock() line: 262 [local variables unavailable] StateManagerImpl.lock() line: 3305 StateManagerImpl.fetchObjectField(int) line: 2364 StateManagerImpl.fetchObject(int) line: 2357 RelationCollectionTableFieldStrategy(RelationToManyTableFieldStrategy).update(OpenJPAStateManager, JDBCStore, RowManager) line: 194 RelationCollectionTableFieldStrategy.update(OpenJPAStateManager, JDBCStore, RowManager) line: 107 FieldMapping.update(OpenJPAStateManager, JDBCStore, RowManager) line: 699 BatchingConstraintUpdateManager(AbstractUpdateManager).update(OpenJPAStateManager, BitSet, ClassMapping, RowManager, JDBCStore, Collection, boolean) line: 334 BatchingConstraintUpdateManager(AbstractUpdateManager).populateRowManager(OpenJPAStateManager, RowManager, JDBCStore, Collection, Collection) line: 169 BatchingConstraintUpdateManager(AbstractUpdateManager).flush(Collection, JDBCStore, PreparedStatementManager) line: 95 BatchingConstraintUpdateManager(AbstractUpdateManager).flush(Collection, JDBCStore) line: 76 JDBCStoreManager.flush(Collection) line: 751 ROPStoreManager(DelegatingStoreManager).flush(Collection<OpenJPAStateManager>) line: 131 FinalizingBrokerImpl(BrokerImpl).flush(int) line: 2139 FinalizingBrokerImpl(BrokerImpl).flushSafe(int) line: 2037 FinalizingBrokerImpl(BrokerImpl).beforeCompletion() line: 1955 LocalManagedRuntime.commit() line: 81 FinalizingBrokerImpl(BrokerImpl).commit() line: 1479 DelegatingBroker.commit() line: 925 EntityManagerImpl.commit() line: 559 .... Thread [pool-2-thread-1] (Suspended) Unsafe.park(boolean, long) line: not available [native method] LockSupport.park(Object) line: 158 ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterrupt() line: 747 ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(AbstractQueuedSynchronizer$Node, int) line: 778 ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int) line: 1114 ReentrantLock$NonfairSync.lock() line: 186 ReentrantLock.lock() line: 262 FinalizingBrokerImpl(BrokerImpl).lock() line: 4366 FinalizingBrokerImpl(BrokerImpl).beginOperation(boolean) line: 1893 FinalizingBrokerImpl(BrokerImpl).isActive() line: 1865 StateManagerImpl.beforeAccessField(int) line: 1603 StateManagerImpl.accessingField(int) line: 1591 ObjektEntity.pcGetid(ObjektEntity) line: not available TestEntity(ObjektEntity).getId() line: 91 ..... > Deadlock with openjpa.Multithreaded=true > ---------------------------------------- > > Key: OPENJPA-1716 > URL: https://issues.apache.org/jira/browse/OPENJPA-1716 > Project: OpenJPA > Issue Type: Bug > Affects Versions: 2.0.0-M1, 2.0.0-M2, 2.0.0-M3, 2.0.0-beta, 2.0.0-beta2, > 2.0.0-beta3, 2.0.0 > Reporter: Stefan Wokusch > > There is a Deadlock by using Multithreaded=true and work with some Threads on > the same Entitymanager. > After many hours of debugging, i found a solution for that Deadlock: The > Problem could be solved by adding another lock into the lock Method of the > StateManagerImpl: > StateManagerImpl ~line3308 > /** > * Lock the state manager if the multithreaded option is set. > */ > protected void lock() { > if (_instanceLock != null){ > _broker.lock();//<- This is the new Part to fix the Deadlock > _instanceLock.lock(); > } > } > Worked for me without Problems for a long time. > Some other Configurations: > <persistence xmlns="http://java.sun.com/xml/ns/persistence" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> > <persistence-unit name="default" transaction-type="RESOURCE_LOCAL"> > <mapping-file>orm.xml</mapping-file> > > <class>...</class> > <class>...</class> > > <properties> > <property name="openjpa.OrphanedKeyAction" > value="log(Channel=Orphans, Level=TRACE)" /> > <property name="openjpa.ConnectionFactoryProperties" > value="PrettyPrint=true, PrettyPrintLineLength=80" /> > <property name="openjpa.Multithreaded" value="true" /> > <property name="openjpa.InverseManager" value="true" /> > <property name="openjpa.LockManager" value="none" /> > <property name="openjpa.WriteLockLevel" value="none" /> > <property name="openjpa.Compatibility" value=" > QuotedNumbersInQueries=true, > CopyOnDetach=true, > cascadeWithDetach=true, > > superclassDiscriminatorStrategyByDefault=false > " /> > <property name="openjpa.DetachState" > value="fetch-groups" /> > <property name="openjpa.jdbc.SynchronizeMappings" > value="buildSchema" /> > <!-- Default DataSource --> > <property name="openjpa.ConnectionURL" > value="jdbc:h2:db/test" /> > <property name="openjpa.ConnectionDriverName" > value="org.h2.Driver" /> > </properties> > </persistence-unit> > </persistence> -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.