django-nonrel/djangoappengine — Issue #11: Exception on first syncdb with high replication / SQlite dev server
Author: wrwrwr
Created: 2012-01-08 16:05:23+00:00
State: open

```
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
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:

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

and using a specific set and order of INSTALLED_APPS:

```python
'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:

```bash
for i in {1..100}; do rm -r .gaedata; python2.7 manage.py syncdb --noinput; done
```