GAE Datastore - Entity in datastore is already updated on @PrePut Datastore Callback

109 views
Skip to first unread message

Nejc Tomažič

unread,
Jun 2, 2015, 6:49:09 AM6/2/15
to google-a...@googlegroups.com

Hi guys, 

as already described on StackOverflow:

I'm working on entity auditing for a set of entities saved in GAE Datastore using @PrePut and @PostPut datastore callbacks.

Idea is that old entity is loaded in @PrePut using Objectify and stored to context. Than updated entity is added to context in @PostPut callback. When request is processed I generate a diff in ContainerResponseFilter and save it.

Issue: if entity is updated non transactional, entity retrieved from datastore in @PrePut callback is already updated and therefore I'm unable to get a diff.
Is this a bug or it is supposed to work like that (if this is a  case I would highly recommend adding a note to the docs here: https://cloud.google.com/appengine/docs/java/datastore/callbacks)

Question: Is it possible to retrieve old entity in @PrePut datastore callback if save operation is non transactional? If not, what would be the best alternative?

All load and save operations are made using Objectify. Versions: Objectify: 5.1.5 Appengine version: 1.9.20


I would really appreciate help on this one.
Thanks, 
KR, Nejc

Ryan (Cloud Platform Support)

unread,
Jun 2, 2015, 9:44:37 AM6/2/15
to google-a...@googlegroups.com, nejc.t...@gmail.com
Salutations Nejc,

This sounds like it would be perfect for our PIT Defect Reports. Fill out the report including a sample project that shows the behaviour. Post the thread in here and I will take a look at it.

Thank you for bringing this to our attention! 

Nejc Tomažič

unread,
Jun 2, 2015, 10:42:13 AM6/2/15
to google-a...@googlegroups.com, nejc.t...@gmail.com
Thanks alot for quick response Ryan!

If this really sounds like an issue on the Callbacks I would first ask the following question:
Can we speed things up if we have Gold support package? My corporate account doesn't have permissions to open a ticket at the moment and I tried on SO first and than came up with posting to this group if there would be obvious that I missed sth. in the docs.
I can request permission or ask colleague to post a ticket if we should take care of an issue through the developers console?

Anyhow I can prepare simple project if this would help, but this will take some extra time because of the priorities.

Thanks, Nejc

Ryan (Cloud Platform Support)

unread,
Jun 2, 2015, 12:26:12 PM6/2/15
to google-a...@googlegroups.com, nejc.t...@gmail.com
The only benefit you would get is the ability to request updates. I work closely with the team that would answer the case and they have the same abilities that I do. They would need the reproduction as well and depending on the route cause either create a PIT with a bug report for you to monitor or give you advice on how to get it to work. Ultimately it's your call but either way having a repro project would be needed.

Just note there is no guarantee on bug fixes.

Jeff Schnitzer

unread,
Jun 2, 2015, 1:54:56 PM6/2/15
to Google App Engine
Objectify author here.

I would not bother with the @PrePut/@PostPut callbacks; I have yet to find a case where they are actually useful. Instead wrap the low level AsyncDatastoreService and build your code as an interceptor/decorator. That way you have full control.

One example is the CachingAsyncDatastoreService in Objectify, another is this: https://github.com/objectify/objectify-insight

Jeff

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/ced9eca8-d836-42d8-be71-02b41769d8f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages