rueckstiess / mtools

A collection of scripts to set up MongoDB test environments and parse and visualize MongoDB log files.
Apache License 2.0
1.89k stars 403 forks source link

mlaunch fails to create a PSA without majority read concern #904

Open FGasper opened 1 year ago

FGasper commented 1 year ago

Expected behavior

This:

mlaunch init --auth --replicaset --nodes 2 --arbiter --enableMajorityReadConcern false

… should create a PSA cluster with majority read concern disabled.

Actual/current behavior

> mlaunch init --auth --replicaset --nodes 2 --arbiter --enableMajorityReadConcern false
Detected mongod version: 6.2.0
Generating keyfile: /Users/felipe/data/keyfile
launching: "mongod" on port 27017
launching: "mongod" on port 27018
launching: "mongod" on port 27019
Traceback (most recent call last):
  File "/Users/felipe/Library/Python/3.11/bin/mlaunch", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/mtools/mlaunch/mlaunch.py", line 2191, in main
    tool.run()
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/mtools/mlaunch/mlaunch.py", line 628, in run
    getattr(self, self.args['command'])()
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/mtools/mlaunch/mlaunch.py", line 807, in init
    self._initiate_replset(nodes[0], self.args['name'])
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/mtools/mlaunch/mlaunch.py", line 1824, in _initiate_replset
    rs_status = con['admin'].command({'replSetGetStatus': 1})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/pymongo/_csot.py", line 105, in csot_wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/pymongo/database.py", line 805, in command
    with self.__client._socket_for_reads(read_preference, session) as (
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/pymongo/mongo_client.py", line 1296, in _socket_for_reads
    server = self._select_server(read_preference, session)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/pymongo/mongo_client.py", line 1257, in _select_server
    server = topology.select_server(server_selector)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/pymongo/topology.py", line 272, in select_server
    server = self._select_server(selector, server_selection_timeout, address)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/pymongo/topology.py", line 261, in _select_server
    servers = self.select_servers(selector, server_selection_timeout, address)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/pymongo/topology.py", line 223, in select_servers
    server_descriptions = self._select_servers_loop(selector, server_timeout, address)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/felipe/Library/Python/3.11/lib/python/site-packages/pymongo/topology.py", line 238, in _select_servers_loop
    raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 61] Connection refused, Timeout: 0.001s, Topology Description: <TopologyDescription id: 63eee76a5ce24c47881600d0, topology_type: Single, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 61] Connection refused')>]>

Steps to reproduce the actual/current behavior

Run the command.

Environment

macOS Ventura (latest as of this writing).

> uname -a
Darwin M-HJR99W7WX5 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
Software Version
mtools 1.7.2
Python 3.11
MongoDB server 6.2.0
Operating system macOS Ventura
FGasper commented 1 year ago

Workaround: create the replica set, stop it, tweak the .mlaunch_startup file, then restart the replica set.

UPDATE: Actually, while this doesn’t display an error, it also doesn’t actually start the server.

stennie commented 1 year ago

Hi @FGasper,

Per SERVER-53247: Disable enableMajorityReadConcern:false, this option is no longer supported in MongoDB 5.0 or newer.

Since you are testing with MongoDB 6.2.0, mongod will refuse to start with a log message like:

"msg":"enableMajorityReadConcern:false is no longer supported"

However, this startup error does not seem to be displaying properly in the develop branch of mtools, so the failure reason is not obvious (and should be fixed).

Regards, Stennie