[SERVER-69780] replicaset.py does not allow you to use a custom replica set name Created: 16/Sep/22  Updated: 17/Sep/22  Resolved: 17/Sep/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Vishnu Kaushik Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Though the ReplicaSetFixture class has the option to pass in a replica set name, the name is overwritten and set to "rs" any time the "serverless" flag isn't in use.

We want the ability to use the replica set name passed in even when the "serverless" flag isn't being used.



 Comments   
Comment by Vishnu Kaushik [ 16/Sep/22 ]

max.hirschhorn@mongodb.com I actually hadn't run it yet, but I was just taking a look at how it's propagated to the shell and it looked like the code was faulty... and it works as expected, so sorry about the false alarm!

Comment by Max Hirschhorn [ 16/Sep/22 ]

vishnu.kaushik@mongodb.com, can you post what resmoke invocation and YAML suite file contents you tried? The following is what I'm doing and the ?replicaSet connection string option is propagated to the mongo shell correctly.

$ python buildscripts/resmoke.py run --suite=replica_sets_jscore_passthrough jstests/core/all.js
...
[js_test:all] Starting JSTest jstests/core/all.js...
PATH=... /home/ubuntu/mongo/build/install/bin/mongo --eval '...' 'mongodb://localhost:20000,localhost:20001/?replicaSet=someOtherName' jstests/core/all.js

diff --git a/buildscripts/resmokeconfig/suites/replica_sets_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/replica_sets_jscore_passthrough.yml
index ad1b5e0f6f2..0c2bc46e02c 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_jscore_passthrough.yml
@@ -48,4 +48,6 @@ executor:
     mongod_options:
       set_parameters:
         enableTestCommands: 1
+      replSet: someOtherName
     num_nodes: 2
+    use_replica_set_connection_string: true

Comment by Didier Nadeau [ 16/Sep/22 ]

vishnu.kaushik@mongodb.com with `serverless` mode we start without specifying a replica set name so the server can learn it through heartbeats/replSetStepUp. This change was made to allow this.

I've taken a second look and I can recall why the `_init` does :

self.replset_name = replset_name
# ... then some time later
if "serverless" not in self.mongod_options:
    self.replset_name = self.mongod_options.setdefault("replSet", "rs")

It's been a while and I haven't dealt with the Python code that much. I've done some change (remove the conditional block) and kicked off a patch to check the impact on the tests and better answer questions next week. Patch link

Comment by Vishnu Kaushik [ 16/Sep/22 ]

Hmm unfortunately the driver connection URL we get from the fixture will not return the one under mongod_options.replSet but will use the name set in the ReplicaSetFixture itself. So even if I manually set the mongod_options section in the YAML file, when a hook requested the driver URL we would end up getting this constant name.

So I think we should maybe change this method to return the correct replica set name?

Comment by Vishnu Kaushik [ 16/Sep/22 ]

Thanks for pointing that out Max, I didn't realize that there was a separate mongod_options.replSet we can use. I think that should work.

Comment by Max Hirschhorn [ 16/Sep/22 ]

vishnu.kaushik@mongodb.com, my understanding of the Python code is that you can set mongod_options.replSet in the YAML suite file to pass that --replSet value into mongod and resmoke will know to use that for its replSetInitiate command. It looks like Serverless introduced a separate mechanism for setting the replica set name because they aren't always using the --replSet option (SERVER-63266).

diff --git a/buildscripts/resmokeconfig/suites/replica_sets_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/replica_sets_jscore_passthrough.yml
index ad1b5e0f6f2..9093105df3d 100644
--- a/buildscripts/resmokeconfig/suites/replica_sets_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/replica_sets_jscore_passthrough.yml
@@ -48,4 +48,5 @@ executor:
     mongod_options:
       set_parameters:
         enableTestCommands: 1
+      replSet: someOtherName
     num_nodes: 2

[j0] Issuing replSetInitiate command: {'_id': 'someOtherName', 'protocolVersion': 1, 'settings': {'electionTimeoutMillis': 86400000}, 'members': [{'_id': 0, 'host': 'localhost:20000'}]}
...
[j0:prim] {"t":{"$date":"2022-09-16T16:51:51.684+00:00"},"s":"I",  "c":"REPL",     "id":21392,   "ctx":"conn7","msg":"New replica set config in use","attr":{"config":{"_id":"someOtherName","version":1,"term":0,"members":[{"_id":0,"host":"localhost:20000","arbiterOnly":false,"buildIndexes":true,"hidden":false,"priority":1,"tags":{},"secondaryDelaySecs":0,"votes":1}],"protocolVersion":1,"writeConcernMajorityJournalDefault":true,"settings":{"chainingAllowed":true,"heartbeatIntervalMillis":2000,"heartbeatTimeoutSecs":10,"electionTimeoutMillis":86400000,"catchUpTimeoutMillis":-1,"catchUpTakeoverDelayMillis":30000,"getLastErrorModes":{},"getLastErrorDefaults":{"w":1,"wtimeout":0},"replicaSetId":{"$oid":"6324a9a797defbbc69e37394"}}}}}

Comment by Vishnu Kaushik [ 16/Sep/22 ]

CC didier.nadeau@mongodb.com

Generated at Thu Feb 08 06:14:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.