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?

已提問 4 年前檢視次數 976 次
1 個回答
0
已接受的答案

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.
已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南