BeanieODM / beanie

Asynchronous Python ODM for MongoDB
http://beanie-odm.dev/
Apache License 2.0
2.02k stars 213 forks source link

Weird Namespace exception when calling init_beanie #862

Closed DgRosa closed 5 months ago

DgRosa commented 7 months ago

I'm getting a weird pymongo exception that can't really reproduce. I'm using celery to run some tasks periodically and sometimes they raise the following exception:

    await init_beanie(
  File "/usr/local/lib/python3.10/site-packages/beanie/odm/utils/init.py", line 754, in init_beanie
    await Initializer(
  File "/usr/local/lib/python3.10/site-packages/beanie/odm/utils/init.py", line 129, in __await__
    yield from self.init_class(model).__await__()
  File "/usr/local/lib/python3.10/site-packages/beanie/odm/utils/init.py", line 720, in init_class
    await self.init_view(cls)
  File "/usr/local/lib/python3.10/site-packages/beanie/odm/utils/init.py", line 665, in init_view
    await self.database.command(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/pymongo/_csot.py", line 107, in csot_wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pymongo/database.py", line 894, in command
    return self._command(
  File "/usr/local/lib/python3.10/site-packages/pymongo/database.py", line 743, in _command
    return conn.command(
  File "/usr/local/lib/python3.10/site-packages/pymongo/helpers.py", line 322, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pymongo/pool.py", line 968, in command
    return command(
  File "/usr/local/lib/python3.10/site-packages/pymongo/network.py", line 192, in command
    helpers._check_command_response(
  File "/usr/local/lib/python3.10/site-packages/pymongo/helpers.py", line 230, in _check_command_response
    raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: Namespace already exists, full error: {'ok': 0.0, 'errmsg': 'Namespace already exists', 'code': 48, 'codeName': 'NamespaceExists', '$clusterTime': {'clusterTime': Timestamp(1708125670, 2), 'signature': {'hash': b'\xffC\xefbg?y.3\\\x89$\\\x95\xea>0\xa5m\x18', 'keyId': 7333269827395518470}}, 'operationTime': Timestamp(1708125670, 2)}

It's kinda rare so hopefully anyone can help me with this.

Thank you for the great work done here 🚀!

roman-right commented 7 months ago

Hi! This looks weird. I'll try to reproduce. Thank you

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 30 days with no activity.

github-actions[bot] commented 5 months ago

This issue was closed because it has been stalled for 14 days with no activity.