Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 88652 invoked from network); 7 Feb 2006 00:00:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Feb 2006 00:00:53 -0000 Received: (qmail 56981 invoked by uid 500); 7 Feb 2006 00:00:41 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 56964 invoked by uid 99); 7 Feb 2006 00:00:40 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2006 16:00:40 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=MISSING_HEADERS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.43] (HELO brmea-mail-2.sun.com) (192.18.98.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2006 16:00:39 -0800 Received: from fe-amer-05.sun.com ([192.18.108.179]) by brmea-mail-2.sun.com (8.12.10/8.12.9) with ESMTP id k1700J8u028241 for ; Mon, 6 Feb 2006 17:00:19 -0700 (MST) Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0IUA00801ICS0P00@mail-amer.sun.com> (original mail from Craig.Russell@Sun.COM) for jdo-dev@db.apache.org; Mon, 06 Feb 2006 17:00:19 -0700 (MST) Received: from [129.146.30.241] by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0IUA00ACGIOIHQ10@mail-amer.sun.com> for jdo-dev@db.apache.org; Mon, 06 Feb 2006 17:00:18 -0700 (MST) Date: Mon, 06 Feb 2006 16:00:16 -0800 From: Craig L Russell Subject: Re: Cache invalidation In-reply-to: <43E7D379.6010402@tralfamadore.com> Sender: Craig.Russell@Sun.COM Cc: JDO Expert Group , Apache JDO project Message-id: <96D7E819-77DB-41D2-B74A-4FB01C44A07F@Sun.COM> MIME-version: 1.0 X-Mailer: Apple Mail (2.746.2) Content-type: multipart/signed; protocol="application/pkcs7-signature"; boundary=Apple-Mail-283--98056814; micalg=sha1 References: <43E32981.7010807@artnology.com> <43E64533.5060904@tralfamadore.com> <43E6939A.5010502@artnology.com> <43E7D379.6010402@tralfamadore.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --Apple-Mail-283--98056814 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed For the record, I'm not opposed to name changes as long as they are consistent and =20 there is time in the release cycle to implement (trivial). I think =20 the proposal is to change all of the names in the DataStoreCache API =20 to include "ById". Do we care about any users who would be affected? Craig On Feb 6, 2006, at 2:53 PM, Wes Biggs wrote: > I agree that it would be nice to change the method signatures to =20 > "evictById" for those that take OIDs in order to avoid confusion. > > To clarify what I mean about persistent nontransactional objects, =20 > see section 5.6.1 of the spec: > "A persistent-nontransactional instance transitions to persistent-=20 > clean if any managed field > is accessed when a datastore transaction is in progress. The state =20 > of the instance in memory > is discarded and the state is loaded from the datastore." > > If you are running with an optimistic transaction instead, you'll =20 > get an optimistic verification exception at commit time. So I =20 > guess it is possible to read stale data from the instance in the PM =20= > cache under a couple of scenarios: > > 1. Reading previously loaded fields of a P-NT instance outside of a =20= > transaction. > 2. Reading previously loaded fields of a P-NT instance inside an =20 > optimistic transaction. > > In these cases, I think you're right that it would be necessary to =20 > hollow the instances in order to be absolutely sure that no stale =20 > data is read after a L2 cache evict(). > > On the other hand, if you're in an optimistic transaction, don't =20 > you want to retain the previously read values (they represent the =20 > ACID guarantee from the optimistic transaction)? So the only case =20 > where it might make sense to me is #1 above, and that seems =20 > debatable to me. Do most people using P-NT objects expect them to =20 > be consistent with the L2 cache at all times? Or are they expected =20= > to act like a limited form of an optimistic transaction? > > I don't have a strong opinion about this, I'm just trying to fully =20 > articulate the question. > > Wes > > Joerg von Frantzius wrote: > >> Hi Wes, >> >> thanks for your answer, please see my comments below. >> >> Wesley Biggs schrieb: >> >>> Joerg von Frantzius wrote: >>> >>>> The problem here is that either evict() accepts only PC objects, =20= >>>> not object ids, so we have to call PM.getObjectById() =20 >>>> beforehand. If no object for that id was present, we're =20 >>>> instantiating a hollow object here only to discard it =20 >>>> afterwards, that's not very effective. >>> >>> I'm not quite parsing your "either" here, sorry. But =20 >>> DataStoreCache.evict() accepts object IDs. I'm not sure I see =20 >>> the necessity of calling PM.evict() as well, unless you have some =20= >>> particularly long-lived transactions. >> >> We're doing nontransactional reads on long-living objects, so I =20 >> guessed we needed to call PM.evict() to avoid accessing stale =20 >> field data. >> >> You're of course right about DatastoreCache.evict() accepting IDs, =20= >> thanks for pointing that out. I had just seen the same method =20 >> signature, and so I assumed the parameter semantics also being the =20= >> same. >> >> Calling it evictById() probably would be less misleading, even =20 >> more so as a mistake here won't show up immediately. Also, if you =20 >> only have a jar without sourcecode, the signatures are absolutely =20 >> indistinguishable (Which of course is not an excuse for not having =20= >> read the spec thoroughly enough ;) >> >>>> As we really want cache invalidation here, not eviction, this is =20= >>>> even worse. For this purpose, it would be far more convenient to =20= >>>> have some method like invalidateCachesFor(Object id) on =20 >>>> PersistenceManagerFactory. >>> >>> That's the intention of DataStoreCache.evict(). The semantics =20 >>> are different than PM.evict(). >> >> Only now I start understanding that I was misled by the word evict=20 >> () for the L2-cache: as the user never gets hold of an L2 cache =20 >> object anyway (a L1-cache object will be created for that), he =20 >> shouldn't need to care whether the L2 cache internally needs to =20 >> throw away (evict) some object in order to invalidate cached =20 >> state. Spec says "/The evict methods are hints to the =20 >> implementation that the instances referred to by the object ids =20 >> are stale and should be evicted from the cache./" It might be nit-=20 >> picking, but I think it would be clearer if the method was called =20 >> invalidateBy=CDd(), which would be natural for some cache interface, =20= >> and if the explanation said "/that the object state referred to by =20= >> the object ids should be discarded/" >> >> Also, the spec doesn't say anything about DatastoreCache.evict() =20 >> having any impact on P-nontrans instances. So I still need to go =20 >> to every PM and evict there as well, which is very inconvenient. >> >> Or does the "evict" row in table 2 for P-nontrans really apply to /=20= >> both /evict() methods, not only PM.evict()!? The RI JPOX isn't =20 >> doing anything like that, by the way. >> >>>> To make our wish complete ;) this method would transition all =20 >>>> non-transactional instances to hollow for that id, for all the =20 >>>> PMs the PMF has given out. All transactional objects with that =20 >>>> id should be transitioned to hollow after their transaction has =20 >>>> completed (either with commit or rollback). >>> >>> Persistent nontransactional instances will have to be revalidated =20= >>> against the datastore (or cache thereof) before being re-enlisted =20= >>> in a transaction anyway. The behavior you mention is a good way =20 >>> to implement that, but it doesn't need to be mandated (hollow is =20 >>> not a user-visible state). >> >> I'm not sure what you mean by mandating here? I'd just like to =20 >> make sure that invalidated non-transactional instances will reload =20= >> state upon next read access, without having to iterate all PMs. =20 >> Also, I'd rather not like a call to PM.getObjectById() afterwards =20 >> returning a new Java object for the same id, which I guess is the =20 >> case after calling PM.evict(PM.getObjectById(id)). >> >> If a method invalidateById() existed, I'd see the sense of evict() =20= >> in releasing the associated memory. evict() currently does two =20 >> things at same time: evicting and transitioning to hollow. For =20 >> (distributed) cache invalidation, I find it sensible to desire =20 >> only the latter. >> >> Regards, >> J=F6rg > > Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:Craig.Russell@sun.com P.S. A good JDO? O, Gasp! --Apple-Mail-283--98056814 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGUDCCAwkw ggJyoAMCAQICEB7Y7fLHmKoeHTUdbtYrvpAwDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCW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