Using batch put(...) not putting all items.

136 views
Skip to first unread message

Christopher

unread,
Aug 17, 2011, 2:46:36 PM8/17/11
to objectify-appengine
After reading through some posts, I see that the batch put() method is
not a transaction (as no guarantee to entity group). I am trying to
track down a bug which put a few of our datastore entities in an
inconsistent state.

Here's what happened: we have an entity called Account, each Account
can have a list of Account entities as sub-accounts. During the
process of creating a sub-account, we update a list in the parent, as
well as some fields in the child such that they essentially reference
eachother in some manner. After modifying the entities, we use
of().put(parent, child). For this particular case, the child points to
the parent, but the parent does not point back to the child, and I am
investigating why this could have happened.

I understand that it is possible one was put while the other failed --
my question is, if this is the case, would an exception have been
thrown on the server? As it stands, I cannot find an exception in the
appengine logs which would indicate that this did in fact happen.

Thanks

Jeff Schnitzer

unread,
Aug 18, 2011, 2:05:27 PM8/18/11
to objectify...@googlegroups.com
If a write failed, I would expect to see an error in the logs. What
kind of timeline is this under? Is it possible you're seeing the
eventual consistency of queries in the HRD?

That said, this sounds like a situation that calls for transactions.
Can't you put subaccounts in the same entity group as an account?

Jeff

Christopher

unread,
Aug 18, 2011, 4:01:58 PM8/18/11
to objectify-appengine
We have strayed away from using entity groups as we had run into
issues using them prior. It may be the case that we go back to using
entity groups, but for the time being we are continuing with our
decision. I have just discovered what is actually causing the problem,
and is not related to objectify or datastore operations. Thank you for
the response. I took a look into the DatastoreService javadoc
regarding the put methods, and it states that it would throw a
DatastoreFailure exception if it was not able to perform the put.
Therefore I would expect put(...) to throw an exception if one entity
failed, unless the objectify wrapper around these methods swallow the
exception. Thanks again Jeff.

Christopher

Jeff Schnitzer

unread,
Aug 18, 2011, 6:57:41 PM8/18/11
to objectify...@googlegroups.com
Glad you found it.

Objectify does not swallow any datastore exceptions - with the one
exception of get(), which takes the checked exception from the
datastore and turns it into a runtime exception.

Jeff

Reply all
Reply to author
Forward
0 new messages