summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@mongodb.com>2019-09-17 13:42:13 +0000
committerevergreen <evergreen@mongodb.com>2019-09-17 13:42:13 +0000
commit9783116c8bd0c3c4414bc0b8b77b2ba629f1c823 (patch)
tree0a183767c43cdb4f5008a4db2e95bd9ab322fd58 /src/mongo
parenta46c2c1a6f69206b2b15f9e2ac366968bd966d54 (diff)
downloadmongo-9783116c8bd0c3c4414bc0b8b77b2ba629f1c823.tar.gz
SERVER-42837 Allow waitInFindBeforeBatch FailPoint to take data.nss parameter
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/commands/find_cmd.cpp8
-rw-r--r--src/mongo/db/commands/index_filter_commands.cpp5
-rw-r--r--src/mongo/db/exec/multi_plan.cpp4
-rw-r--r--src/mongo/db/query/SConscript3
-rw-r--r--src/mongo/db/query/canonical_query.cpp4
-rw-r--r--src/mongo/db/query/find.cpp3
-rw-r--r--src/mongo/db/query/find_common.cpp21
-rw-r--r--src/mongo/db/query/find_common.h10
-rw-r--r--src/mongo/s/query/cluster_find.cpp3
9 files changed, 43 insertions, 18 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index 88705768bcc..2711ee95da9 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -37,7 +37,6 @@
#include "mongo/db/commands.h"
#include "mongo/db/commands/run_aggregate.h"
#include "mongo/db/commands/test_commands_enabled.h"
-#include "mongo/db/curop_failpoint_helpers.h"
#include "mongo/db/cursor_manager.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/working_set_common.h"
@@ -444,12 +443,7 @@ public:
return;
}
- CurOpFailpointHelpers::waitWhileFailPointEnabled(&waitInFindBeforeMakingBatch,
- opCtx,
- "waitInFindBeforeMakingBatch",
- []() {},
- false,
- nss);
+ FindCommon::waitInFindBeforeMakingBatch(opCtx, *exec->getCanonicalQuery());
const QueryRequest& originalQR = exec->getCanonicalQuery()->getQueryRequest();
diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp
index de26b32142b..98ba9a5c66e 100644
--- a/src/mongo/db/commands/index_filter_commands.cpp
+++ b/src/mongo/db/commands/index_filter_commands.cpp
@@ -266,7 +266,7 @@ Status ClearFilters::clear(OperationContext* opCtx,
// Remove entry from plan cache
planCache->remove(*cq).transitional_ignore();
- LOG(0) << "Removed index filter on " << ns << " " << redact(cq->toStringShort());
+ LOG(0) << "Removed index filter on " << redact(cq->toStringShort());
return Status::OK();
}
@@ -399,8 +399,7 @@ Status SetFilter::set(OperationContext* opCtx,
// Remove entry from plan cache.
planCache->remove(*cq).transitional_ignore();
- LOG(0) << "Index filter set on " << ns << " " << redact(cq->toStringShort()) << " "
- << indexesElt;
+ LOG(0) << "Index filter set on " << redact(cq->toStringShort()) << " " << indexesElt;
return Status::OK();
}
diff --git a/src/mongo/db/exec/multi_plan.cpp b/src/mongo/db/exec/multi_plan.cpp
index 425a37087ff..24ee575a541 100644
--- a/src/mongo/db/exec/multi_plan.cpp
+++ b/src/mongo/db/exec/multi_plan.cpp
@@ -269,7 +269,7 @@ Status MultiPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) {
size_t runnerUpIdx = ranking->candidateOrder[1];
LOG(1) << "Winning plan tied with runner-up. Not caching."
- << " ns: " << collection()->ns() << " " << redact(_query->toStringShort())
+ << " query: " << redact(_query->toStringShort())
<< " winner score: " << ranking->scores[0]
<< " winner summary: " << Explain::getPlanSummary(_candidates[winnerIdx].root)
<< " runner-up score: " << ranking->scores[1] << " runner-up summary: "
@@ -283,7 +283,7 @@ Status MultiPlanStage::pickBestPlan(PlanYieldPolicy* yieldPolicy) {
size_t winnerIdx = ranking->candidateOrder[0];
LOG(1) << "Winning plan had zero results. Not caching."
- << " ns: " << collection()->ns() << " " << redact(_query->toStringShort())
+ << " query: " << redact(_query->toStringShort())
<< " winner score: " << ranking->scores[0]
<< " winner summary: " << Explain::getPlanSummary(_candidates[winnerIdx].root);
}
diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript
index 774678220d1..4c526ba5845 100644
--- a/src/mongo/db/query/SConscript
+++ b/src/mongo/db/query/SConscript
@@ -107,6 +107,9 @@ env.Library(
"query_planner",
"query_request",
],
+ LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/db/curop_failpoint_helpers',
+ ],
)
env.Library(
diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp
index ff77f314fa2..085a5abaec8 100644
--- a/src/mongo/db/query/canonical_query.cpp
+++ b/src/mongo/db/query/canonical_query.cpp
@@ -457,8 +457,8 @@ std::string CanonicalQuery::toString() const {
std::string CanonicalQuery::toStringShort() const {
str::stream ss;
- ss << "query: " << _qr->getFilter().toString() << " sort: " << _qr->getSort().toString()
- << " projection: " << _qr->getProj().toString();
+ ss << "ns: " << _qr->nss().ns() << " query: " << _qr->getFilter().toString()
+ << " sort: " << _qr->getSort().toString() << " projection: " << _qr->getProj().toString();
if (!_qr->getCollation().isEmpty()) {
ss << " collation: " << _qr->getCollation().toString();
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp
index d01fd699726..9ac91cb8768 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -657,8 +657,7 @@ std::string runQuery(OperationContext* opCtx,
}
opCtx->checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point.
- CurOpFailpointHelpers::waitWhileFailPointEnabled(
- &waitInFindBeforeMakingBatch, opCtx, "waitInFindBeforeMakingBatch");
+ FindCommon::waitInFindBeforeMakingBatch(opCtx, *exec->getCanonicalQuery());
// Run the query.
// bb is used to hold query results
diff --git a/src/mongo/db/query/find_common.cpp b/src/mongo/db/query/find_common.cpp
index a6c17f0158e..33de26862c9 100644
--- a/src/mongo/db/query/find_common.cpp
+++ b/src/mongo/db/query/find_common.cpp
@@ -27,14 +27,19 @@
* it in the license file.
*/
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery
+
#include "mongo/platform/basic.h"
#include "mongo/db/query/find_common.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/db/curop.h"
+#include "mongo/db/curop_failpoint_helpers.h"
+#include "mongo/db/query/canonical_query.h"
#include "mongo/db/query/query_request.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
namespace mongo {
@@ -89,4 +94,20 @@ BSONObj FindCommon::transformSortSpec(const BSONObj& sortSpec) {
return comparatorBob.obj();
}
+
+void FindCommon::waitInFindBeforeMakingBatch(OperationContext* opCtx, const CanonicalQuery& cq) {
+ auto whileWaitingFunc = [&, hasLogged = false]() mutable {
+ if (!std::exchange(hasLogged, true)) {
+ log() << "Waiting in find before making batch for query - "
+ << redact(cq.toStringShort());
+ }
+ };
+
+ CurOpFailpointHelpers::waitWhileFailPointEnabled(&mongo::waitInFindBeforeMakingBatch,
+ opCtx,
+ "waitInFindBeforeMakingBatch",
+ std::move(whileWaitingFunc),
+ /* checkForInterrupt = */ false,
+ cq.nss());
+}
} // namespace mongo
diff --git a/src/mongo/db/query/find_common.h b/src/mongo/db/query/find_common.h
index b46629409b7..14515224326 100644
--- a/src/mongo/db/query/find_common.h
+++ b/src/mongo/db/query/find_common.h
@@ -53,6 +53,7 @@ struct AwaitDataState {
extern const OperationContext::Decoration<AwaitDataState> awaitDataState;
class BSONObj;
+class CanonicalQuery;
class QueryRequest;
// Failpoint for making find hang.
@@ -125,6 +126,15 @@ public:
* meta-sort specification).
*/
static BSONObj transformSortSpec(const BSONObj& sortSpec);
+
+ /**
+ * This function wraps waitWhileFailPointEnabled() on waitInFindBeforeMakingBatch.
+ *
+ * Since query processing happens in three different places, this function makes it easier to
+ * check the failpoint for a query's namespace and log a helpful diagnostic message when the
+ * failpoint is active.
+ */
+ static void waitInFindBeforeMakingBatch(OperationContext* opCtx, const CanonicalQuery& cq);
};
} // namespace mongo
diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp
index cbc0d09d368..567110ae134 100644
--- a/src/mongo/s/query/cluster_find.cpp
+++ b/src/mongo/s/query/cluster_find.cpp
@@ -289,8 +289,7 @@ CursorId runQueryWithoutRetrying(OperationContext* opCtx,
// Retrieve enough data from the ClusterClientCursor for the first batch of results.
- CurOpFailpointHelpers::waitWhileFailPointEnabled(
- &waitInFindBeforeMakingBatch, opCtx, "waitInFindBeforeMakingBatch");
+ FindCommon::waitInFindBeforeMakingBatch(opCtx, query);
auto cursorState = ClusterCursorManager::CursorState::NotExhausted;
int bytesBuffered = 0;