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

Batch API: Fixes the size limit to reduce timeouts #1757

Merged
merged 8 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace Microsoft.Azure.Cosmos
/// </summary>
internal class BatchAsyncContainerExecutorCache : IDisposable
{
// Same as bulk v2.
internal const int DefaultMaxBulkRequestBodySizeInBytes = 220201;
j82w marked this conversation as resolved.
Show resolved Hide resolved
private ConcurrentDictionary<string, BatchAsyncContainerExecutor> executorsPerContainer = new ConcurrentDictionary<string, BatchAsyncContainerExecutor>();

public BatchAsyncContainerExecutor GetExecutorForContainer(
Expand All @@ -35,7 +37,7 @@ public BatchAsyncContainerExecutor GetExecutorForContainer(
container,
cosmosClientContext,
Constants.MaxOperationsInDirectModeBatchRequest,
Constants.MaxDirectModeBatchRequestBodySizeInBytes);
DefaultMaxBulkRequestBodySizeInBytes);
rakkuma marked this conversation as resolved.
Show resolved Hide resolved
if (!this.executorsPerContainer.TryAdd(containerLink, newExecutor))
{
newExecutor.Dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task RetryOnSplit()
},
string.Empty);
mockContainer.Setup(x => x.GetRoutingMapAsync(It.IsAny<CancellationToken>())).Returns(Task.FromResult(routingMap));
BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(mockContainer.Object, mockedContext.Object, 20, Constants.MaxDirectModeBatchRequestBodySizeInBytes);
BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(mockContainer.Object, mockedContext.Object, 20, BatchAsyncContainerExecutorCache.DefaultMaxBulkRequestBodySizeInBytes);
j82w marked this conversation as resolved.
Show resolved Hide resolved
TransactionalBatchOperationResult result = await executor.AddAsync(itemBatchOperation);

Mock.Get(mockContainer.Object)
Expand Down Expand Up @@ -117,7 +117,7 @@ public async Task RetryOnNameStale()
},
string.Empty);
mockContainer.Setup(x => x.GetRoutingMapAsync(It.IsAny<CancellationToken>())).Returns(Task.FromResult(routingMap));
BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(mockContainer.Object, mockedContext.Object, 20, Constants.MaxDirectModeBatchRequestBodySizeInBytes);
BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(mockContainer.Object, mockedContext.Object, 20, BatchAsyncContainerExecutorCache.DefaultMaxBulkRequestBodySizeInBytes);
TransactionalBatchOperationResult result = await executor.AddAsync(itemBatchOperation);

Mock.Get(mockContainer.Object)
Expand Down Expand Up @@ -177,7 +177,7 @@ public async Task RetryOn429()
},
string.Empty);
mockContainer.Setup(x => x.GetRoutingMapAsync(It.IsAny<CancellationToken>())).Returns(Task.FromResult(routingMap));
BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(mockContainer.Object, mockedContext.Object, 20, Constants.MaxDirectModeBatchRequestBodySizeInBytes);
BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(mockContainer.Object, mockedContext.Object, 20, BatchAsyncContainerExecutorCache.DefaultMaxBulkRequestBodySizeInBytes);
TransactionalBatchOperationResult result = await executor.AddAsync(itemBatchOperation);

Mock.Get(mockContainer.Object)
Expand Down Expand Up @@ -236,7 +236,7 @@ public async Task DoesNotRecalculatePartitionKeyRangeOnNoSplits()
},
string.Empty);
mockContainer.Setup(x => x.GetRoutingMapAsync(It.IsAny<CancellationToken>())).Returns(Task.FromResult(routingMap));
BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(mockContainer.Object, mockedContext.Object, 20, Constants.MaxDirectModeBatchRequestBodySizeInBytes);
BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(mockContainer.Object, mockedContext.Object, 20, BatchAsyncContainerExecutorCache.DefaultMaxBulkRequestBodySizeInBytes);
TransactionalBatchOperationResult result = await executor.AddAsync(itemBatchOperation);

Mock.Get(mockContainer.Object)
Expand Down