diff options
author | Arun Banala <arun.banala@mongodb.com> | 2019-02-01 12:39:00 +0000 |
---|---|---|
committer | Arun Banala <arun.banala@mongodb.com> | 2019-02-06 18:16:29 +0000 |
commit | 2b674c38879a8e3074924c0fe892c52ceec3ea0e (patch) | |
tree | f7c86597b1578451233d717edd402e7f9b6201dd /src/mongo/db/ops | |
parent | 5cbcfe8b8a2444a7d5d6274ff90d7de32eef9adc (diff) | |
download | mongo-2b674c38879a8e3074924c0fe892c52ceec3ea0e.tar.gz |
SERVER-35402 Add validators where applicable in query_knobs.cpp
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r-- | src/mongo/db/ops/write_ops.h | 3 | ||||
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/db/ops/write_ops.h b/src/mongo/db/ops/write_ops.h index a8a233c0128..a9939d0e5f7 100644 --- a/src/mongo/db/ops/write_ops.h +++ b/src/mongo/db/ops/write_ops.h @@ -62,6 +62,9 @@ namespace write_ops { // used if the protocol changes to avoid the 16MB limit on reply size. constexpr size_t kMaxWriteBatchSize = 100'000; +// Limit the size that we write without yielding to 16MB / 64 (max expected number of indexes) +constexpr size_t insertVectorMaxBytes = 256 * 1024; + /** * Retrieves the statement id for the write at the specified position in the write batch entries * array. diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index a273dd31e95..7607384169b 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -60,7 +60,6 @@ #include "mongo/db/ops/write_ops_retryability.h" #include "mongo/db/query/get_executor.h" #include "mongo/db/query/plan_summary_stats.h" -#include "mongo/db/query/query_knobs.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/retryable_writes_stats.h" @@ -523,6 +522,7 @@ WriteResult performInserts(OperationContext* opCtx, size_t bytesInBatch = 0; std::vector<InsertStatement> batch; const size_t maxBatchSize = internalInsertMaxBatchSize.load(); + const size_t maxBatchBytes = write_ops::insertVectorMaxBytes; batch.reserve(std::min(wholeOp.getDocuments().size(), maxBatchSize)); for (auto&& doc : wholeOp.getDocuments()) { @@ -547,7 +547,7 @@ WriteResult performInserts(OperationContext* opCtx, BSONObj toInsert = fixedDoc.getValue().isEmpty() ? doc : std::move(fixedDoc.getValue()); batch.emplace_back(stmtId, toInsert); bytesInBatch += batch.back().doc.objsize(); - if (!isLastDoc && batch.size() < maxBatchSize && bytesInBatch < insertVectorMaxBytes) + if (!isLastDoc && batch.size() < maxBatchSize && bytesInBatch < maxBatchBytes) continue; // Add more to batch before inserting. } |