summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-08-29 20:19:05 +0000
committerDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-08-30 11:47:22 -0400
commit4406a3674738f41826413a412025b1cef4857024 (patch)
treebd46d646c8795be695bfb2d43c8ac7170ee06976
parent4ebd59eb450fc1a693472bca6df7ee353af4afec (diff)
downloadmongo-4406a3674738f41826413a412025b1cef4857024.tar.gz
SERVER-43074: Make appendMultikeyPathsAsBytes threadsafe.
The method previously relied on catalog level serialization for guaranteeing serialized access to a global variable. (cherry picked from commit eb47871d19c81d08827f83df0554ce2c83cd8487)
-rw-r--r--src/mongo/db/storage/bson_collection_catalog_entry.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.cpp b/src/mongo/db/storage/bson_collection_catalog_entry.cpp
index 7837e898b56..aa389dc4679 100644
--- a/src/mongo/db/storage/bson_collection_catalog_entry.cpp
+++ b/src/mongo/db/storage/bson_collection_catalog_entry.cpp
@@ -42,7 +42,6 @@ namespace {
// We use that value to represent the largest number of path components we could ever possibly
// expect to see in an indexed field.
const size_t kMaxKeyPatternPathLength = 2048;
-char multikeyPathsEncodedAsBytes[kMaxKeyPatternPathLength];
/**
* Encodes 'multikeyPaths' as binary data and appends it to 'bob'.
@@ -54,6 +53,8 @@ char multikeyPathsEncodedAsBytes[kMaxKeyPatternPathLength];
void appendMultikeyPathsAsBytes(BSONObj keyPattern,
const MultikeyPaths& multikeyPaths,
BSONObjBuilder* bob) {
+ char multikeyPathsEncodedAsBytes[kMaxKeyPatternPathLength];
+
size_t i = 0;
for (const auto keyElem : keyPattern) {
StringData keyName = keyElem.fieldNameStringData();