Skip to content

Commit bd52f29

Browse files
awagenmakerMongoDB Bot
authored andcommitted
SERVER-87729 Disable FCV-gating for featureFlagQueryStats (#23609)
GitOrigin-RevId: b6875f604f34732acd4f741d04d88540a83aaeca
1 parent dd4368a commit bd52f29

File tree

4 files changed

+21
-41
lines changed

4 files changed

+21
-41
lines changed

jstests/multiVersion/genericBinVersion/query_stats_key_hash_version_consistency.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
load("jstests/multiVersion/libs/multi_rs.js");
99
load("jstests/libs/query_stats_utils.js"); // For getQueryStatsFindCmd and getQueryStatsKeyHashes.
1010

11-
// TODO SERVER-87729 Start from the previous version.
12-
const rst = new ReplSetTest(
13-
{nodes: {n1: {binVersion: "latest"}, n2: {binVersion: "latest"}, n3: {binVersion: "latest"}}});
11+
const rst = new ReplSetTest({
12+
nodes:
13+
{n1: {binVersion: "last-lts"}, n2: {binVersion: "last-lts"}, n3: {binVersion: "last-lts"}}
14+
});
1415

1516
// Turn on the collecting of query stats metrics.
1617
rst.startSet({setParameter: {internalQueryStatsRateLimit: -1}});

jstests/noPassthrough/queryStats/query_stats_disable_after_initial_request.js

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,8 @@ function setQueryStatsCacheSize(size) {
4747
assert.commandWorked(testDB.adminCommand({setParameter: 1, internalQueryStatsCacheSize: size}));
4848
}
4949

50-
function setFCV(newFCV) {
51-
assert.commandWorked(
52-
testDB.adminCommand({setFeatureCompatibilityVersion: newFCV, confirm: true}));
53-
}
54-
55-
// Tests the scenario of disabling QueryStats by setting internalQueryStatsCacheSize to
56-
// 0 and ending the command by running it to completion.
50+
// Tests the scenario of disabling query stats by setting internalQueryStatsCacheSize to 0 and
51+
// ending the command by running it to completion.
5752
testStatsAreNotCollectedWhenDisabledBeforeCommandCompletion({
5853
conn: testDB,
5954
coll,
@@ -73,26 +68,5 @@ testStatsAreNotCollectedWhenDisabledBeforeCommandCompletion({
7368
enableQueryStatsFn: () => setQueryStatsCacheSize("10MB")
7469
});
7570

76-
// Tests the scenario of disabling query stats by downgrading the FCV and ending the command by
77-
// running it to completion.
78-
testStatsAreNotCollectedWhenDisabledBeforeCommandCompletion({
79-
conn: testDB,
80-
coll,
81-
disableQueryStatsFn: () => setFCV(lastLTSFCV),
82-
endCommandFn: (cursor) => cursor.itcount(),
83-
enableQueryStatsFn: () => setFCV(binVersionToFCV("latest"))
84-
});
85-
86-
// Tests the scenario of disabling query stats by downgrading the FCV and ending the command by
87-
// killing the cursor.
88-
testStatsAreNotCollectedWhenDisabledBeforeCommandCompletion({
89-
conn: testDB,
90-
coll,
91-
disableQueryStatsFn: () => setFCV(lastLTSFCV),
92-
endCommandFn: (cursor) => assert.commandWorked(
93-
testDB.runCommand({killCursors: coll.getName(), cursors: [cursor.getId()]})),
94-
enableQueryStatsFn: () => setFCV(binVersionToFCV("latest"))
95-
});
96-
9771
MongoRunner.stopMongod(conn);
9872
}());

jstests/noPassthrough/queryStats/query_stats_upgrade.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/**
2-
* Test that query stats doesn't work on a lower FCV version but works after an FCV upgrade.
3-
* @tags: [requires_fcv_70, requires_persistence]
2+
* Test that query stats works both before and after an FCV upgrade.
3+
* @tags: [
4+
* # Query Stats should not skip FCV gating before 7.0.
5+
* requires_fcv_70,
6+
* # Re-uses FCV state in the dbpath.
7+
* requires_persistence
8+
* ]
49
*/
510
load('jstests/libs/analyze_plan.js');
611
load("jstests/libs/feature_flag_util.js");
@@ -23,20 +28,20 @@ function testLower(restart = false) {
2328
adminDB = conn.getDB("admin");
2429
}
2530

26-
assert.commandFailedWithCode(
27-
testDB.adminCommand({aggregate: 1, pipeline: [{$queryStats: {}}], cursor: {}}),
28-
[6579000, ErrorCodes.QueryFeatureNotAllowed]);
31+
// We should be able to run a query stats pipeline even though the FCV is not upgraded.
32+
assert.commandWorked(
33+
testDB.adminCommand({aggregate: 1, pipeline: [{$queryStats: {}}], cursor: {}}));
2934

3035
// Upgrade FCV.
3136
assert.commandWorked(adminDB.runCommand(
3237
{setFeatureCompatibilityVersion: binVersionToFCV("latest"), confirm: true}));
3338

34-
// We should be able to run a query stats pipeline now that the FCV is correct.
39+
// We should still be able to run a query stats pipeline on the upgraded FCV.
3540
assert.commandWorked(
3641
testDB.adminCommand({aggregate: 1, pipeline: [{$queryStats: {}}], cursor: {}}),
3742
);
3843
}
3944
testLower(true);
4045
testLower(false);
4146
MongoRunner.stopMongod(conn);
42-
})();
47+
})();

src/mongo/db/query/query_stats/query_stats.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ void updateStatistics(const QueryStatsStore::Partition& proofOfLock,
222222
} // namespace
223223

224224
bool isQueryStatsFeatureEnabled() {
225-
const auto fcvSnapshot = serverGlobalParams.featureCompatibility.acquireFCVSnapshot();
226-
return fcvSnapshot.isVersionInitialized() &&
227-
(feature_flags::gFeatureFlagQueryStats.isEnabled(fcvSnapshot));
225+
// (Ignore FCV check): Now that query stats is enabled on v6.0, we don't want to enforce FCV
226+
// gating on v7.0.
227+
return feature_flags::gFeatureFlagQueryStats.isEnabledAndIgnoreFCVUnsafe();
228228
}
229229

230230
void registerRequest(OperationContext* opCtx,

0 commit comments

Comments
 (0)