SERVER-112250 Test shard mongod starting without --shardsvr. (#42633)
GitOrigin-RevId: 470fe8a966ae4185b061921a634df94a640e8235
This commit is contained in:
parent
7277584dd6
commit
ae73e84ece
@ -67,3 +67,6 @@ filters:
|
||||
- "replica_set_to_csrs_promotion.js":
|
||||
approvers:
|
||||
- 10gen/server-catalog-and-routing
|
||||
- "startup_with_all_configs_down.js":
|
||||
approvers:
|
||||
- 10gen/server-catalog-and-routing-routing-and-topology
|
||||
|
||||
@ -2,11 +2,15 @@
|
||||
// server, and that they will wait until there is a config server online before handling any
|
||||
// sharding operations.
|
||||
//
|
||||
// However, if a shard mongod is restarted without --shardsvr mode then the shard mongod
|
||||
// will NOT wait until there is a config server online before continuing replication.
|
||||
//
|
||||
// This test involves restarting a standalone shard, so cannot be run on ephemeral storage engines.
|
||||
// A restarted standalone will lose all data when using an ephemeral storage engine.
|
||||
// @tags: [requires_persistence]
|
||||
|
||||
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
||||
import {stopServerReplication} from "jstests/libs/write_concern_util.js";
|
||||
|
||||
// The following checks use connections to shards cached on the ShardingTest object, but this test
|
||||
// restarts a shard, so the cached connection is not usable.
|
||||
@ -19,7 +23,8 @@ var st = new ShardingTest({
|
||||
// hours). For this test, we need a shorter election timeout because it relies on nodes running
|
||||
// an election when they do not detect an active primary. Therefore, we are setting the
|
||||
// electionTimeoutMillis to its default value.
|
||||
initiateWithDefaultElectionTimeout: true
|
||||
initiateWithDefaultElectionTimeout: true,
|
||||
rs1: {nodes: [{}, {rsConfig: {votes: 0, priority: 0}}]},
|
||||
});
|
||||
|
||||
jsTestLog("Setting up initial data");
|
||||
@ -37,6 +42,17 @@ assert.commandWorked(
|
||||
// Make sure the pre-existing mongos already has the routing information loaded into memory
|
||||
assert.eq(100, st.s.getDB('test').foo.find().itcount());
|
||||
|
||||
// We pause replication on one of the replica set shard secondaries and perform some additional
|
||||
// writes to later verify the secondary will catch up when --shardsvr is omitted.
|
||||
const secondary = st.rs1.getSecondary();
|
||||
stopServerReplication(secondary);
|
||||
|
||||
const collection = st.s0.getCollection("test.foo");
|
||||
for (let i = 75; i < 100; ++i) {
|
||||
assert.commandWorked(
|
||||
collection.update({_id: i}, {$inc: {x: 1}}, {writeConcern: {w: "majority"}}));
|
||||
}
|
||||
|
||||
jsTestLog("Shutting down all config servers");
|
||||
st.configRS.nodes.forEach((config) => {
|
||||
st.stopConfigServer(config);
|
||||
@ -50,8 +66,32 @@ assert.throws(function() {
|
||||
new Mongo(newMongosInfo.host);
|
||||
});
|
||||
|
||||
jsTestLog("Restarting a shard while there are no config servers up");
|
||||
st.rs1.stopSet(undefined, true);
|
||||
jsTestLog("Restarting a shard WITHOUT --shardsvr while there are no config servers up");
|
||||
// We won't be able to compare dbHashes because server replication was stopped on the secondary.
|
||||
st.rs1.stopSet(undefined, true, {skipCheckDBHashes: true, skipValidation: true});
|
||||
|
||||
for (let node of st.rs1.nodes) {
|
||||
delete node.fullOptions.shardsvr;
|
||||
|
||||
st.rs1.start(node.nodeId, undefined, /*restart=*/ true, /*waitForHealth=*/ false);
|
||||
if (node.nodeId === 0) {
|
||||
// We prevent the node from being or becoming primary because we want to exercise the case
|
||||
// where a secondary mongod is syncing from another secondary with the config server replica
|
||||
// set being entirely unavailable. This is also why we must restart the shard mongod
|
||||
// processes individually.
|
||||
st.rs1.freeze(node);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the non-voting shard mongod successfully syncs from the former primary.
|
||||
st.rs1.awaitReplication(undefined, undefined, undefined, undefined, st.rs1.nodes[0]);
|
||||
|
||||
jsTestLog("Restarting a shard WITH --shardsvr while there are no config servers up");
|
||||
// Since there is intentionally no primary for the replica set shard, we won't be able to compare
|
||||
// dbHashes still.
|
||||
st.rs1.stopSet(undefined, true, {skipCheckDBHashes: true, skipValidation: true});
|
||||
|
||||
st.rs1.nodes.forEach((node) => (node.fullOptions.shardsvr = ""));
|
||||
st.rs1.startSet({waitForConnect: false}, true);
|
||||
|
||||
jsTestLog("Queries should fail because the shard can't initialize sharding state");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user