Question

I have been using Django 1.3 non-rel with django-mongodb_engine 0.4. Mongodb version being used was 1.8.2 and things were working fine. Recently i tried to upgrade to mongodb 2.4.2(latest stable) release and faced the following issue.

Upon syncing the db i get the following exception:

Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line    
438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 
379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 191, 
in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220, 
in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 351,   
in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/commands/syncdb.py", line 90, in handle_noargs
sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
File "/usr/local/lib/python2.7/dist-packages/django_mongodb_engine/creation.py", line 
142, in sql_create_model
self.connection.get_collection(model._meta.db_table, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_mongodb_engine/base.py", line 98, 
in get_collection
collection = self.collection_class(self.database, name, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 108, in 
__init__
self.__create(kwargs)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 119, in 
__create
self.__database.command("create", self.__name, **options)
File "/usr/local/lib/python2.7/dist-packages/pymongo/database.py", line 393, in command
msg, allowable_errors)
File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 144, in 
_check_command_response
raise OperationFailure(msg % details["errmsg"])
pymongo.errors.OperationFailure: command SON([('create', u'auth_permission'), ('max', 
False), ('capped', False), ('size', 0.0)]) failed: exception: create collection invalid   
size spec

The cause of the exception seems to be some kind of incompatibility between mongo 2.X version as compared to the previous mongodb verions(< 1.8).

Is there a way around this capped/uncapped collection creation issue as evident from the error?

Was it helpful?

Solution

Currently the createCollection command validates the size parameter and considers a number that's not greater than 0 as invalid.

As of this 2.3.1 commit the 0 check happens if size passed in is a number. Previously the assert was later and this change was a result of ticket SERVER-7543 - the core issue is in Django and is discussed in depth here: https://github.com/django-nonrel/mongodb-engine/pull/134 with the actual fix here: https://github.com/django-nonrel/mongodb-engine/pull/134/files#L4L134

If you're using a version that includes this fix, I think you would need to raise an issue on Django list.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top