Skip to content

Commit c28c435

Browse files
authored
Merge pull request #107569 from ealsur/users/ealsur/cfeventual
Cosmos DB - Change feed and Eventual consistency
2 parents 3ac88b7 + 537d0a9 commit c28c435

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

articles/cosmos-db/change-feed.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ This feature is currently supported by the following Azure Cosmos DB APIs and cl
3636

3737
## Change feed and different operations
3838

39-
Today, you see all operations in the change feed. The functionality where you can control change feed, for specific operations such as updates only and not inserts is not yet available. You can add a soft marker on the item for updates and filter based on that when processing items in the change feed. Currently change feed doesnt log deletes. Similar to the previous example, you can add a soft marker on the items that are being deleted, for example, you can add an attribute in the item called "deleted" and set it to "true" and set a TTL on the item, so that it can be automatically deleted. You can read the change feed for historic items (the most recent change corresponding to the item, it doesn't include the intermediate changes), for example, items that were added five years ago. If the item is not deleted you can read the change feed as far as the origin of your container.
39+
Today, you see all operations in the change feed. The functionality where you can control change feed, for specific operations such as updates only and not inserts is not yet available. You can add a "soft marker" on the item for updates and filter based on that when processing items in the change feed. Currently change feed doesn't log deletes. Similar to the previous example, you can add a soft marker on the items that are being deleted, for example, you can add an attribute in the item called "deleted" and set it to "true" and set a TTL on the item, so that it can be automatically deleted. You can read the change feed for historic items (the most recent change corresponding to the item, it doesn't include the intermediate changes), for example, items that were added five years ago. If the item is not deleted you can read the change feed as far as the origin of your container.
4040

4141
### Sort order of items in change feed
4242

43-
Change feed items come in the order of their modification time. This sort order is guaranteed per logical partition key.
43+
Change feed items come in the order of their modification time. This sort order is guaranteed per logical partition key.
44+
45+
### Consistency level
46+
47+
While consuming the change feed in an Eventual consistency level, there could be duplicate events in-between subsequent change feed read operations (the last event of one read operation appears as the first of the next).
4448

4549
### Change feed in multi-region Azure Cosmos accounts
4650

articles/cosmos-db/troubleshoot-changefeed-functions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ If it's the latter, there could be some delay between the changes being stored a
6565
3. Your Azure Cosmos container might be [rate-limited](./request-units.md).
6666
4. You can use the `PreferredLocations` attribute in your trigger to specify a comma-separated list of Azure regions to define a custom preferred connection order.
6767

68+
### Some changes are repeated in my Trigger
69+
70+
The concept of a "change" is an operation on a document. The most common scenarios where events for the same document is received are:
71+
* The account is using Eventual consistency. While consuming the change feed in an Eventual consistency level, there could be duplicate events in-between subsequent change feed read operations (the last event of one read operation appears as the first of the next).
72+
* The document is being updated. The Change Feed can contain multiple operations for the same documents, if that document is receiving updates, it can pick up multiple events (one for each update). One easy way to distinguish among different operations for the same document is to track the `_lsn` [property for each change](change-feed.md#change-feed-and-_etag-_lsn-or-_ts). If they don't match, these are different changes over the same document.
73+
* If you are identifying documents just by `id`, remember that the unique identifier for a document is the `id` and its partition key (there can be two documents with the same `id` but different partition key).
74+
6875
### Some changes are missing in my Trigger
6976

7077
If you find that some of the changes that happened in your Azure Cosmos container are not being picked up by the Azure Function, there is an initial investigation step that needs to take place.

0 commit comments

Comments
 (0)