-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add support for optimistic concurrency #8
Comments
This looks like it could be the answer to #21, and something i was looking for as well... Would you accept PR for this? And if so have you thought yet about how you would like to implement it? |
hmmm doesn't look like this will be possible with your current update implementation. At least not if you wanted to leverage built-in dynamodb SDK's support for document versioning.
Would it be a good idea to internally fork between batched ops and |
Hi Andy! You're absolutely welcome to send a PR for that, I'd really appreciate your help! For the implementation, I'd propose to keep being consistent with AWS Object Persistence Model. We could just start respecting the DynamoDBVersion attribute, in a way that if the entity type does have a property marked with that attribute, we do a conditional update. If no such properties exist in the type - we fall back to existing "last writer wins" implementation. Yes, BatchWrites do not seem to support conditional expressions or anything. Yes, it makes perfect sense to do multiple parallel PutItem operations with properly configured PutItemOperationConfig.Expected values instead. What I wouldn't recommend is to try using DynamoDBContext.Save() for implementing this. First, because it would be hard to do (note: in ExecuteUpdateBatchAsync() you only have Documents, not entities). And second, because we generally strive not to build on top of AWS Object Persistence. We can re-use attributes from it (to look consistent) but not utilize it's functionality. |
so something like this for use of table.PutItem(document, new PutItemOperationConfig()
{
Expected = new Document(new Dictionary<string, DynamoDBEntry>
{
// In reality, we'd get "VersionNumber" from a previous check for any [Versioned]
// members of the original entity (before Document conversion?)
{ "Version", document["VersionNumber"] }
})
}); questions:
|
Well, just to be consistent with what BatchWrite operation currently does. It would be confusing, if in one case items are replaced and in other case they're amended.
Something like that, except not Task.WaitAll(), but Task.WhenAll().
Well, the performance definitely would be lower compared to what we have with BatchWrite (my experiments show it would be 5-10 times slower). But there're no other options, as we just can't use BatchWrite. Maybe just fine-tuning the task scheduler for those tasks (not in first version obviously). Error handling should be OK. If any PUT fails, there'll be an exception, and the cache will be cleared. Some items yes, might be written to DynamoDB successfully, but that's the same thing, as we have with BatchWrite now (upon getting an exception the consumer is supposed to implement retries or whatever). |
* No more bulk operations for CUD, using async tasks instead * Removing entities also respects version field * Update caching behavior to handle partial failure in optimistic locking scenario
* No more bulk operations for CUD, using async tasks instead * Removing entities also respects version field * Update caching behavior to handle partial failure in optimistic locking scenario
DataContext.SubmitChanges() should fail, if there's a newer version of an entity in DynamoDB and/or in cache.
The text was updated successfully, but these errors were encountered: