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:40:53 -0400
commit29ea16120d5fb478c3728a4ab3aac044df82a387 (patch)
tree3be9d0c33107fd61b1aa74db3ad5f18febf90979
parent143edc21c045a7c47c10ce4bcf552481789b7117 (diff)
downloadmongo-29ea16120d5fb478c3728a4ab3aac044df82a387.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 d5ea5ae8249..39536e14f4d 100644
--- a/src/mongo/db/storage/bson_collection_catalog_entry.cpp
+++ b/src/mongo/db/storage/bson_collection_catalog_entry.cpp
@@ -45,7 +45,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'.
@@ -57,6 +56,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();