Search code examples
azureazure-cosmosdbdatabase-replicationeventual-consistency

Does CosmosDB replication guarantee order across containers and physical partitions?


With Strong to Constant Prefix consistency levels, they guarantee reads will never see out-of-order writes.

The below questions are particularly of interest with a multi-region + multi-master setup; if this makes a difference to the answer, I would be interested to understand what/why those differences are.

Is order maintained across multiple Physical Partitions?

For example with:

Partition1/InsertRow [val 1]
Partition1/InsertRow [val 2]
Partition2/InsertRow [val 3]

Is it possible that data could be made available for reading in the order:

[val 1]
[val 3]
[val 2]

In a similar example, is order maintained across multiple Containers?

There are two reasons I'm unsure.


Solution

  • For a multi-master account, readers in different regions where writes are made to a single region will get consistent prefix. When writes are in different regions, readers will get eventual consistency.

    This is all documented here Consistency Levels in Cosmos DB.