SERVER-106614 Match config.shards entries without replSetConfigVersion.

GitOrigin-RevId: bed99f699da6cb2b74262aa6d473446c41476643
This commit is contained in:
Max Hirschhorn 2025-06-24 03:45:52 +00:00 committed by MongoDB Bot
parent 3369f76f50
commit 9730cd82e1
2 changed files with 19 additions and 2 deletions

View File

@ -167,6 +167,20 @@ for (const oldVersion of [lastLTSFCV, lastContinuousFCV]) {
jsTest.log('Upgrading binaries to latest version');
st.upgradeCluster('latest');
const newNode = st.shard0.rs.add({shardsvr: "", rsConfig: {priority: 0, votes: 0}});
st.shard0.rs.reInitiate();
st.shard0.rs.awaitSecondaryNodes();
let shard;
assert.soon(
() => {
shard = st.s.getCollection("config.shards").findOne({_id: st.shard0.shardName});
const hosts = MongoURI(shard.host).servers.map(x => x.server);
return hosts.includes(newNode.host);
},
() => `timed out waiting for replica set shard primary to add ${
newNode.host} to config.shards entry: ${tojson(shard)}`);
checkClusterAfterBinaryUpgrade();
jsTest.log('Upgrading FCV to ' + latestFCV);

View File

@ -548,8 +548,11 @@ void ShardRegistry::scheduleReplicaSetUpdateOnConfigServerIfNeeded(
// Specify the config version in the filter and the update to prevent overwriting a
// newer connection string when there are concurrent updates.
auto filter =
BSON(ShardType::name() << shard->getId().toString() << ShardType::replSetConfigVersion()
<< BSON("$lt" << replSetConfigVersion));
BSON(ShardType::name()
<< shard->getId().toString() << "$or"
<< BSON_ARRAY(BSON(ShardType::replSetConfigVersion() << BSON("$exists" << false))
<< BSON(ShardType::replSetConfigVersion()
<< BSON("$lt" << replSetConfigVersion))));
auto update = BSON("$set" << BSON(ShardType::host()
<< connStr.toString() << ShardType::replSetConfigVersion()
<< replSetConfigVersion));