开发者

psycopg2.InternalError no matter what I do

I use Django and just dropped and re-created database in order to flush table data. Now when I'm trying to do any db-related task, I get:

./manage.py sql portfolio
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 362, 开发者_Python百科in execute_manager
    utility.execute()
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 286, in handle
    app_output = self.handle_app(app, **options)
  File "/usr/lib/pymodules/python2.6/django/core/management/commands/sql.py", line 10, in handle_app
    return u'\n'.join(sql_create(app, self.style)).encode('utf-8')
  File "/usr/lib/pymodules/python2.6/django/core/management/sql.py", line 28, in sql_create
    tables = connection.introspection.table_names()
  File "/usr/lib/pymodules/python2.6/django/db/backends/__init__.py", line 491, in table_names
    return self.get_table_list(cursor)
  File "/usr/lib/pymodules/python2.6/django/db/backends/postgresql/introspection.py", line 30, in get_table_list
    AND pg_catalog.pg_table_is_visible(c.oid)""")
  File "/usr/lib/pymodules/python2.6/django/db/backends/util.py", line 19, in execute
    return self.cursor.execute(sql, params)
psycopg2.InternalError: BŁĄD:  current transaction is aborted, commands ignored until end of transaction block

As you can see it's just code generation, so there should not be any problem with transaction. What's going on? :-(


That error means that something happened to your Postgres process that caused it to fail in the middle of a transaction but the transaction was never committed or rolled back, so it's stuck.

Basically you need to either issue a rollback command (this can be done from the Django shell, oftentimes), or kill the postgres process.

Note that (depending on your server config) Postgres processes keep running even if Django is not, so you're getting the same error every time because it's probably still stuck in the same process.

If you've done that and it's still doing this every time then it means you're triggering the error in your actual code somewhere and need to go digging.


Check postgres log file, to see the actual query responsible for database error. and try to find which portion of django makes this query.

Also check out https://github.com/django-debug-toolbar/django-debug-toolbar/issues/351 . It says django-debug-toolbar might be responsible for this error. Try disabling it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