NDB Transaction Collision Engine Application Engine

The App Engine documentation ( https://cloud.google.com/appengine/docs/python/ndb/transactions ) says, "If a transaction collides with another, it fails, NDB will automatically retry such failed transactions multiple times.

The meaning of this sentence is not entirely clear to me. If transaction A starts first and then transaction B starts in the middle of transaction A, does that mean both A and B fail and retry? Or does only B happen and A continues?

Also, a related question: are there cases where a transaction will be partially completed and then rolled back? Or is every attempt at a transaction not included in the function at all until it has a chance to execute the function?

Thank!

+3


source to share


1 answer


Most likely, one of the transactions will be successful and the other will fail (and will be tried), but you cannot tell in advance which one; this is it is also possible that both could fail (and will be re-tried).

And yes, it fail

usually means partly progresses but then gets rolled back

. This is an "optimistic concurrency" layout, not a look-ahead one locking

.



Remember that potentially conflicting transactions are usually requested on many distributed machines, coordinating them with anything, but "optimistic concurrency" (detecting conflicts and rolling back those that cannot complete cleanly) would be impracticable.

+3


source







All Articles