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

silk_clear_request_log fails on Postgres #290

Closed
devmonkey22 opened this issue Jun 11, 2018 · 9 comments · Fixed by #299
Closed

silk_clear_request_log fails on Postgres #290

devmonkey22 opened this issue Jun 11, 2018 · 9 comments · Fixed by #299

Comments

@devmonkey22
Copy link
Contributor

django-silk==3.0.0

The SQL executed to clear the request logs fail with multiple errors on Postgres 9.5.12.

The errors include:

  • django.db.utils.ProgrammingError: syntax error at or near "'silk_profile'" LINE 1: ALTER TABLE 'silk_profile' DISABLE TRIGGER ALL;
    • Postgres needs unquoted or double quotes, but was given single quotes.
  • django.db.utils.NotSupportedError: cannot truncate a table referenced in a foreign key constraint DETAIL: Table "silk_profile_queries" references "silk_profile". HINT: Truncate table "silk_profile_queries" at the same time, or use TRUNCATE ... CASCADE.

These seem to stem from changes for PR #270.

Traceback (most recent call last):
  File "oc/manage.py", line 18, in <module>
    main()
  File "oc/manage.py", line 15, in main
    execute_from_command_line(sys.argv)
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/silk/management/commands/silk_clear_request_log.py", line 41, in handle
    Command.delete_model(silk.models.Profile)
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/silk/management/commands/silk_clear_request_log.py", line 21, in delete_model
    cursor.execute("ALTER TABLE %s DISABLE TRIGGER ALL;", [table])
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/user/dev/oc/ENV/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: syntax error at or near "'silk_profile'"
LINE 1: ALTER TABLE 'silk_profile' DISABLE TRIGGER ALL;
@arjenfvellinga
Copy link

I'm using 3.0.1 and silk_clear_request_log still fails for me on Postgres with (an other) programming error:

django.db.utils.ProgrammingError: permission denied: "RI_ConstraintTrigger_a_7428263" is a system trigger

@gforcada
Copy link
Contributor

The same happens to me like @arjenfvellinga do we need to change the database user to an admin for clearing data? 🤔

@gforcada
Copy link
Contributor

I manually changed on lines 23 and 25:

cursor.execute("ALTER TABLE {0} DISABLE TRIGGER ALL;".format(table))

cursor.execute("ALTER TABLE {0} ENABLE TRIGGER ALL;".format(table))

the ALL for USER and the command was successful. I will write a pull request for it.

@mOscuro
Copy link

mOscuro commented Oct 22, 2018

Hi! any news about a possible release? I'm getting impacted by this as well. Thanks!

1 similar comment
@mOscuro
Copy link

mOscuro commented Oct 22, 2018

Hi! any news about a possible release? I'm getting impacted by this as well. Thanks!

@betoborda
Copy link

It looks like this error is still happening on the latest version (django-silk 3.0.1 ) from pypi released: Jul 3, 2018. When do you plan to release a new version?

@guy881
Copy link

guy881 commented Mar 11, 2019

We had the same problem and we cleared the data by rolling back migrations of this app python manage.py migrate silk zero.

@davidcorbin
Copy link

davidcorbin commented Apr 2, 2019

Still having the issue referenced by @arjenfvellinga above with Postgres

@guy881 works as a temporary work around but you still have to remigrate after running.

@m-hu
Copy link

m-hu commented Apr 10, 2019

Yes, if a release is planned, that could be wonderful

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

Successfully merging a pull request may close this issue.

8 participants