Skip to content

Commit b3183b8

Browse files
Merge pull request #272007 from TheovanKraay/multi-region-write-updates
multi-region writes doc updates
2 parents 10cb038 + 3bf07dd commit b3183b8

File tree

8 files changed

+111
-20
lines changed

8 files changed

+111
-20
lines changed

articles/cosmos-db/cassandra/TOC.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,16 @@
177177
- name: Mapping Cassandra consistency levels
178178
href: consistency-mapping.md
179179
- name: High availability
180-
href: ../high-availability.md
181-
- name: Conflict types and resolution policies
182-
displayName: last write wins, custom, multi-region writes, multi-master
183-
href: ../conflict-resolution-policies.md
180+
items:
181+
- name: High availability overview
182+
href: ../high-availability.md
183+
- name: Multi-region writes
184+
items:
185+
- name: Understanding multi-region writes
186+
href: ../multi-region-writes.md
187+
- name: Conflict resolution
188+
displayName: last write wins, custom, multi-region writes, multi-master
189+
href: ../conflict-resolution-policies.md
184190
- name: Global distribution - under the hood
185191
href: ../global-dist-under-the-hood.md
186192
- name: Security

articles/cosmos-db/change-feed.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ Change feed is available for partition key ranges of an Azure Cosmos DB containe
6767

6868
Change feed items come in the order of their modification time. This sort order is guaranteed per partition key, and there's no guaranteed order across the partition key values.
6969

