From ff39bb1dd572f0202537f761095a9d8df96a6e3d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 30 Dec 2015 21:14:38 -0500 Subject: [PATCH] throttle bulk procs to 50 ciphers at a time --- src/Core/Repositories/DocumentDB/CipherRepository.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Core/Repositories/DocumentDB/CipherRepository.cs b/src/Core/Repositories/DocumentDB/CipherRepository.cs index 14eafac48..41d2670ed 100644 --- a/src/Core/Repositories/DocumentDB/CipherRepository.cs +++ b/src/Core/Repositories/DocumentDB/CipherRepository.cs @@ -46,7 +46,9 @@ namespace Bit.Core.Repositories.DocumentDB var userId = ((Cipher)cleanedCiphers.First()).UserId; StoredProcedureResponse sprocResponse = await Client.ExecuteStoredProcedureAsync( 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 sprocResponse = await Client.ExecuteStoredProcedureAsync( 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())