summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Xiao <jeffrey.xiao@mongodb.com>2022-08-02 13:14:18 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-02 13:49:05 +0000
commitee648d59acd37f7a177e1f248359dc7472a6ca4e (patch)
treea8b81268969ab3fc3b440713b6e79a5331f84288
parent7f78636fc0c825c476871e35d010623957204a04 (diff)
downloadmongo-ee648d59acd37f7a177e1f248359dc7472a6ca4e.tar.gz
SERVER-68319 Modify `checkSBEEnabled` to check feature flags for all nodes (BF-25843)
-rw-r--r--jstests/core/hidden_index.js4
-rw-r--r--jstests/libs/sbe_util.js48
2 files changed, 34 insertions, 18 deletions
diff --git a/jstests/core/hidden_index.js b/jstests/core/hidden_index.js
index 3e93c4e98af..931c27a5df5 100644
--- a/jstests/core/hidden_index.js
+++ b/jstests/core/hidden_index.js
@@ -17,8 +17,8 @@ load("jstests/libs/fixture_helpers.js"); // For FixtureHelpers.
load("jstests/libs/index_catalog_helpers.js"); // For IndexCatalogHelpers.findByName.
load("jstests/libs/sbe_util.js"); // For checkSBEEnabled.
-const columnstoreEnabled =
- checkSBEEnabled(db, ["featureFlagColumnstoreIndexes", "featureFlagSbeFull"]);
+const columnstoreEnabled = checkSBEEnabled(
+ db, ["featureFlagColumnstoreIndexes", "featureFlagSbeFull"], true /* checkAllNodes */);
const collName = "hidden_index";
let coll = assertDropAndRecreateCollection(db, collName);
diff --git a/jstests/libs/sbe_util.js b/jstests/libs/sbe_util.js
index be6d3509ea7..f6135df7db0 100644
--- a/jstests/libs/sbe_util.js
+++ b/jstests/libs/sbe_util.js
@@ -9,14 +9,21 @@ load("jstests/libs/fixture_helpers.js"); // For 'isMongos'
* Returns whether or not SBE is enabled for the given connection. Assumes that for repl sets and
* sharded clusters, SBE is either enabled on each node, or disabled on each node.
* If 'featureFlags' is non-empty, checks if SBE and all the feature flags are enabled.
+ * If 'checkAllNodes` is true, explicitly checks if feature flags are enabled for all
+ * nodes.
*/
-function checkSBEEnabled(theDB, featureFlags = []) {
- let checkResult = false;
+function checkSBEEnabled(theDB, featureFlags = [], checkAllNodes = false) {
+ // By default, we find that SBE is enabled. If, for any node, we find that the classic engine is
+ // on, `checkResult` will be set to false. This is done intentionally so that in the event that
+ // we check all nodes, the effects from previously visited nodes will carry over into the rest.
+ // If we are not checking all nodes, `checkResult` is reset to true before each iteration.
+ let checkResult = true;
assert.soon(() => {
// Some test suites kill the primary, potentially resulting in networking errors. We use:
// 1. try..catch below to retry the whole check if we failed to discover topology
- // 2. try..catch in the loop to try the next node if the current is killed
+ // 2. try..catch in the loop to try the next node if the current is killed (if we aren't
+ // checking to ensure that all feature flags are enabled on all nodes).
let nodes;
try {
nodes = DiscoverTopology.findNonConfigNodes(theDB.getMongo());
@@ -36,18 +43,11 @@ function checkSBEEnabled(theDB, featureFlags = []) {
const getParam = conn.adminCommand({
getParameter: 1,
internalQueryForceClassicEngine: 1,
- internalQueryEnableSlotBasedExecutionEngine: 1
});
- if (getParam.hasOwnProperty("internalQueryForceClassicEngine") &&
- !getParam.internalQueryForceClassicEngine) {
- checkResult = true;
- }
-
- // Some versions use a different parameter to disable SBE instead of enabling it.
- if (getParam.hasOwnProperty("internalQueryEnableSlotBasedExecutionEngine") &&
- getParam.internalQueryEnableSlotBasedExecutionEngine) {
- checkResult = true;
+ if (!getParam.hasOwnProperty("internalQueryForceClassicEngine") ||
+ getParam.internalQueryForceClassicEngine) {
+ checkResult = false;
}
featureFlags.forEach(function(featureFlag) {
@@ -56,13 +56,29 @@ function checkSBEEnabled(theDB, featureFlags = []) {
featureFlagParam[featureFlag]["value"];
});
- return true;
+ // Exit `assert.soon` if we are only analyzing one node in the cluster.
+ if (!checkAllNodes) {
+ return true;
+ }
} catch (e) {
- continue;
+ // Unable to verify that all feature flags are enabled on the current node. Return
+ // early from `assert.soon` if we're checking all nodes; otherwise, try the next
+ // node.
+ if (checkAllNodes) {
+ return false;
+ } else {
+ checkResult = true;
+ continue;
+ }
}
}
- return false;
+ // If we are not checking feature flags on all nodes, this result only occurs when we catch
+ // an exception for each node. In this case, the output of `assert.soon` should be false.
+ // If we are checking feature flags on all nodes, this result only occurs when we
+ // successfully iterate over each node and update the local boolean flags. In this case, the
+ // output of `assert.soon` should be true.
+ return checkAllNodes;
});
return checkResult;