mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
SERVER-36893 Change autosplit_heuristics.js to wait for chunk splitting after each insert
This commit is contained in:
parent
ce0602665a
commit
3ef3a0de87
@ -42,8 +42,8 @@
|
||||
|
||||
jsTest.log("Setup collection...");
|
||||
st.printShardingStatus(true);
|
||||
|
||||
var approxSize = Object.bsonsize({_id: 0.0});
|
||||
var pad = (new Array(1024)).join(' ');
|
||||
var approxSize = Object.bsonsize({_id: 0.0, pad: pad});
|
||||
|
||||
jsTest.log("Starting inserts of approx size: " + approxSize + "...");
|
||||
|
||||
@ -65,19 +65,18 @@
|
||||
});
|
||||
|
||||
// Insert enough docs to trigger splits into all chunks
|
||||
var bulk = coll.initializeUnorderedBulkOp();
|
||||
for (var i = 0; i < totalInserts; i++) {
|
||||
bulk.insert({_id: i % numChunks + (i / totalInserts)});
|
||||
assert.writeOK(coll.insert({_id: i % numChunks + (i / totalInserts), pad: pad}));
|
||||
// Splitting is asynchronous so we should wait after each insert
|
||||
// for autosplitting to happen
|
||||
waitForOngoingChunkSplits(st);
|
||||
}
|
||||
assert.writeOK(bulk.execute());
|
||||
|
||||
jsTest.log("Inserts completed...");
|
||||
|
||||
st.printShardingStatus(true);
|
||||
printjson(coll.stats());
|
||||
|
||||
waitForOngoingChunkSplits(st);
|
||||
|
||||
// Check that all chunks (except the two extreme chunks)
|
||||
// have been split at least once + 1 extra chunk as reload buffer
|
||||
assert.gte(config.chunks.count({"ns": "foo.hashBar"}), numChunks * 2 + 3);
|
||||
|
Loading…
Reference in New Issue
Block a user