Streamstone
Streamstone copied to clipboard
CosmosDB concurrency exception handling
When batch inserting to CosmosDB Table API the error message returned doesn't include the index of the conflicting entity. The test below reproduces the issue (cosmos_specifics.cs
)
[Test]
public async Task Handling_concurrency()
{
var partition = new Partition(table, "test-handling-concurrency");
var stream = new Stream(partition);
var events = Enumerable.Range(1, 10)
.Select(CreateEvent)
.ToArray();
await Stream.WriteAsync(stream, events);
await Stream.WriteAsync(stream, events);
}
The following exception is thrown:
UnexpectedStorageResponseException.ConflictExceptionMessageShouldHaveSemicolonOnFirstLine(error);
I've asked CosmosDB team for feedback and will update the issue with their response.
Got a tweet from @CosmosDB with confirmation they are fixing it. More info to follow.
Update from CosmosDB team:
Regarding the issue where batch operation error message does not indicate the operation index that has failed: yes this is a known issue and we are working on the fix. We don’t have a firm timeline yet but we hope the fix could be rolled out to you in July.
It is also in our roadmap to extend Azure Storage Table APIs to add features you would typically expect from Cosmos DB, such as RU charges & retry-after suggestions on throttling. When such features come, we expect it will be exposed via the Cosmos DB Table SDK.