diff options
author | Marcos José Grillo Ramírez <marcos.grillo@mongodb.com> | 2020-03-12 12:19:41 +0100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-12 16:24:40 +0000 |
commit | bb741a0ab1b2c80844dab55a3beecd83a8250ca4 (patch) | |
tree | 777930c1580aeaf27d3d53734f83947afc68d2b4 /src | |
parent | 90c3f10389519068eb685db72b7ff13f93c71dc6 (diff) | |
download | mongo-bb741a0ab1b2c80844dab55a3beecd83a8250ca4.tar.gz |
SERVER-44463 insertConfigDocumentsAsRetryableWrite() incorrectly calculates BSON array overhead
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/s/catalog/sharding_catalog_client_impl.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp index 93065c91a75..a1e3da49eb9 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp +++ b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp @@ -862,30 +862,28 @@ void ShardingCatalogClientImpl::insertConfigDocumentsAsRetryableWrite( std::vector<BSONObj> workingBatch; size_t workingBatchItemSize = 0; - - int workingBatchDocSize = kRetryableBatchWriteBSONSizeOverhead; + int workingBatchDocSize = 0; while (!docs.empty()) { BSONObj toAdd = docs.back(); docs.pop_back(); - int docSize = toAdd.objsize(); - bool batchAtSizeLimit = (workingBatchItemSize + 1 > write_ops::kMaxWriteBatchSize) || - (workingBatchDocSize + docSize > BSONObjMaxUserSize); - - if (batchAtSizeLimit) { + const int docSizePlusOverhead = toAdd.objsize() + kRetryableBatchWriteBSONSizeOverhead; + // Check if pushing this object will exceed the batch size limit or the max object size + if ((workingBatchItemSize + 1 > write_ops::kMaxWriteBatchSize) || + (workingBatchDocSize + docSizePlusOverhead > BSONObjMaxUserSize)) { sendRetryableWriteBatchRequestToConfig( asr.opCtx(), nss, workingBatch, currentTxnNumber, writeConcern); ++currentTxnNumber; workingBatch.clear(); workingBatchItemSize = 0; - workingBatchDocSize = kRetryableBatchWriteBSONSizeOverhead; + workingBatchDocSize = 0; } workingBatch.push_back(toAdd); ++workingBatchItemSize; - workingBatchDocSize += docSize; + workingBatchDocSize += docSizePlusOverhead; } if (!workingBatch.empty()) { |