1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* Utilities for column store indexes.
*/
load("jstests/libs/discover_topology.js"); // For findNonConfigNodes.
// For areAllCollectionsClustered.
load("jstests/libs/clustered_collections/clustered_collection_util.js");
load("jstests/noPassthrough/libs/server_parameter_helpers.js"); // For setParameterOnAllHosts.
load("jstests/libs/sbe_util.js"); // For checkSBEEnabled.
/**
* Updates server parameters to disable column scan query planning heuristics so that column scan
* will always be considered.
*
* This is intentionally done in all column scan correctness tests because we want to exercise
* column scan semantics regardless of whether column scan is performant on the test data. Coverage
* for the planning heuristics behavior is included in unit tests, no passthrough tests, and perf
* tests.
*/
function fullyEnableColumnScan(nodes) {
// Since the CSI query planning heuristics are OR-ed together, we can set any one of
// [internalQueryColumnScanMinAvgDocSizeBytes, internalQueryColumnScanMinCollectionSizeBytes,
// internalQueryColumnScanMinNumColumnFilters] to zero in order to fully enable column scan.
setParameterOnAllHosts(nodes, "internalQueryColumnScanMinNumColumnFilters", 0);
}
/**
* Returns true if the current testing environment is one where column store index creation is
* expected to succeed. Otherwise, logs the reason why the test will not create column store indexes
* and returns false.
*/
function safeToCreateColumnStoreIndex(db) {
return safeToCreateColumnStoreIndexInCluster(
DiscoverTopology.findNonConfigNodes(db.getMongo()));
}
function safeToCreateColumnStoreIndexInCluster(nodes) {
for (const node of nodes) {
const conn = new Mongo(node);
if (FixtureHelpers.isMongos(conn.getDB("admin"))) {
continue;
}
const fpName = "failpoint.createColumnIndexOnAllCollections";
const getParamRes = conn.getDB("admin").runCommand({getParameter: 1, [fpName]: 1});
if (!getParamRes.ok) {
return false;
}
if (getParamRes[fpName].mode) {
// Test is already configured to create column store indexes on all collections; skip
// it so that we don't create double indexes.
jsTestLog("Note: declining to create column store index, because they are already " +
"on all collections.");
return false;
}
if (ClusteredCollectionUtil.areAllCollectionsClustered(conn)) {
// Columnstore indexes are incompatible with clustered collections.
jsTestLog("Note: declining to create column store index, because all collections " +
"are clustered.");
return false;
}
const getParamFeatureFlagRes = assert.commandWorked(
conn.adminCommand({getParameter: 1, featureFlagColumnstoreIndexes: 1}));
if (!getParamFeatureFlagRes.featureFlagColumnstoreIndexes ||
!getParamFeatureFlagRes.featureFlagColumnstoreIndexes["value"]) {
jsTestLog("Note: declining to create column store index, because " +
"featureFlagColumnstoreIndexes is disabled");
return false;
}
}
return true;
}
/**
* Checks if the test is eligible to run and sets the appropriate parameters to use column store
* indexes. Returns true if setup was successful.
*/
function setUpServerForColumnStoreIndexTest(db) {
if (!checkSBEEnabled(db)) {
jsTestLog("Skipping column store index test since SBE is disabled");
return false;
}
let nodes = DiscoverTopology.findNonConfigNodes(db.getMongo());
if (!safeToCreateColumnStoreIndexInCluster(nodes)) {
jsTestLog(
"Skipping column store index test in suite where column store index creation may fail");
return false;
}
// TODO SERVER-75026: Re-enable CSI in parallel tests.
// Note that we should not fully enable columnscans during the parallel tests due to the side
// effect of clearing the SBE plan cache. Fully enabling column scans should only be done
// in non-parallel environments.
if ((TestData || {}).isParallelTest) {
return false;
} else {
fullyEnableColumnScan(nodes);
}
return true;
}
|