summaryrefslogtreecommitdiff
path: root/src/mongo/db/index
diff options
context:
space:
mode:
authorBynn Lee <bynn.lee@mongodb.com>2020-07-08 21:24:32 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-10 22:29:51 +0000
commit461b2dee7d731d5a9cf5dd5000d73536bb534b56 (patch)
tree2f553c02eb91d2faca068c130d2e41c9d2d4e765 /src/mongo/db/index
parent83a0479dbb78f73366a91b4afe9da44f6f5e9cf0 (diff)
downloadmongo-461b2dee7d731d5a9cf5dd5000d73536bb534b56.tar.gz
SERVER-21254 Get rid of the DuplicateKeyValue error code
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r--src/mongo/db/index/index_access_method.cpp26
-rw-r--r--src/mongo/db/index/index_access_method.h8
2 files changed, 2 insertions, 32 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index b51b525f7aa..a9afbad441f 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -101,26 +101,6 @@ AbstractIndexAccessMethod::AbstractIndexAccessMethod(IndexCatalogEntry* btreeSta
verify(IndexDescriptor::isIndexVersionSupported(_descriptor->version()));
}
-bool AbstractIndexAccessMethod::isFatalError(OperationContext* opCtx,
- Status status,
- KeyString::Value key) {
- // If the status is Status::OK() return false immediately.
- if (status.isOK()) {
- return false;
- }
-
- // A document might be indexed multiple times during a background index build if it moves ahead
- // of the cursor (e.g. via an update). We test this scenario and swallow the error accordingly.
- if (status == ErrorCodes::DuplicateKeyValue && !_indexCatalogEntry->isReady(opCtx)) {
- LOGV2_DEBUG(20681,
- 3,
- "KeyString {key} already in index during background indexing (ok)",
- "key"_attr = key);
- return false;
- }
- return true;
-}
-
// Find the keys for obj, put them in the tree pointing to loc.
Status AbstractIndexAccessMethod::insert(OperationContext* opCtx,
const Collection* coll,
@@ -178,9 +158,8 @@ Status AbstractIndexAccessMethod::insertKeys(OperationContext* opCtx,
result->dupsInserted.push_back(key);
}
}
- if (isFatalError(opCtx, status, keyString)) {
+ if (!status.isOK())
return status;
- }
}
}
@@ -429,9 +408,8 @@ Status AbstractIndexAccessMethod::update(OperationContext* opCtx,
for (const auto keySet : {&ticket.added, &ticket.newMultikeyMetadataKeys}) {
for (const auto& keyString : *keySet) {
Status status = _newInterface->insert(opCtx, keyString, ticket.dupsAllowed);
- if (isFatalError(opCtx, status, keyString)) {
+ if (!status.isOK())
return status;
- }
}
}
diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h
index 793a298066a..fac28550154 100644
--- a/src/mongo/db/index/index_access_method.h
+++ b/src/mongo/db/index/index_access_method.h
@@ -578,14 +578,6 @@ private:
class BulkBuilderImpl;
/**
- * Determine whether the given Status represents an exception that should cause the indexing
- * process to abort. The 'key' argument is passed in to allow the offending entry to be logged
- * in the event that a non-fatal 'ErrorCodes::DuplicateKeyValue' is encountered during a
- * background index build.
- */
- bool isFatalError(OperationContext* opCtx, Status status, KeyString::Value key);
-
- /**
* Removes a single key from the index.
*
* Used by remove() only.