Tuesday, April 1, 2014

Random auth_permission + content_type errors during test runs

I've got a project running Django 1.4, Postgres 3, Python 2.7. Our tests get about halfway through, then we get a sudden flood of errors showing that the django_content_type table may be empty:

......................................................EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Once the errors stop, they continue to the end of the test run. Here's the traceback for all of the errors:


Traceback (most recent call last):

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/test/testcases.py", line 502, in __call__

self._pre_setup()

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/test/testcases.py", line 463, in _pre_setup

self._fixture_setup()

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/test/testcases.py", line 475, in _fixture_setup

call_command('flush', verbosity=0, interactive=False, database=db)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command

return klass.execute(*args, **defaults)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/raven/contrib/django/management/__init__.py", line 37, in new_execute

return original_func(self, *args, **kwargs)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute

output = self.handle(*args, **options)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle

return self.handle_noargs(**options)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/core/management/commands/flush.py", line 77, in handle_noargs

emit_post_sync_signal(set(all_models), verbosity, interactive, db)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal

interactive=interactive, db=db)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send

response = receiver(signal=self, sender=sender, **named)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 54, in create_permissions

auth_app.Permission.objects.bulk_create(objs)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/db/models/manager.py", line 140, in bulk_create

return self.get_query_set().bulk_create(*args, **kwargs)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/db/models/query.py", line 421, in bulk_create

transaction.commit(using=self.db)

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/db/transaction.py", line 153, in commit

connection.commit()

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 234, in commit

self._commit()

File "/home/cbweb/.virtualenvs/coursebook/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 235, in _commit

return self.connection.commit()

IntegrityError: insert or update on table "auth_permission" violates foreign key constraint "content_type_id_refs_id_728de91f"

DETAIL: Key (content_type_id)=(1) is not present in table "django_content_type".


This is pretty bizarre, but it's probably something we're doing. Has anyone ran into something like this before? I can't find anywhere that we're deleting content types (which the error seems to suggest is happening).

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/644c6d98-fa52-4a52-8b36-366aa7cdc2d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment