summaryrefslogtreecommitdiff
path: root/jstests/concurrency
diff options
context:
space:
mode:
authorAllison Easton <allison.easton@mongodb.com>2022-05-31 12:05:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-31 12:34:36 +0000
commit2a61fb48311b141c92bb0185fe7cb3caa0480ac0 (patch)
tree1d6b9fd8346a05bc9e2727fa8c9133402b0033a9 /jstests/concurrency
parentd88a892d5b18035bd0f5393a42690e705c2007d7 (diff)
downloadmongo-2a61fb48311b141c92bb0185fe7cb3caa0480ac0.tar.gz
SERVER-66074 Remove usage of toArray in collection_defragmentation.js
Diffstat (limited to 'jstests/concurrency')
-rw-r--r--jstests/concurrency/fsm_workloads/collection_defragmentation.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/jstests/concurrency/fsm_workloads/collection_defragmentation.js b/jstests/concurrency/fsm_workloads/collection_defragmentation.js
index b986e0f73ee..7ec9bb8b071 100644
--- a/jstests/concurrency/fsm_workloads/collection_defragmentation.js
+++ b/jstests/concurrency/fsm_workloads/collection_defragmentation.js
@@ -38,6 +38,19 @@ function getExtendedCollectionShardKey(configDB, ns) {
return currentShardKey;
}
+function getAllChunks(configDB, ns, keyPattern) {
+ let chunksCursor = findChunksUtil.findChunksByNs(configDB, ns).sort(keyPattern);
+ let chunkArray = [];
+ while (!chunksCursor.isExhausted()) {
+ while (chunksCursor.objsLeftInBatch()) {
+ chunkArray.push(chunksCursor.next());
+ }
+ chunksCursor =
+ findChunksUtil.findChunksByNs(configDB, ns).sort(keyPattern).skip(chunkArray.length);
+ }
+ return chunkArray;
+}
+
var $config = (function() {
var states = {
init: function init(db, collName, connCache) {
@@ -98,12 +111,10 @@ var $config = (function() {
const configDB = randomDB.getSiblingDB('config');
const keyPattern = getCollectionShardKey(configDB, randomColl.getFullName());
- // Get all the chunks
- const chunks = findChunksUtil.findChunksByNs(configDB, randomColl.getFullName())
- .sort(keyPattern)
- .toArray();
+ // Get all the chunks without using getMore so the test can run with stepdowns.
+ const chunks = getAllChunks(configDB, randomColl.getFullName(), keyPattern);
- // No chunks to merge is there are less than 2 chunks
+ // No possible merges if there are less than 2 chunks.
if (chunks.length < 2) {
return;
}