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

Exception on first syncdb with high replication / SQlite dev server #11

Open
wrwrwr opened this issue Jan 8, 2012 · 3 comments
Open

Comments

@wrwrwr
Copy link
Member

wrwrwr commented Jan 8, 2012

WARNING:root:The rdbms API is not available because the MySQLdb library could not be loaded.
Creating tables ...
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/a/django/testapp/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/a/django/testapp/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/a/django/testapp/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/a/django/testapp/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/a/django/testapp/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/a/django/testapp/django/core/management/commands/syncdb.py", line 109, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/a/django/testapp/django/core/management/sql.py", line 190, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/a/django/testapp/django/dispatch/dispatcher.py", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/a/django/testapp/django/contrib/contenttypes/management.py", line 20, in update_contenttypes
    content_types.remove(ct)
ValueError: list.remove(x): x not in list

Only happens sometimes (nearly always with one particular project), fairly hard to reproduce, feels like a concurrency issue (but disabling threading doesn't help) or something similar to this: https://code.djangoproject.com/ticket/7052. With testapp I get it most often after adding:

DATABASES['default']['DEV_APPSERVER_OPTIONS']
    = { 'high_replication' : True, 'use_sqlite': True, }

and using a specific set and order of INSTALLED_APPS:

'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'djangotoolbox',
'autoload',
'dbindexer',
'djangoappengine',

Note that the order is actually significant -- swapping auth with contenttypes seems to fix the issue... Also note that for testapp frequency of this happening may be low (varies a lot depending on what exactly you have in settings), so to see it you'll likely need something like this:

for i in {1..100}; do rm -r .gaedata; python2.7 manage.py syncdb --noinput; done
@aburgel
Copy link
Member

aburgel commented Jan 8, 2012

whats the value of ct that is not in the list?

does turning off high_replication help? maybe using high replication on the dev server does some eventual consistency emulation.

@wrwrwr
Copy link
Member Author

wrwrwr commented Jan 8, 2012

Removing 'high_replication', 'use_sqlite' or any of the contrib apps does help.

When the exception occurs the 'content_types' list is empty while Django is trying to remove 'site'.

@aburgel
Copy link
Member

aburgel commented Feb 5, 2012

i ran into this issue myself recently. i'm pretty sure its an eventual consistency issue.

i was able to work around it by temporarily changing the consistency policy, but its a bit of a hack. it also requires modifying the command code.

a better solution might be to always run commands with a strong consistency policy and then change to eventual consistency explicitly. like when running tests or the actual app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants