You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by idan <id...@gmail.com> on 2010/11/21 14:17:39 UTC
Entity Serialization
Hey,
While implementing my own StoreManager.flush method i encountered a deadlock
caused by the following situation:
My flush method creates a second thread which serializes the persistent
entities which leads to the following stack trace:
Daemon Thread [Thread2] (Suspended)
Unsafe.park(boolean, long) line: not available [native method]
LockSupport.park(Object) line: not available
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterrupt()
line: not available
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(AbstractQueuedSynchronizer$Node,
int) line: not available
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int) line:
not available
ReentrantLock$NonfairSync.lock() line: not available
ReentrantLock.lock() line: not available
FinalizingBrokerImpl(BrokerImpl).lock() line: 4366
FinalizingBrokerImpl(BrokerImpl).beginOperation(boolean) line: 1893
FinalizingBrokerImpl(BrokerImpl).isActive() line: 1865
DetachManager.flushDirty(StateManagerImpl) line: 225
DetachManager.preSerialize(StateManagerImpl) line: 92
StateManagerImpl.serializing() line: 1454
Pet.pcSerializing() line: not available
Pet.writeObject(ObjectOutputStream) line: not available
GeneratedMethodAccessor14.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
The main thread waits until the 2nd thread finishes but the 2nd thread is
stuck since the 1st one locked FinalizingBrokerImpl...
Is there a way to serialize my entities without passing through OpenJPA's
code?
--
View this message in context: http://openjpa.208410.n2.nabble.com/Entity-Serialization-tp5760119p5760119.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: Entity Serialization
Posted by idan <id...@gmail.com>.
Heya,
This actually works :-)
Thanks!
--
View this message in context: http://openjpa.208410.n2.nabble.com/Entity-Serialization-tp5760119p5770018.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: Entity Serialization
Posted by idan <id...@gmail.com>.
Hey Rick thanks for your reply.
I thought of doing so but didn't really know if its possible :-)
I'll give it a try and post my results.
Thanks,
Idan
--
View this message in context: http://openjpa.208410.n2.nabble.com/Entity-Serialization-tp5760119p5763216.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: Entity Serialization
Posted by Rick Curtis <cu...@gmail.com>.
Idan -
Perhaps you could remove the StateManager from each Entity before you
serialize it, then put the SM back when you're done? I'm not entirely sure
the implications of doing this when/if you have fields which are proxied
types (ie: Collection, Map).
This is just off the top of my head, so take it as direction.... not an
answer. :-)
public Collection<Exception> flush(Collection<OpenJPAStateManager>
states) {
for (OpenJPAStateManager sm : states) {
PersistenceCapable pc = sm.getPersistenceCapable();
pc.pcReplaceStateManager(null);
// serialize here
pc.pcReplaceStateManager(sm);
}
Thanks,
Rick
On Sun, Nov 21, 2010 at 7:17 AM, idan <id...@gmail.com> wrote:
>
> Hey,
>
> While implementing my own StoreManager.flush method i encountered a
> deadlock
> caused by the following situation:
> My flush method creates a second thread which serializes the persistent
> entities which leads to the following stack trace:
> Daemon Thread [Thread2] (Suspended)
> Unsafe.park(boolean, long) line: not available [native method]
> LockSupport.park(Object) line: not available
>
>
> ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterrupt()
> line: not available
>
>
> ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(AbstractQueuedSynchronizer$Node,
> int) line: not available
> ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int)
> line:
> not available
> ReentrantLock$NonfairSync.lock() line: not available
> ReentrantLock.lock() line: not available
> FinalizingBrokerImpl(BrokerImpl).lock() line: 4366
> FinalizingBrokerImpl(BrokerImpl).beginOperation(boolean) line: 1893
> FinalizingBrokerImpl(BrokerImpl).isActive() line: 1865
> DetachManager.flushDirty(StateManagerImpl) line: 225
> DetachManager.preSerialize(StateManagerImpl) line: 92
> StateManagerImpl.serializing() line: 1454
> Pet.pcSerializing() line: not available
> Pet.writeObject(ObjectOutputStream) line: not available
> GeneratedMethodAccessor14.invoke(Object, Object[]) line: not
> available
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not
> available
> Method.invoke(Object, Object...) line: not available
>
> The main thread waits until the 2nd thread finishes but the 2nd thread is
> stuck since the 1st one locked FinalizingBrokerImpl...
>
> Is there a way to serialize my entities without passing through OpenJPA's
> code?
>