diff options
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/index/index_build_interceptor.cpp | 11 |
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. |