DynamoDB Global Tables + Atomic Transactions and counters

0

I'm trying to figure out how Dynamo handles conflict resolution in a global table when doing a transaction.

Assuming I want to run a transaction that increments an atomic counter and writes out a log item in the same transaction, how is this resolved in a global tables environment?

Inside of a single region the second transaction would fail and refuse to increment the counter since the log record already exists.

But what happens when the transaction is run in 2 regions at the same time? The docs for conflict resolution in global tables states that the last writer wins. But how does this apply to transactions and how does this apply to atomic counters?

Would an atomic counter being quickly incremented in 2 regions at the same time result in them constantly over-writing each other and not actually incrementing properly?

asked 4 years ago975 views
1 Answer
0
Accepted Answer

So, after lots of digging and testing I found the answer for those who come looking in the future:

  • Transactions don't "exist" as far as global tables is concerned.
  • Transactions will apply within a single region
  • Replication of changes made via transactions are replicated async to the other regions that are enabled
  • This means that the default "last writer wins" policy will come in to effect.
  • TL;DR: Don't rely on transactions if you might be writing to the same thing in multiple regions; e.g. add a 'region' to your PK/SK if you want transaction qualities or some other such mechanism to prevent different regions overwriting each other's transactions. Another alternative would be writing in a single region and reading from others depending on the use case.
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions