1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-25 17:27:45 +01:00

throttle bulk procs to 50 ciphers at a time

This commit is contained in:
Kyle Spearrin 2015-12-30 21:14:38 -05:00
parent 967e383001
commit ff39bb1dd5

View File

@ -46,7 +46,9 @@ namespace Bit.Core.Repositories.DocumentDB
var userId = ((Cipher)cleanedCiphers.First()).UserId;
StoredProcedureResponse<int> sprocResponse = await Client.ExecuteStoredProcedureAsync<int>(
ResolveSprocIdLink(userId, "updateDirtyCiphers"),
cleanedCiphers,
// TODO: Figure out how to better determine the max number of document to send without
// going over 512kb limit for DocumentDB. 50 could still be too large in some cases.
cleanedCiphers.Take(50),
userId);
var replacedCount = sprocResponse.Response;
@ -71,7 +73,9 @@ namespace Bit.Core.Repositories.DocumentDB
var userId = ((Cipher)cleanedCiphers.First()).UserId;
StoredProcedureResponse<int> sprocResponse = await Client.ExecuteStoredProcedureAsync<int>(
ResolveSprocIdLink(userId, "bulkCreate"),
cleanedCiphers);
// TODO: Figure out how to better determine the max number of document to send without
// going over 512kb limit for DocumentDB. 50 could still be too large in some cases.
cleanedCiphers.Take(50));
var createdCount = sprocResponse.Response;
if(createdCount != cleanedCiphers.Count())