70+
> [!NOTE]
71+
> For [multi-region write](multi-region-writes.md) accounts, there are two timestamps:
72+
> - The server epoch time at which the record was written in the local region. This is recorded as `_ts`.
73+
> - The epoch time at which the absence of a conflict was confirmed, or the conflict was resolved in the [hub region](multi-region-writes.md#hub-region) for that record. This is recorded as `crts`.
74+
>
75+
> Change feed items come in the order recorded by `crts`.
76+
77+
7078
### Change feed in multi-region Azure Cosmos DB accounts
7179

7280
In a multi-region Azure Cosmos DB account, changes in one region are available in all regions. If a write-region fails over, change feed works across the manual failover operation, and it's contiguous. For accounts with multiple write regions, there's no guarantee of when changes will be available. Incoming changes to the same document may be dropped in latest version mode if there was a more recent change in another region, and all changes will be captured in all versions and deletes mode.

articles/cosmos-db/get-latest-restore-timestamp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ This article describes how to get the [latest restorable timestamp](latest-resto
1818

1919
This feature is supported for Azure Cosmos DB API for NoSQL containers, API for MongoDB , Table API and API for Gremlin graphs.
2020

21+
> [!IMPORTANT]
22+
> For [multi-region write](multi-region-writes.md) accounts, the latest restorable timestamp is determinded by a [conflict resolution timestamp (`crts`)](multi-region-writes.md#understanding-timestamps). This is not returned by the methods listed below. See GitHub sample [here](https://github.com/Azure-Samples/cosmosdb-get-conflict-resolved-timestamp-from-changefeed) to learn how to consume Azure Cosmos DB's Change Feed and return documents with `ConflictResolvedTimestamp(crts)` in a container.
23+
2124
## SQL container
2225

2326
### PowerShell

articles/cosmos-db/gremlin/TOC.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,16 @@
185185
displayName: session, consistency prefix, strong, eventual, bounded staleness
186186
href: ../consistency-levels.md
187187
- name: High availability
188-
href: ../high-availability.md
189-
- name: Conflict types and resolution policies
190-
displayName: last write wins, custom, multi-region writes, multi-master
191-
href: ../conflict-resolution-policies.md
188+
items:
189+
- name: High availability overview
190+
href: ../high-availability.md
191+
- name: Multi-region writes
192+
items:
193+
- name: Understanding multi-region writes
194+
href: ../multi-region-writes.md
195+
- name: Conflict resolution
196+
displayName: last write wins, custom, multi-region writes, multi-master
197+
href: ../conflict-resolution-policies.md
192198
- name: Global distribution - under the hood
193199
href: ../global-dist-under-the-hood.md
194200
- name: Security

articles/cosmos-db/mongodb/TOC.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,16 @@
254254
- name: Mapping MongoDB consistency levels
255255
href: consistency-mapping.md
256256
- name: High availability
257-
href: ../high-availability.md
258-
- name: Conflict types and resolution policies
259-
displayName: last write wins, custom, multi-region writes, multi-master
260-
href: ../conflict-resolution-policies.md
257+
items:
258+
- name: High availability overview
259+
href: ../high-availability.md
260+
- name: Multi-region writes
261+
items:
262+
- name: Understanding multi-region writes
263+
href: ../multi-region-writes.md
264+
- name: Conflict resolution
265+
displayName: last write wins, custom, multi-region writes, multi-master
266+
href: ../conflict-resolution-policies.md
261267
- name: Global distribution - under the hood
262268
href: ../global-dist-under-the-hood.md
263269
- name: Security
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: Understanding multi-region writes in Azure Cosmos DB
3+
description: This article describes how multi-region writes work in Azure Cosmos DB.
4+
author: TheovanKraay
5+
ms.service: cosmos-db
6+
ms.topic: conceptual
7+
ms.date: 04/12/2024
8+
ms.author: thvankra
9+
ms.reviewer: thvankra
10+
---
11+
12+
# Understanding multi-region writes in Azure Cosmos DB
13+
14+
[!INCLUDE[NoSQL, MongoDB, Cassandra, Gremlin, Table](includes/appliesto-nosql-mongodb-cassandra-gremlin-table.md)]
15+
16+
The best way to achieve near-zero downtime in either a partial or total outage scenario where consistency of reads doesn't need to be guaranteed, is to configure your account for multi-region writes. This article covers the key concepts to be aware of when configuring a multi-region write account.
17+
18+
## Hub region
19+
In a multi-region-write database account with two or more regions, the first region in which your account was created is called the "hub" region. All other regions that are then added to the account are called "satellite" regions. If the hub region is removed from the account, the next region, in the order they were added, is automatically chosen as the hub region.
20+
21+
Any writes arriving in satellite regions are quorum committed in the local region and then later sent to the Hub region for [conflict resolution](conflict-resolution-policies.md), asynchronously. Once a write goes to the hub region and gets conflict resolved, it becomes a "confirmed" write. Until then, it's called a "tentative" write or an "unconfirmed" write. Any write served from the hub region immediately becomes a confirmed write.
22+
23+
## Understanding timestamps
24+
25+
One of the primary differences in a multi-region-write account is the presence of two server timestamp values associated with each entity. The first is the server epoch time at which the entity was written in that region. This timestamp is available in both single-region write and multi-region write accounts. The second server timestamp value is associated with the epoch time at which the absence of a conflict was confirmed, or the conflict was resolved in the hub region. A confirmed or conflict resolved write has a conflict-resolution timestamp (`crts`) assigned, whereas an unconfirmed or tentative write doesn't have `crts`. There are two timestamps in Cosmos DB set by the server. The primary difference is whether the region configuration of the account is Single-Write or Multi-Write.
26+
27+
| Timestamp | Meaning | When exposed |
28+
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29+
| `_ts` | The server epoch time at which the entity was written. | Always exposed by all read and query APIs. |
30+
| `crts` | The epoch time at which the Multi-Write conflict was resolved, or the absence of a conflict was confirmed. For Multi-Write region configuration, this timestamp defines the order of changes for Continuous backup and Change Feed:<br><br><ul><li>Used to find start time for Change Feed requests</li><li>Used as sort order for in Change Feed response.</li><li>Used to order the writes for Continuous Backup</li><li>The log backup only captures confirmed or conflict resolved writes and hence restore result of a Continuous backup only returns confirmed writes.</li></ul> | Exposed in response to Change Feed requests and only when "New Wire Model" is enabled by the request. This is the default for [All versions and deletes](change-feed.md#all-versions-and-deletes-mode-preview) Change Feed mode. |
31+
32+
33+
34+
## Next steps
35+
36+
Next, you can read the following articles:
37+
38+
* [Conflict types and resolution policies when using multiple write regions](conflict-resolution-policies.md)
39+
40+
* [Configure multi-region writes in your applications that use Azure Cosmos DB](how-to-multi-master.md)
41+
42+
* [Consistency levels in Azure Cosmos DB](./consistency-levels.md)
43+
44+
* [Request Units in Azure Cosmos DB](./request-units.md)
45+
46+
* [Global data distribution with Azure Cosmos DB - under the hood](global-dist-under-the-hood.md)
47+
48+
* [Consistency levels in Azure Cosmos DB](consistency-levels.md)
49+
50+
* [Diagnose and troubleshoot the availability of Azure Cosmos DB SDKs in multiregional environments](troubleshoot-sdk-availability.md)

articles/cosmos-db/nosql/TOC.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,16 @@
346346
displayName: session, consistency prefix, strong, eventual, bounded staleness
347347
href: ../consistency-levels.md
348348
- name: High availability
349-
href: ../high-availability.md
350-
- name: Conflict types and resolution policies
351-
displayName: last write wins, custom, multi-region writes, multi-master
352-
href: ../conflict-resolution-policies.md
349+
items:
350+
- name: High availability overview
351+
href: ../high-availability.md
352+
- name: Multi-region writes
353+
items:
354+
- name: Understanding multi-region writes
355+
href: ../multi-region-writes.md
356+
- name: Conflict resolution
357+
displayName: last write wins, custom, multi-region writes, multi-master
358+
href: ../conflict-resolution-policies.md
353359
- name: Global distribution - under the hood
354360
href: ../global-dist-under-the-hood.md
355361
- name: Security

articles/cosmos-db/table/TOC.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,16 @@
191191
displayName: session, consistency prefix, strong, eventual, bounded staleness
192192
href: ../consistency-levels.md
193193
- name: High availability
194-
href: ../high-availability.md
195-
- name: Conflict types and resolution policies
196-
displayName: last write wins, custom, multi-region writes, multi-master
197-
href: ../conflict-resolution-policies.md
194+
items:
195+
- name: High availability overview
196+
href: ../high-availability.md
197+
- name: Multi-region writes
198+
items:
199+
- name: Understanding multi-region writes
200+
href: ../multi-region-writes.md
201+
- name: Conflict resolution
202+
displayName: last write wins, custom, multi-region writes, multi-master
203+
href: ../conflict-resolution-policies.md
198204
- name: Global distribution - under the hood
199205
href: ../global-dist-under-the-hood.md
200206
- name: Security

0 commit comments

Comments
 (0)