Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongod.start() fails on MongoDB version >= 6.1.0 #97

Open
juho-workfellow opened this issue Nov 23, 2023 · 3 comments
Open

Mongod.start() fails on MongoDB version >= 6.1.0 #97

juho-workfellow opened this issue Nov 23, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@juho-workfellow
Copy link

Describe the bug
Starting MongoDB fails on versions later than 6.1.0 due to removal of ephemeralForTest engine: https://jira.mongodb.org/browse/SERVER-65151

To Reproduce
This works:

from pymongo_inmemory import MongoClient
import os

os.environ["PYMONGOIM__DOWNLOAD_URL"] = "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-6.0.0.zip"

client = MongoClient()  # No need to provide host
db = client['testdb']
collection = db['test-collection']
# etc., etc.
client.close()

This fails:

from pymongo_inmemory import MongoClient
import os

os.environ["PYMONGOIM__DOWNLOAD_URL"] = "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-7.0.3.zip"

client = MongoClient()  # No need to provide host
db = client['testdb']
collection = db['test-collection']
# etc., etc.
client.close()

Changing self.engine to "wiredTiger" here seems to fix the issue: https://github.com/kaizendorks/pymongo_inmemory/blob/master/pymongo_inmemory/mongod.py#L54

Expected behavior
Expected the example code from instructions to run without errors.

Logs

  File "C:\testmongo\minimal.py", line 6, in <module>
    client = MongoClient()  # No need to provide host
  File "C:\testmongo\.venv\lib\site-packages\pymongo_inmemory\_pim.py", line 15, in __init__
    self._mongod.start()
  File "C:\testmongo\.venv\lib\site-packages\pymongo_inmemory\mongod.py", line 144, in start
    while not self.is_healthy:
  File "C:\testmongo\.venv\lib\site-packages\pymongo_inmemory\mongod.py", line 184, in is_healthy
    status = db.command("serverStatus")
  File "C:\testmongo\.venv\lib\site-packages\pymongo\_csot.py", line 107, in csot_wrapper
    return func(self, *args, **kwargs)
  File "C:\testmongo\.venv\lib\site-packages\pymongo\database.py", line 890, in command
    with self.__client._conn_for_reads(read_preference, session) as (
  File "C:\testmongo\.venv\lib\site-packages\pymongo\mongo_client.py", line 1346, in _conn_for_reads
    server = self._select_server(read_preference, session)
  File "C:\testmongo\.venv\lib\site-packages\pymongo\mongo_client.py", line 1303, in _select_server
    server = topology.select_server(server_selector)
  File "C:\testmongo\.venv\lib\site-packages\pymongo\topology.py", line 302, in select_server
    server = self._select_server(selector, server_selection_timeout, address)
  File "C:\testmongo\.venv\lib\site-packages\pymongo\topology.py", line 286, in _select_server
    servers = self.select_servers(selector, server_selection_timeout, address)
  File "C:\testmongo\.venv\lib\site-packages\pymongo\topology.py", line 237, in select_servers
    server_descriptions = self._select_servers_loop(selector, server_timeout, address)
  File "C:\testmongo\.venv\lib\site-packages\pymongo\topology.py", line 259, in _select_servers_loop
    raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: 127.0.0.1:27017: [WinError 10061] No connection could be made because the target machine actively refused it (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 655f3dee8b6bb45d6b5a77e7, topology_type: Unknown, servers: [<ServerDescription ('127.0.0.1', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('127.0.0.1:27017: [WinError 10061] No connection could be made because the target machine actively refused it (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>

Context:

  • OS: Windows 11
  • Version of pymongo_inmemory: 0.4.0
  • Version of mongo you are downloading: 6.1.0, 7.0.3
@juho-workfellow juho-workfellow added the bug Something isn't working label Nov 23, 2023
@ekarademir
Copy link
Collaborator

Hi @juho-workfellow thank you for the report. I am aware of this behaviour. However I didn't have time to investigate further. With this report I'll try to prioritize it. That being said, I don't have a clear answer to why this is happening. Probably I'm missing some start up configuration.

@ekarademir ekarademir self-assigned this Dec 25, 2023
@juho-workfellow
Copy link
Author

I think it's just that pymongo_inmemory tries to use ephemeralForTest engine, which was removed from the latest MongoDB versions.

@Guibod
Copy link

Guibod commented May 30, 2024

In fact you need to overwrite the PYMONGOIM__STORAGE_ENGINE env variable to wiredTiger.

os.environ['PYMONGOIM__STORAGE_ENGINE'] = 'wiredTiger'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants