From 4406a3674738f41826413a412025b1cef4857024 Mon Sep 17 00:00:00 2001 From: Daniel Gottlieb Date: Thu, 29 Aug 2019 20:19:05 +0000 Subject: 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) --- src/mongo/db/storage/bson_collection_catalog_entry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(); -- cgit v1.2.1