Issue Details (XML | Word | Printable)

Key: NUCCORE-682
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Unassigned
Reporter: Chris Colman
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Core

Deadlock while detaching all on commit while another thread attempts to get object

Created: 21/Mar/11 08:05 AM   Updated: 09/May/11 09:58 AM   Resolved: 07/Apr/11 08:43 AM
Component/s: Code Structure
Affects Version/s: 3.0.0.m2
Fix Version/s: None

File Attachments: 1. File datanucleus.properties (3 kB)

Environment: Windows XP, Oracle XE, IntelliJ, JVM 1.5

Datastore: Oracle
Severity: Production


 Description  « Hide
Scenario:

Thread A:

Background thread running a Job Manager.

Thread B:

A job has finished which invokes another background thread that sends off an email notification. It accesses some persistent objects to retrieve email server name and user credentials.

The application was running for a couple of days before this occurred so it's reproducibility via a unit test maybe somewhat hard to accomplish but hopefully the stack dump may provide some light as to where the deadlock occurred.

It appears as though the 'detach all on commit' method is executing in the first thread and attempts to synchronize in a backed List method at the same time the second thread is attempting to retrieve a persistent object.

datanucleus.properties file is attached.

jobmgr.JobMgrProxy@1bc6ed3@3152, prio=5, in group 'main', status: 'waiting for monitor entry'
  java.lang.Thread.State: BLOCKED
                blocks Thread-139535@11298
                waiting for Thread-139535@11298
                  at org.datanucleus.store.types.sco.backed.List.toArray(List.java:578)
                  at org.datanucleus.store.fieldmanager.DetachFieldManager.internalFetchObjectField(DetachFieldManager.java:182)
                  at org.datanucleus.store.fieldmanager.AbstractFetchFieldManager.fetchObjectField(AbstractFetchFieldManager.java:103)
                  at org.datanucleus.state.JDOStateManagerImpl.detach(JDOStateManagerImpl.java:3885)
                  at org.datanucleus.ObjectManagerImpl.performDetachAllOnTxnEnd(ObjectManagerImpl.java:3659)
                  at org.datanucleus.ObjectManagerImpl.postCommit(ObjectManagerImpl.java:3732)
                  at org.datanucleus.ObjectManagerImpl$2.transactionCommitted(ObjectManagerImpl.java:341)
                  at org.datanucleus.TransactionImpl.internalPostCommit(TransactionImpl.java:566)
                  at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:343)
                  at org.datanucleus.api.jdo.JDOTransaction.commit(JDOTransaction.java:95)
                  at com.sas.framework.expojo.jdo.JdoPersistenceProvider.commitTx(JdoPersistenceProvider.java:286)
                  at jobmgr.JobMgr.process(JobMgr.java:326)
                  at jobmgr.TaskProxy.process(TaskProxy.java:120)
                  at threads.HeartBeatThread.run(HeartBeatThread.java:186)



Thread-139535@11298, prio=5, in group 'main', status: 'waiting for monitor entry'
  java.lang.Thread.State: BLOCKED
                blocks com.thales.ctip.ipis.model.jobmgr.JobMgrProxy@1bc6ed3@3152
                waiting for jobmgr.JobMgrProxy@1bc6ed3@3152
                  at org.datanucleus.ObjectManagerImpl.findObjectProvider(ObjectManagerImpl.java:811)
                  at org.datanucleus.store.mapped.mapping.PersistableMapping.setObjectAsValue(PersistableMapping.java:515)
                  at org.datanucleus.store.mapped.mapping.PersistableMapping.setObject(PersistableMapping.java:425)
                  at org.datanucleus.store.mapped.mapping.PersistableMapping.setObject(PersistableMapping.java:404)
                  at org.datanucleus.store.rdbms.scostore.RDBMSFKListStore.listIterator(RDBMSFKListStore.java:144)
                  at org.datanucleus.store.mapped.scostore.AbstractListStore.listIterator(AbstractListStore.java:84)
                  at org.datanucleus.store.mapped.scostore.AbstractListStore.iterator(AbstractListStore.java:74)
                  at org.datanucleus.store.types.sco.backed.List.loadFromStore(List.java:243)
                  at org.datanucleus.store.types.sco.backed.List.iterator(List.java:496)
                  at com.acme.performNotify(IpisService.java:136)
                  at com.acme.notifications.EmailNotifier$1.execute(EmailNotifier.java:85)
                  at jobmgr.StateThread.run(StateThread.java:117)


Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 28/Mar/11 04:06 PM
i see nothing implying that DN is deadlocking itself. A PM is not thread-safe, so any "detach" in thread 1 and "find" in thread 2 will be working on different PM/ObjectManagerImpl/Transaction and consequently objects. JobMgrProxy is your object

Chris Colman added a comment - 07/Apr/11 04:14 AM
You can close/delete this issue as it is now resolved - not a DataNucleus problem - put it down to user error :)

I discovered that someone had inadvertently passed a persistent instance from one background thread to another - each thread has its own PM so that was never going to turn out well.