Closed gsakkis closed 11 months ago
It turns out both issues were user (my) errors:
list_collection_names
does include system.views
, it also includes the view name as well (if it exists). As I was trying out things I was deleting the view and thought that list_collection_names
showed system.views
instead of (rather than in addition to) the view name.drop_indexes
on all models without checking if it's a Document or a View. It's still strange that the error was non deterministic but regardless, drop_indexes
shouldn't be called on views.
I run into two issues when passing a
View
model toinit_beanie
:The result of
list_collection_names
contains "system.views" instead of my view name. This means that the conditionif self.recreate_views or cls._settings.name not in collection_names
is always True and it always attempt to (re)create the view.I am getting an intermittent, non-deterministic exception from PyMongo:
pymongo.errors.OperationFailure: Namespace ... is a view, not a collection
. Apparently this happens in a thread so it doesn't stop the overall execution but it's still worrying. Full traceback: