summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2022-12-05 19:32:58 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-21 08:44:23 +0000
commit300f442d681cfebe47addc1756d8220c9864673e (patch)
treeb27afd76e911dc99641a19ddeec56c5abcf8e58a
parent354db83c8611c1eabb58c748430289168ae3a709 (diff)
downloadmongo-300f442d681cfebe47addc1756d8220c9864673e.tar.gz
SERVER-71436 Range deleter must not aggressively spam the log when shard key index not found
-rw-r--r--src/mongo/db/s/range_deletion_util.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/mongo/db/s/range_deletion_util.cpp b/src/mongo/db/s/range_deletion_util.cpp
index ceb014816a9..7f30748e9b7 100644
--- a/src/mongo/db/s/range_deletion_util.cpp
+++ b/src/mongo/db/s/range_deletion_util.cpp
@@ -130,12 +130,20 @@ StatusWith<int> deleteNextBatch(OperationContext* opCtx,
auto catalog = collection->getIndexCatalog();
const IndexDescriptor* idx = catalog->findShardKeyPrefixedIndex(opCtx, keyPattern, false);
if (!idx) {
- LOGV2_ERROR_OPTIONS(23765,
- {logv2::UserAssertAfterLog(ErrorCodes::InternalError)},
- "Unable to find shard key index for {keyPattern} in {namespace}",
- "Unable to find shard key index",
- "keyPattern"_attr = keyPattern.toString(),
- "namespace"_attr = nss.ns());
+ LOGV2_ERROR(23765,
+ "Unable to find shard key index",
+ "keyPattern"_attr = keyPattern,
+ "namespace"_attr = nss.ns());
+
+ // When a shard key index is not found, the range deleter gets stuck and indefinitely logs
+ // an error message. This sleep is aimed at avoiding logging too aggressively in order to
+ // prevent log files to increase too much in size.
+ opCtx->sleepFor(Seconds(5));
+
+ uasserted(ErrorCodes::IndexNotFound,
+ str::stream() << "Unable to find shard key index"
+ << " for " << nss.ns() << " and key pattern `"
+ << keyPattern.toString() << "'");
}
// Extend bounds to match the index we found