summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/sharding/query/lookup_unionWith_subpipeline_local_read.js23
-rw-r--r--src/mongo/db/service_entry_point_common.cpp20
2 files changed, 28 insertions, 15 deletions
diff --git a/jstests/sharding/query/lookup_unionWith_subpipeline_local_read.js b/jstests/sharding/query/lookup_unionWith_subpipeline_local_read.js
index 2da51eb3ca6..6e5e1978262 100644
--- a/jstests/sharding/query/lookup_unionWith_subpipeline_local_read.js
+++ b/jstests/sharding/query/lookup_unionWith_subpipeline_local_read.js
@@ -525,9 +525,11 @@ assert.commandWorked(otherForeign.insert([{_id: -1, c: 2}, {_id: 1, c: 1}, {_id:
{writeConcern: {w: 'majority'}}));
// Set a failpoint on the first aggregate to be run against the nested $lookup's foreign collection.
+let parallelTestComment = "lookup_foreign_becomes_sharded";
const data = {
ns: otherForeign.getFullName(),
- commands: ['aggregate']
+ commands: ['aggregate'],
+ comment: parallelTestComment
};
let failPoint = configureFailPoint(st.shard0, "waitAfterCommandFinishesExecution", data);
@@ -565,8 +567,8 @@ const parallelScript = (pipeline, expectedRes, comment) =>
// Start a parallel shell to run the nested $lookup.
clearLogs();
-let awaitShell = startParallelShell(
- parallelScript(pipeline, expectedRes, "lookup_foreign_becomes_sharded"), st.s.port);
+let awaitShell =
+ startParallelShell(parallelScript(pipeline, expectedRes, parallelTestComment), st.s.port);
// When we hit this failpoint, the nested $lookup will have just completed its first subpipeline.
// Shard 'foreign' to verify that $lookup execution changes correctly mid-query.
@@ -586,7 +588,7 @@ let expectedRouting = {
subPipelineLocal: [1, 0],
subPipelineRemote: [2, 2]
};
-assertProfilerEntriesMatch(expectedRouting, "lookup_foreign_becomes_sharded", pipeline);
+assertProfilerEntriesMatch(expectedRouting, parallelTestComment, pipeline);
//
// Test $lookup where the primary is moved in the middle of the query.
@@ -596,12 +598,15 @@ assertProfilerEntriesMatch(expectedRouting, "lookup_foreign_becomes_sharded", pi
assert(foreign.drop());
assert.commandWorked(foreign.insert([{_id: -1, b: 2}, {_id: 1, b: 1}, {_id: 2, b: 3}],
{writeConcern: {w: 'majority'}}));
+
+parallelTestComment = "lookup_primary_is_moved";
+data.comment = parallelTestComment;
failPoint = configureFailPoint(st.shard0, "waitAfterCommandFinishesExecution", data);
// Start a parallel shell to run the nested $lookup.
clearLogs();
awaitShell =
- startParallelShell(parallelScript(pipeline, expectedRes, "lookup_primary_is_moved"), st.s.port);
+ startParallelShell(parallelScript(pipeline, expectedRes, parallelTestComment), st.s.port);
// When we hit this failpoint, the nested $lookup will have just completed its first subpipeline.
// Move the primary to the other shard to verify that $lookup execution changes correctly mid-query.
@@ -619,7 +624,7 @@ expectedRouting = {
subPipelineLocal: [1, 0],
subPipelineRemote: [0, 2]
};
-assertProfilerEntriesMatch(expectedRouting, "lookup_primary_is_moved", pipeline);
+assertProfilerEntriesMatch(expectedRouting, parallelTestComment, pipeline);
//
// Test $graphLookup where the primary is moved in the middle of the query.
@@ -650,11 +655,13 @@ pipeline = [
}},
];
+parallelTestComment = "graphLookup_becomes_primary";
+data.comment = parallelTestComment;
failPoint = configureFailPoint(st.shard1, "waitAfterCommandFinishesExecution", data);
// Start a parallel shell to run the $graphLookup.
-awaitShell = startParallelShell(
- parallelScript(pipeline, expectedRes, "graphLookup_becomes_primary"), st.s.port);
+awaitShell =
+ startParallelShell(parallelScript(pipeline, expectedRes, parallelTestComment), st.s.port);
// When we hit this failpoint, the nested $lookup will have just completed its first subpipeline.
// Move the primary to the shard executing $graphLookup to verify that we still get correct results.
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 1dd97bef48b..dfcd884dbca 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -1034,8 +1034,8 @@ void RunCommandImpl::_epilogue() {
auto& behaviors = *execContext->behaviors;
// This fail point blocks all commands which are running on the specified namespace, or which
- // are present in the given list of commands.If no namespace or command list are provided,then
- // the failpoint will block all commands.
+ // are present in the given list of commands, or which match a given comment. If no namespace,
+ // command list, or comment are provided, then the failpoint will block all commands.
waitAfterCommandFinishesExecution.executeIf(
[&](const BSONObj& data) {
CurOpFailpointHelpers::waitWhileFailPointEnabled(
@@ -1045,14 +1045,20 @@ void RunCommandImpl::_epilogue() {
auto ns = data["ns"].valueStringDataSafe();
auto commands =
data.hasField("commands") ? data["commands"].Array() : std::vector<BSONElement>();
+ bool requestMatchesComment = data.hasField("comment")
+ ? data.getField("comment").woCompare(request.body.getField("comment")) == 0
+ : true;
- // If 'ns' or 'commands' is not set, block for all the namespaces or commands
- // respectively.
+ // If 'ns', 'commands', or 'comment' is not set, block for all the namespaces, commands,
+ // or comments respectively.
return (ns.empty() || _ecd->getInvocation()->ns().ns() == ns) &&
(commands.empty() ||
- std::any_of(commands.begin(), commands.end(), [&request](auto& element) {
- return element.valueStringDataSafe() == request.getCommandName();
- }));
+ std::any_of(commands.begin(),
+ commands.end(),
+ [&request](auto& element) {
+ return element.valueStringDataSafe() == request.getCommandName();
+ })) &&
+ requestMatchesComment;
});
behaviors.waitForLinearizableReadConcern(opCtx);