Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ETag with CosmosDB #2136

Merged
merged 1 commit into from
Nov 12, 2024
Merged

use ETag with CosmosDB #2136

merged 1 commit into from
Nov 12, 2024

Conversation

zkokelj
Copy link
Contributor

@zkokelj zkokelj commented Nov 11, 2024

Why this change is needed

We need to implement optimistic locking for CosmosDB.

Two threads could read an user from the database at the same time and then both can modify and store the user.
With current implementation both writes to database are successful which can cause us to loose some data without seeing an error anywhere. (Example: in both threads we add an account to user and the second thread overwrites the account being added by the first one).

What changes were made as part of this PR

Using ETag from CosmosDB to check if the version that we are overwriting is the same as the one that we read from.

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

Copy link
Collaborator

@tudor-malene tudor-malene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zkokelj zkokelj merged commit 8d69de4 into main Nov 12, 2024
2 checks passed
@zkokelj zkokelj deleted the ziga/use_etag_with_cosmosDB branch November 12, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants