[ 
https://issues.apache.org/jira/browse/OPENJPA-453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12716349#action_12716349
 ] 

Craig Russell commented on OPENJPA-453:
---------------------------------------

Ravi, I've given you contributor status on OpenJPA JIRA. Let me know if that 
doesn't work for you.

> The race condition arises from the repeated use of the following logic in 
> enhancement added code (expressed as pseudo code here): 

> [PC object class].pc[SomeMethod] 
>     { 
>     if (pcStateManager == null) 
>         ... do something by default with current values in 
>             this object 
>     else 
>         { 
>         ... use pcStateManager, likely resulting in an 
>             eventual lock, and possibly in a call back to 
>             this object's PersistenceCapable interface 
>             methods 
>         ... 
>         } 
>     } 
         
>The race condition arises because the check of the value of pcStateManager is 
>obtained and used twice in succession without first locking the state manager. 
>Another thread using and having locked the state manager has the time to alter 
>the state of this pc object, including nulling out its pcStateManager 
>reference. 

The use of the multithreaded flag was intended to add a bit of overhead to the 
StateManager in exchange for thread-safe behavior. It's understandable why a 
"context" StateManager lock was used: it prevents many cases of deadlock for 
multithreaded access.

But the footprint of sm->pc seems to be small. Would it be possible to use a 
simple semaphore before calling the pc methods? For example,

    void provideField(PersistenceCapable pc, FieldManager store, int field) {
if (multithreaded) {
        FieldManager beforeFM = _fm;
        _fm = store;
synchronized(this) {
        pc.pcProvideField(field);
}
        // Retaining original FM because of the possibility of reentrant calls
        _fm = beforeFM;
} else {
        FieldManager beforeFM = _fm;
        _fm = store;
        pc.pcProvideField(field);
        // Retaining original FM because of the possibility of reentrant calls
        _fm = beforeFM;
}
    }




> Evicting embedded object nullifies statemanager
> -----------------------------------------------
>
>                 Key: OPENJPA-453
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-453
>             Project: OpenJPA
>          Issue Type: Bug
>         Environment: Kodo 4.1.4, Ms sql server 2005, jTDS 1.2, jdk 1.6
>            Reporter: Christiaan
>            Assignee: David Ezzio
>         Attachments: OpenJPABug453Embedded.zip, openJPATestCase.zip, 
> TestCaseEvictEmbedded.zip
>
>
> I am noticing the following behaviour: If evict() is called on an embedded
> object the statemanager is nullified which is in contrast to non-embedded
> objects. Subsequently, calling JDOHelper.getPersistenceManager() on the
> evicted embedded object returns null. Is this the correct behaviour?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to