Skip to content

Instantly share code, notes, and snippets.

@rueckstiess
Created April 1, 2014 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rueckstiess/9924918 to your computer and use it in GitHub Desktop.
Save rueckstiess/9924918 to your computer and use it in GitHub Desktop.
SERVER-12638 repro.js (shorter)
var clusterConfig = { shards : 3,
mongos : 3,
config : 1 };
var st = new ShardingTest(clusterConfig);
var mongos = st.s;
function createShardedCollections(collName, dbName, mongosHost) {
var mongos = new Mongo(mongosHost);
var i = 0;
assert.commandWorked(mongos.adminCommand({ enableSharding : dbName + "_" + i }));
assert.commandWorked(mongos.adminCommand({ shardcollection : dbName + "_" + i + "." + "collection",
key : { _id : "hashed" },
numInitialChunks : 15 }));
}
function parallelCreateShardedCollections(baseName, nthreads) {
var i = 0;
var threads = [];
for (i = 0; i < nthreads; ++i) {
var collName = baseName + "_";
var dbName = baseName + "_" + i;
threads[i] = new Thread(createShardedCollections, collName, dbName, mongos.host);
}
for (i = 0; i < nthreads; ++i) {
threads[i].start();
}
for (i = 0; i < nthreads; ++i) {
threads[i].join();
}
return true;
}
jsTest.log("Disabling balancer");
st.stopBalancer();
// mongos.getDB("config").settings.update({ _id: "balancer" }, { $set : { stopped : true } });
jsTest.log("Creating collections");
parallelCreateShardedCollections("basename", 10);
sleep(900000);
st.stop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment