summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2023-05-18 00:17:48 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-05-18 03:02:02 +0000
commit475a34e15540935ef7678ec55adb1a336ccf3f25 (patch)
tree3a6b57c2573e88235e411f08a56ace46d5b0755b
parent3b4e340cd03eca77a1e3e18b4ca7d9a275178a82 (diff)
downloadmongo-v7.0.tar.gz
SERVER-77247 Allow users to retry a configureQueryAnalyzer command to disable query samplingv7.0
(cherry picked from commit d7bf13d97da047abfe9098a6b5f98678e89cd987)
-rw-r--r--jstests/concurrency/fsm_workloads/analyze_shard_key.js6
-rw-r--r--jstests/sharding/analyze_shard_key/configure_query_analyzer_persistence.js13
-rw-r--r--src/mongo/db/s/configure_query_analyzer_cmd.cpp8
3 files changed, 11 insertions, 16 deletions
diff --git a/jstests/concurrency/fsm_workloads/analyze_shard_key.js b/jstests/concurrency/fsm_workloads/analyze_shard_key.js
index 43a3f11bdbb..e7512bc4dc4 100644
--- a/jstests/concurrency/fsm_workloads/analyze_shard_key.js
+++ b/jstests/concurrency/fsm_workloads/analyze_shard_key.js
@@ -872,11 +872,7 @@ var $config = extendWorkload($config, function($config, $super) {
$config.states.disableQuerySampling = function disableQuerySampling(db, collName) {
print("Starting disableQuerySampling state");
const ns = db.getName() + "." + collName;
- // If query sampling is off, this command is expected to fail with an IllegalOperation
- // error.
- assert.commandWorkedOrFailedWithCode(
- db.adminCommand({configureQueryAnalyzer: ns, mode: "off"}),
- ErrorCodes.IllegalOperation);
+ assert.commandWorked(db.adminCommand({configureQueryAnalyzer: ns, mode: "off"}));
print("Finished disableQuerySampling state");
};
diff --git a/jstests/sharding/analyze_shard_key/configure_query_analyzer_persistence.js b/jstests/sharding/analyze_shard_key/configure_query_analyzer_persistence.js
index 6ba1108021a..aba1408b8d1 100644
--- a/jstests/sharding/analyze_shard_key/configure_query_analyzer_persistence.js
+++ b/jstests/sharding/analyze_shard_key/configure_query_analyzer_persistence.js
@@ -73,10 +73,10 @@ function testPersistingConfiguration(conn) {
tojson({dbName, collName, collUuid})}`);
// Run a configureQueryAnalyzer command to disable query sampling. Verify that the command
- // fails since query sampling is not even active.
+ // does not fail although query sampling is not even active.
const mode0 = "off";
- assert.commandFailedWithCode(conn.adminCommand({configureQueryAnalyzer: ns, mode: mode0}),
- ErrorCodes.IllegalOperation);
+ const res0 = assert.commandWorked(conn.adminCommand({configureQueryAnalyzer: ns, mode: mode0}));
+ assertConfigQueryAnalyzerResponse(res0, {mode: mode0} /* newConfig */);
assertNoQueryAnalyzerConfigDoc(conn, ns);
// Run a configureQueryAnalyzer command to enable query sampling.
@@ -151,10 +151,9 @@ function testPersistingConfiguration(conn) {
{mode: mode6} /* newConfig */,
{mode: mode5, sampleRate: sampleRate5} /* oldConfig */);
- // Retry the previous configureQueryAnalyzer command. Verify that the 'stopTime' remains the
- // same.
- assert.commandFailedWithCode(conn.adminCommand({configureQueryAnalyzer: ns, mode: mode6}),
- ErrorCodes.IllegalOperation);
+ // Retry the previous configureQueryAnalyzer command. Verify that the retry does not fail and
+ // that the 'stopTime' remains the same.
+ assert.commandWorked(conn.adminCommand({configureQueryAnalyzer: ns, mode: mode6}));
assertQueryAnalyzerConfigDoc(
conn, ns, collUuid, mode6, sampleRate5, doc5.startTime, doc6.stopTime);
}
diff --git a/src/mongo/db/s/configure_query_analyzer_cmd.cpp b/src/mongo/db/s/configure_query_analyzer_cmd.cpp
index 84b6fd11dbf..c523f286f69 100644
--- a/src/mongo/db/s/configure_query_analyzer_cmd.cpp
+++ b/src/mongo/db/s/configure_query_analyzer_cmd.cpp
@@ -246,10 +246,10 @@ public:
if (preImageDoc.getCollectionUuid() == collUuid) {
response.setOldConfiguration(preImageDoc.getConfiguration());
}
- } else {
- uassert(ErrorCodes::IllegalOperation,
- "Attempted to disable query sampling but query sampling was not active",
- mode != QueryAnalyzerModeEnum::kOff);
+ } else if (mode != QueryAnalyzerModeEnum::kOff) {
+ LOGV2_WARNING(
+ 7724700,
+ "Attempted to disable query sampling but query sampling was not active");
}
return response;