summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-06-11 14:26:15 -0400
committerBenety Goh <benety@mongodb.com>2019-06-11 14:26:35 -0400
commit11f1122708d82b1e499fed6438854d08a55168d2 (patch)
tree2e30b757cc907d1e9c4fd6c41ab39bfcff096bc1 /src/mongo/db
parent85ec26ff72f4029c52c40fab796ad53533828e60 (diff)
downloadmongo-11f1122708d82b1e499fed6438854d08a55168d2.tar.gz
SERVER-39705 Always observe multikey changes in IndexBuildInterceptor::sideWrite.
This re-applies commit 5bd904dff90a0e6332d6d4630053141e6617c5de with additional change to the js test hybrid_sparse_multikey_index.js.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/index/index_build_interceptor.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mongo/db/index/index_build_interceptor.cpp b/src/mongo/db/index/index_build_interceptor.cpp
index aaf57c66564..8d8f538691f 100644
--- a/src/mongo/db/index/index_build_interceptor.cpp
+++ b/src/mongo/db/index/index_build_interceptor.cpp
@@ -384,11 +384,10 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx,
// `multikeyMetadataKeys` when inserting.
*numKeysOut = keys.size() + (op == Op::kInsert ? multikeyMetadataKeys.size() : 0);
- if (*numKeysOut == 0) {
- return Status::OK();
- }
-
{
+ // SERVER-39705: It's worth noting that a document may not generate any keys, but be
+ // described as being multikey. This step must be done to maintain parity with `validate`s
+ // expectations.
stdx::unique_lock<stdx::mutex> lk(_multikeyPathMutex);
if (_multikeyPaths) {
MultikeyPathTracker::mergeMultikeyPaths(&_multikeyPaths.get(), multikeyPaths);
@@ -399,6 +398,10 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx,
}
}
+ if (*numKeysOut == 0) {
+ return Status::OK();
+ }
+
std::vector<BSONObj> toInsert;
for (const auto& key : keys) {
// Documents inserted into this table must be consumed in insert-order.