summaryrefslogtreecommitdiff
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
parent83a0479dbb78f73366a91b4afe9da44f6f5e9cf0 (diff)
downloadmongo-461b2dee7d731d5a9cf5dd5000d73536bb534b56.tar.gz
SERVER-21254 Get rid of the DuplicateKeyValue error code
-rw-r--r--src/mongo/base/error_codes.yml6
-rw-r--r--src/mongo/db/index/index_access_method.cpp26
-rw-r--r--src/mongo/db/index/index_access_method.h8
3 files changed, 5 insertions, 35 deletions
diff --git a/src/mongo/base/error_codes.yml b/src/mongo/base/error_codes.yml
index 9c806fce610..2efc049e995 100644
--- a/src/mongo/base/error_codes.yml
+++ b/src/mongo/base/error_codes.yml
@@ -111,11 +111,11 @@ error_codes:
- {code: 81,name: NoMatchParseContext}
- {code: 82,name: NoProgressMade}
- {code: 83,name: RemoteResultsUnavailable}
- - {code: 84,name: DuplicateKeyValue}
+ - {code: 84,name: OBSOLETE_DuplicateKeyValue}
- {code: 85,name: IndexOptionsConflict}
- {code: 86,name: IndexKeySpecsConflict}
- {code: 87,name: CannotSplit}
- - {code: 88,name: SplitFailed_OBSOLETE}
+ - {code: 88,name: OBSOLETE_SplitFailed}
- {code: 89,name: NetworkTimeout,categories: [NetworkError,RetriableError,NetworkTimeoutError]}
- {code: 90,name: CallbackCanceled,categories: [CancelationError]}
- {code: 91,name: ShutdownInProgress,
@@ -416,6 +416,6 @@ error_codes:
- {code: 13435,name: NotMasterNoSlaveOk,categories: [NotMasterError,RetriableError]}
- {code: 13436,name: NotMasterOrSecondary,categories: [NotMasterError,RetriableError]}
- {code: 14031,name: OutOfDiskSpace}
- - {code: 17280,name: OSBELETE_KeyTooLong}
+ - {code: 17280,name: OBSOLETE_KeyTooLong}
- {code: 46841,name: ClientMarkedKilled,categories: [Interruption,CancelationError]}
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.