summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@mongodb.com>2023-06-29 02:11:23 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-06-29 02:35:52 +0000
commit36c047f935fd86b2d5ac4c4f5189e52daa044966 (patch)
treed70d4e35f932331ed6c3d9d8cbed090966b2e317 /src
parentb6f816f31c0bb4cf8845b0858346bc3d0290dc4e (diff)
SERVER-78314 Add server parameter internalQueryDocumentSourceWriterBatchExtraReservedBytesr4.4.23-rc0r4.4.23
(cherry picked from commit 67d3e420aa2c7e693fac97318a4a3fec1c6ced80)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/pipeline/document_source_writer.h19
-rw-r--r--src/mongo/db/query/query_knobs.idl13
2 files changed, 17 insertions, 15 deletions
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