[JIRA] Created: (CAY-786) Race condition in DataContext.localObject()

From: Andrus Adamchik (JIRA) ("Andrus)
Date: Fri May 04 2007 - 12:39:44 EDT

  • Next message: Tore Halset: "Re: Discussing 1.2.3 and 2.0.3 release"

    Race condition in DataContext.localObject()
    -------------------------------------------

                     Key: CAY-786
                     URL: https://issues.apache.org/cayenne/browse/CAY-786
                 Project: Cayenne
              Issue Type: Bug
              Components: Cayenne Core Library
        Affects Versions: 1.2 [STABLE], 2.0 [STABLE], 3.0
                Reporter: Andrus Adamchik
             Assigned To: Andrus Adamchik
                Priority: Critical
                 Fix For: 1.2 [STABLE], 2.0 [STABLE], 3.0

    I've been trying to track down for some time a uniquing breakage in my production application. The app would randomly throw FaultFailureExceptions for objects resolved via to-one relationships:

    org.apache.cayenne.FaultFailureException: [v.3.0-SNAPSHOT Mar 12 2007 15:24:28] Error resolving fault for ObjectId: <ObjectId:EEE, ID=18> and state (hollow). Possible cause - matching row is missing from the database.
            at org.apache.cayenne.BaseContext.prepareForAccess(BaseContext.java:106)
            
    The exception text is misleading. In fact what happened is that the HOLLOW object being resolved was previously kicked out from the ObjectStore and replaced with another object for the same id. The race condition is in DataContext.localObject():

                Persistent localObject = (Persistent) descriptor.createObject();

                localObject.setObjectContext(this);
                localObject.setObjectId(id);

                getGraphManager().registerNode(id, localObject);

    This entire block of code has to be synchronized. This exception is not very common, as DataContext is normally not reused by many parallel threads... However I've been successfully using a shared DataContext in a read-only high-volume app and it worked very nicely... except for this case. I also suspect that this same race condition may have other visible consequences... I was just able to trfack the most obvious one that results in FFE.

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



    This archive was generated by hypermail 2.0.0 : Fri May 04 2007 - 12:40:27 EDT