Question: In the AppEngine DataStore, given an entity `a = MyModel(a=1, b=2)`, is `a.put()` atomic? That is, if I run:

```
a.a=3
a.b=4
a.put()

```

Am I guaranteed that the entity was updated correctly for all its properties, (assuming `a.put()` did not raise an exception, that is)?

Dan Sanderson's [book](http://shop.oreilly.com/product/9780596522735.do) says that [it is](https://books.google.pl/books?id=6cL_kCZ4NJ4C&lpg=PA165&ots=sJhjMRTYjn&dq=%22When%20you%20create%2C%20update%20or%20delete%20a%20single%20entity%2C%20the%20change%20occurs%20in%20a%20transaction%22&pg=PA165#v=onepage&q=%22When%20you%20create,%20update%20or%20delete%20a%20single%20entity,%20the%20change%20occurs%20in%20a%20transaction%22&f=true), but I couldn't find concrete documentation on the subject elsewhere.

Answer: 
Yes, a single entity's update is atomic.

As noted [in this article](https://developers.google.com/appengine/articles/life_of_write), a given entity is a single protocol buffer in a Bigtable row. Protocol buffers are always written atomically.
**Yes & no.**

It's atomic but it is **eventually consistent**. It can make a huge difference to business logic if not taken into account properly.

E.g. if you did:

```
a = A(id=1)
a.b = 2
a.c = 3
a.put()
.... wait some time
a = A(id=1)
a.b = 4
a.c = 5
a.put()
....
# check now

```

and if you query a = db.get\_by\_key(1) it will always have a.b==2 and a.c==3.

But if you query the entity by index it can give different results.

For example if you query at the same time

```
A.query(A.b==4)
A.query(A.c==5)

```

then one (any) of the queries can return you 1 record and other return nothing. Or both return 1 record. Or both return nothing *for some period of time*. Eventually it will always return stable 1 record for each query. But **timing is no guaranteed** - usually it takes milliseconds but can be few seconds or even minutes or hours in case of big issues.

You may be interested to read more about this:
<https://cloud.google.com/datastore/docs/articles/balancing-strong-and-eventual-consistency-with-google-cloud-datastore/>