Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 90E6810ABE for ; Fri, 27 Sep 2013 19:33:06 +0000 (UTC) Received: (qmail 59014 invoked by uid 500); 27 Sep 2013 19:33:06 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 58999 invoked by uid 500); 27 Sep 2013 19:33:06 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 58988 invoked by uid 99); 27 Sep 2013 19:33:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Sep 2013 19:33:05 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mkienenb@gmail.com designates 74.125.82.174 as permitted sender) Received: from [74.125.82.174] (HELO mail-we0-f174.google.com) (74.125.82.174) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Sep 2013 19:33:01 +0000 Received: by mail-we0-f174.google.com with SMTP id q58so3179825wes.33 for ; Fri, 27 Sep 2013 12:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=se36xN/Is4aVtbzWAgB62iW+aa/MMx4WTXkS9GC2hew=; b=c3JV6r5FRDaN6y3J54fk4JNxdShtNpExzc/6Wxxb4WaD+OiXzCcRZ04SQiUKcC7lWX DzLIaZpVOS+BQaUDPYEwU2b9Hg+8x2+LjyQB0Wr9HR5LWin7cig2JSxsJmLgz8Zcms0G kgMWI8XGMc4t8nFx75Q/rrQ47g6w6wFKsk0F2XYtCon4bVpdAaws5FjYheC+y5RAidY+ FZs9fcUrPu7lxF1BgT9d8KmWTZidI2pJ6p3zyaJ1Gr7Ron7zR+e7yQV/Z5TPqTBlvzlP yjQmXRc0a3DV+DSkjFCyorTw+Y/mkbCyYdjUUOlzE2YdcvAQEeWJlpZUKfP7yQXQWpDl 1uZw== X-Received: by 10.180.73.134 with SMTP id l6mr3976725wiv.16.1380310359951; Fri, 27 Sep 2013 12:32:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.213.8 with HTTP; Fri, 27 Sep 2013 12:32:19 -0700 (PDT) In-Reply-To: References: <5E9091FB-D5B5-47FC-958E-744F41177D8D@objectstyle.org> From: Mike Kienenberger Date: Fri, 27 Sep 2013 15:32:19 -0400 Message-ID: Subject: Re: 3.0 -> 3.1: Committed changes not propagating to other contexts / invalidating objects not removing cached values To: user@cayenne.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org This is probably the biggest unresolved issue still facing me, at least of those I know about. Is one of the 3rd party packages required to make invalidateObjects() work? If not, what should I be using in my configuration to replace the default JavaGroups event bridge? On Tue, Sep 24, 2013 at 9:50 AM, Mike Kienenberger wrote: > On Tue, Sep 24, 2013 at 2:15 AM, Andrus Adamchik wrote: >> Could be because peer context notifications are now asynchronous and you test runs before the change is propagated? Async context synchronization is used for performance reasons and to avoid deadlocks. > > That was one of my first thoughts, so first I set a breakpoint to > insure there was enough time to propagate the changes. Then I traced > through the event notification and found that nothing was registered > to listening for the events. > > >>> It does look like JavaGroupsBridgeFactory gets instantiated as the >>> default event bridge factory, although if I don't have it installed >>> (which I don't) it's replaced by a noop event manager. >> >> That'll be odd. Has to be something in configs. > > The source code indicates that JavaGroups is the default. > > public static final String EVENT_BRIDGE_FACTORY_DEFAULT = > "org.apache.cayenne.event.JavaGroupsBridgeFactory"; > > So, what should I be looking for? I have no event bridge factory > configured in the cayenne*.xml file. This seems to match the > tutorial projects as well as a new empty project I set up. > Furthermore, I see no EventBridgeFactory implementations other than > JavaGroups, JMS, and XMPP bridge factory implementations in the 3.1 > source, all of which require third-party libraries. > > Is a 3rd-party package required for this to work as advertised? > > > >> On Sep 23, 2013, at 11:10 PM, Mike Kienenberger wrote: >> >>> Under 3.0.2, I have a test that creates a local copy of an object in a >>> new DataContext, makes a change to it, commits the change, and then >>> verifies that both the old copy and the new copy match. And this >>> passes. >>> >>> Under 3.1, the old object does not reflect the new changes, although >>> the 3.x docs state that it should by default: >>> >>> http://cayenne.apache.org/docs/3.1/cayenne-guide/performance-tuning.html#caching-and-fresh-data >>> >>> This appears to be because there's nothing listening for the >>> postSnapshotsChangeEvent, maybe because there's an error in my >>> hand-converted modeler test configuration file. >>> >>> It does look like JavaGroupsBridgeFactory gets instantiated as the >>> default event bridge factory, although if I don't have it installed >>> (which I don't) it's replaced by a noop event manager. >>> >>> Ebpp DEBUG [main 09-23 15:42:44] DataRowStore: DataRowStore property >>> cayenne.DataRowStore.snapshot.expiration = 7200 >>> Ebpp DEBUG [main 09-23 15:42:44] DataRowStore: DataRowStore property >>> cayenne.DataRowStore.snapshot.size = 10000 >>> Ebpp DEBUG [main 09-23 15:42:44] DataRowStore: DataRowStore property >>> cayenne.DataRowStore.remote.notify = false >>> Ebpp DEBUG [main 09-23 15:42:44] DataRowStore: DataRowStore property >>> cayenne.DataRowStore.EventBridge.factory = >>> org.apache.cayenne.event.JavaGroupsBridgeFactory >>> >>> >>> So I decided to see whether I could force a refetch for the existing >>> object in the original database using: >>> >>> context.invalidateObjects(this); >>> context.prepareForAccess(this, null, false); >>> >>> prepareForAccess is pulling the old value out of the cachedSnapshots. >>> This is rather unexpected since invalidateObjects() claims clears out >>> the cache. All I see it doing when I step through the values is >>> resetting the persistence state from committed to hollow. I don't >>> see anything in stepping through the code which would remove the cache >>> snapshot for the data context as documented. >>> >>> /** >>> * Invalidates a Collection of persistent objects. This operation >>> only applies to the >>> * objects already committed to the database and does nothing to >>> the NEW objects. It >>> * would remove each object's snapshot from caches and change >>> object's state to >>> * HOLLOW. On the next access to this object, the object will be refetched. >>> */ >>> void invalidateObjects(Collection objects); >>> >>> >>> If I manually remove the item from the cache, then it works, even >>> without prepareForAccess(). >>> >>> ObjectContext context = getObjectContext(); >>> DataContext dataContext = (DataContext)context; >>> dataContext.getObjectStore().getDataRowCache().forgetSnapshot(this.getObjectId()); >>> context.invalidateObjects(this); >>> >>> It seems to me that it's a bug to not invalidate the DataContext >>> DataRowCache snapshot during invalidateObjects(). >>> >>