2
votes

Let's say I have the following model:

class B(ndb.Model):
    name   = ndb.StringProperty()

class A(ndb.Model):
    prop_a = ndb.StringProperty()
    prop_b = ndb.StringProperty()
    list   = ndb.StructuredProperty(B, repeated=True)
  1. Two concurrent requests (r1 and r2) are trying to modify an instance of A in a transaction. r1 wants to update (i.e. .put()) the instance's prop_a and r2 wants to update the instance's prop_b simultaneously (i.e. different properties of the same instance). Will this be considered a collision?

  2. Similary, if r1 and r2 wanted to update different elements in the list property of the same instance of A (e.g. list[0] and list[1], respectively), will this also be considered a collision by @ndb.transactional?

1

1 Answers

1
votes

If it is the same entity of kind A, then both transactions will collide.

Even if they are not the same entity of kind A, then both transactions will still collide, unless the two instances belong to different entity groups.

The collision space of transactions are entity groups. Whether the transaction references different properties does not matter. Whether they modify different elements of a list property does not matter. Whether they modify the same entity or different entities do not matter. The only thing that matters from a collision perspective is whether the transactions belong to the same entity group.