Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-786

Race condition in DataContext.localObject()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.2 branch, 2.0 branch, 3.0
    • 3.0M1
    • Core Library
    • None

    Description

      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.

      Attachments

        Activity

          People

            andrus Andrus Adamchik
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: