Reputation: 274
In DynamoDb, reads using Global Secondary Indexes are eventually consistent by default: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html#GSI.Querying
However, does that mean queries to a GSI may return one of the following:
Example for clarification:
Foo starts with the following records: {a: 1, b: apple, c: blue} {a: 2, b: orange, c: green}
A write to foo updates the record where a = 2 to be: {a:2, b: apple, c: red}
Another write updates the record where a = 1 to be: {a: 1, b: apple, c: orange}
After the write, suppose there is some delay and before the GSI is consistent, a read is made to the table using the GSI
The query uses the GSI to get all records where b = apple
Will this query return:
Result X - Wrong Set but Right Attribute Values: {a: 1, b: apple, c: orange}
Result Y - Right Set but Wrong Attribute Values: {a: 1, b: apple, c: blue} {a: 2, b: orange, c: green}
Result Z - Wrong Set and Wrong Attribute Values: {a: 1, b: apple, c: blue}
or something else?
Upvotes: 0
Views: 441
Reputation: 12259
Queries on the GSI will sometimes return the old set of records
Yes
Queries will return the new set of records, but the attributes of the record will be old?
This will never happen.
Upvotes: 1