4

I wanted to reset a database and issued a drop database followed by a create database on a postgresql server accessed through psycopg2 by a django app.

When I do ./manage.py syncdb I get the following error:

(prod)root@ns204612:/home/someproject/prod/django-mingus/mingus# ./manage.py syncdb
Traceback (most recent call last):
  File "./manage.py", line 16, in <module>
    execute_manager(settings)
  File "/home/someproject/prod/lib/python2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager
    utility.execute()
  File "/home/someproject/prod/lib/python2.6/site-packages/django/core/management/__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/someproject/prod/lib/python2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/someproject/prod/lib/python2.6/site-packages/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/home/someproject/prod/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/someproject/prod/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 52, in handle_noargs
    tables = connection.introspection.table_names()
  File "/home/someproject/prod/lib/python2.6/site-packages/django/db/backends/__init__.py", line 491, in table_names
    return self.get_table_list(cursor)
  File "/home/someproject/prod/lib/python2.6/site-packages/django/db/backends/postgresql/introspection.py", line 30, in get_table_list
    AND pg_catalog.pg_table_is_visible(c.oid)""")
  File "/home/someproject/prod/lib/python2.6/site-packages/django/db/backends/util.py", line 19, in execute
    return self.cursor.execute(sql, params)
psycopg2.InternalError: current transaction is aborted, commands ignored until end of transaction block

and in the postgresql log I got the following error:

2010-01-24 01:08:02 CET ERROR:  relation "django_site" does not exist
2010-01-24 01:08:02 CET STATEMENT:  SELECT "django_site"."id", "django_site"."domain", "django_site"."name" FROM "django_site" WHERE "django_site"."id" = 1  ORDER BY "django_site"."domain" ASC
2010-01-24 01:08:02 CET ERROR:  current transaction is aborted, commands ignored until end of transaction block
2010-01-24 01:08:02 CET STATEMENT:  
                    SELECT c.relname
                    FROM pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                    WHERE c.relkind IN ('r', 'v', '')
                        AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
                        AND pg_catalog.pg_table_is_visible(c.oid)
2010-01-24 01:08:02 CET LOG:  could not receive data from client: Connection reset by peer
2010-01-24 01:08:02 CET LOG:  unexpected EOF on client connection

How can I fix that please ?

Milen A. Radev
  • 60,241
  • 22
  • 105
  • 110
user234090
  • 53
  • 1
  • 5
  • Is it a remote or a local server? Have you tried to restart the PostgreSQL server? – Felix Kling Jan 24 '10 at 00:18
  • It's a local server and I tried to restart the PostgreSQL server without result. – user234090 Jan 24 '10 at 22:07
  • 1
    I had a similar problem - it was caused by trying to be smart with __init__.py in my app. In there I imported my forms and tests (so that runserver and django-autotest would pick them up). By wrapping these in an if block that checked argv for the server commands I wanted, it got fixed. – Stuart Axon May 10 '12 at 09:13

5 Answers5

0

Try to reset you database like ./manage.py reset your_app

douglaz
  • 1,306
  • 2
  • 13
  • 17
0

I was having the same issue and tracked it down to the commit at 2979ea3d4541f7b3c51c17e160bc95b468ac999b on django-mingus

If you reset back to commit 2f7eb8de7e2cb1c776e801a40f008048fcbb6d36, the sync should happen fine.

0

The cause of this was an issue in django-request which is used by Django-Mingus. During syncdb Django does some db introspection and a related import raised this exception. If you are to pull the latest bits from either django-request or django-mingus you'll be ok.

montylounge
  • 688
  • 5
  • 5
0

mySQL does not invalidate the current transaction when it encounters an error where postgres throws the error and do not run other query until the current transaction is not aborted. In this case you have to kill the transaction or commit with that transaction id

Praveen
  • 31
  • 1
  • 2
  • 5
  • Hi Praveen, do you have some pointer about transactions in Postgresql ? how to find open transactions, commit or rollback them ? – user234090 Feb 06 '10 at 21:53
0

Look at here http://www.faqs.org/docs/ppbook/x15040.htm

Praveen
  • 31
  • 1
  • 2
  • 5