summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/noPassthrough/query_knobs_validation.js9
-rw-r--r--src/mongo/db/pipeline/document_source_writer.h19
-rw-r--r--src/mongo/db/query/query_knobs.idl13
3 files changed, 25 insertions, 16 deletions
diff --git a/jstests/noPassthrough/query_knobs_validation.js b/jstests/noPassthrough/query_knobs_validation.js
index 6096748afd0..76c6c633b44 100644
--- a/jstests/noPassthrough/query_knobs_validation.js
+++ b/jstests/noPassthrough/query_knobs_validation.js
@@ -45,7 +45,7 @@ const expectedParamDefaults = {
internalQueryPlannerGenerateCoveredWholeIndexScans: false,
internalQueryIgnoreUnknownJSONSchemaKeywords: false,
internalQueryProhibitBlockingMergeOnMongoS: false,
- documentSourceWriterBatchBuffer: 0,
+ internalQueryDocumentSourceWriterBatchExtraReservedBytes: 0,
};
function assertDefaultParameterValues() {
@@ -178,5 +178,12 @@ assertSetParameterSucceeds("internalDocumentSourceLookupCacheSizeBytes", 11);
assertSetParameterSucceeds("internalDocumentSourceLookupCacheSizeBytes", 0);
assertSetParameterFails("internalDocumentSourceLookupCacheSizeBytes", -1);
+assertSetParameterSucceeds("internalQueryDocumentSourceWriterBatchExtraReservedBytes", 10);
+assertSetParameterSucceeds("internalQueryDocumentSourceWriterBatchExtraReservedBytes",
+ 4 * 1024 * 1024);
+assertSetParameterFails("internalQueryDocumentSourceWriterBatchExtraReservedBytes", -1);
+assertSetParameterFails("internalQueryDocumentSourceWriterBatchExtraReservedBytes",
+ 9 * 1024 * 1024);
+
MongoRunner.stopMongod(conn);
})();
diff --git a/src/mongo/db/pipeline/document_source_writer.h b/src/mongo/db/pipeline/document_source_writer.h
index 10bb21ddefc..6b845745c18 100644
--- a/src/mongo/db/pipeline/document_source_writer.h
+++ b/src/mongo/db/pipeline/document_source_writer.h
@@ -237,19 +237,20 @@ DocumentSource::GetNextResult DocumentSourceWriter<B>::doGetNext() {
_initialized = true;
}
- // While most metadata attached to a command is limited to less than a KB,
- // Impersonation metadata may grow to an arbitrary size.
- // Ask the active Client how much impersonation metadata we'll use for it,
- // add in our own estimate of write header size, and assume that the rest can fit
- // in the space reserved by BSONObjMaxUserSize's overhead plus
- // the value from the server parameter: documentSourceWriterBatchBuffer.
+ // While most metadata attached to a command is limited to less than a KB, Impersonation
+ // metadata may grow to an arbitrary size.
+ //
+ // Ask the active Client how much impersonation metadata we'll use for it, add in our own
+ // estimate of write header size, and assume that the rest can fit in the space reserved by
+ // BSONObjMaxUserSize's overhead plus the value from the server parameter:
+ // internalQueryDocumentSourceWriterBatchExtraReservedBytes.
const auto estimatedMetadataSizeBytes =
- rpc::estimateImpersonatedUserMetadataSize(pExpCtx->opCtx) +
- gDocumentSourceWriterBatchBufferBytes;
+ rpc::estimateImpersonatedUserMetadataSize(pExpCtx->opCtx);
BatchedCommandRequest batchWrite = initializeBatchedWriteRequest();
const auto writeHeaderSize = estimateWriteHeaderSize(batchWrite);
- const auto initialRequestSize = estimatedMetadataSizeBytes + writeHeaderSize;
+ const auto initialRequestSize = estimatedMetadataSizeBytes + writeHeaderSize +
+ internalQueryDocumentSourceWriterBatchExtraReservedBytes.load();
uassert(7637800,
"Unable to proceed with write while metadata size ({}KB) exceeds {}KB"_format(
diff --git a/src/mongo/db/query/query_knobs.idl b/src/mongo/db/query/query_knobs.idl
index 53885816fc8..7dc4684eb80 100644
--- a/src/mongo/db/query/query_knobs.idl
+++ b/src/mongo/db/query/query_knobs.idl
@@ -448,12 +448,13 @@ server_parameters:
cpp_vartype: AtomicWord<bool>
default: false
- documentSourceWriterBatchBuffer:
- description: 'Space to reserve in document source writer batches for miscellaneous metadata'
- set_at: startup
- cpp_vartype: int
- cpp_varname: gDocumentSourceWriterBatchBufferBytes
+ internalQueryDocumentSourceWriterBatchExtraReservedBytes:
+ description: "Space to reserve in document source writer batches for miscellaneous metadata"
+ set_at: [ startup, runtime ]
+ cpp_vartype: AtomicWord<int>
+ cpp_varname: internalQueryDocumentSourceWriterBatchExtraReservedBytes
validator:
gte: 0
- lte: 8388608 # 8MB
+ lte:
+ expr: 8 * 1024 * 1024 # 8MB
default: 0