summaryrefslogtreecommitdiff
path: root/src/mongo/db/index
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-02-20 22:26:44 -0500
committerDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-02-21 08:35:39 -0500
commit5bd904dff90a0e6332d6d4630053141e6617c5de (patch)
treee694fecb2846108c0bb4757f440a8af16efb7d07 /src/mongo/db/index
parent1d6995441c39e5761f923dc7f9be01dd354ec3af (diff)
downloadmongo-5bd904dff90a0e6332d6d4630053141e6617c5de.tar.gz
SERVER-39705: Always observe multikey changes in IndexBuildInterceptor::sideWrite.
Diffstat (limited to 'src/mongo/db/index')
-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 715c4c60fb1..8b8ae089912 100644
--- a/src/mongo/db/index/index_build_interceptor.cpp
+++ b/src/mongo/db/index/index_build_interceptor.cpp
@@ -381,11 +381,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);
@@ -396,6 +395,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.