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?

demandé il y a 4 ans975 vues
1 réponse
0
Réponse acceptée

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.
répondu il y a 3 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions