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

Sentry Cleanup returns error with --project flag #3293

Open
javidrazack opened this issue Aug 26, 2024 · 2 comments
Open

Sentry Cleanup returns error with --project flag #3293

javidrazack opened this issue Aug 26, 2024 · 2 comments
Assignees

Comments

@javidrazack
Copy link

Self-Hosted Version

24.8.0

CPU Architecture

x86_64

Docker Version

24.0.7

Docker Compose Version

2.27.1

Steps to Reproduce

  1. docker-compose exec worker bash
  2. sentry cleanup --days 30 --project 7
    Tried with org-slug/project-slug as well.
    The command works fine without the project flag.

Expected Result

Run cleanup for specific the project.

Actual Result

`
Removing expired values for LostPasswordHash
Removing expired values for OrganizationMember
Removing expired values for ApiGrant
Removing expired values for ApiToken
Removing expired files associated with ExportedData
Bulk NodeStore deletion not available for project selection
Running bulk query deletes in BULK_QUERY_DELETES
Removing UserReport for days=30 project=7
Removing GroupEmailThread for days=30 project=7
Removing RuleFireHistory for days=30 project=7
Removing NotificationMessage for days=30 project=7
Traceback (most recent call last):
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 91, in inner
return func(self, sql, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/base.py", line 85, in execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedColumn: column "project_id" does not exist
LINE 6: ...024-07-27T09:16:05.517865+00:00'::timestamptz and project_id...
^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/.venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 103, in _execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 77, in inner
raise_the_exception(self.db, e)
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 75, in inner
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 18, in inner
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 93, in inner
raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.traceback)
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 91, in inner
return func(self, sql, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/base.py", line 85, in execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedColumn: UndefinedColumn('column "project_id" does not exist\nLINE 6: ...024-07-27T09:16:05.517865+00:00'::timestamptz and project_id...\n ^\n')
SQL:
delete from sentry_notificationmessage
where id = any(array(
select id
from sentry_notificationmessage
where "date_added" < '2024-07-27T09:16:05.517865+00:00'::timestamptz and project_id = 7

            limit 10000
        ));

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/.venv/bin/sentry", line 4, in
raise SystemExit(main())
^^^^^^
File "/usr/src/sentry/src/sentry/runner/main.py", line 149, in main
func(**kwargs)
File "/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/runner/decorators.py", line 83, in inner
return ctx.invoke(f, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/runner/commands/cleanup.py", line 314, in cleanup
).execute(chunk_size=chunk_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/deletion.py", line 68, in execute
return self._continuous_query(query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/deletion.py", line 74, in _continuous_query
cursor.execute(query)
File "/.venv/lib/python3.11/site-packages/sentry_sdk/utils.py", line 1720, in runner
return sentry_patched_function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/sentry_sdk/integrations/django/init.py", line 651, in execute
result = real_execute(self, sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 100, in _execute
with self.db.wrap_database_errors:
File "/.venv/lib/python3.11/site-packages/django/db/utils.py", line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/.venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 103, in _execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 77, in inner
raise_the_exception(self.db, e)
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 75, in inner
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 18, in inner
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 93, in inner
raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.traceback)
File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 91, in inner
return func(self, sql, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/sentry/src/sentry/db/postgres/base.py", line 85, in execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.ProgrammingError: UndefinedColumn('column "project_id" does not exist\nLINE 6: ...024-07-27T09:16:05.517865+00:00'::timestamptz and project_id...\n ^\n')
SQL:
delete from sentry_notificationmessage
where id = any(array(
select id
from sentry_notificationmessage
where "date_added" < '2024-07-27T09:16:05.517865+00:00'::timestamptz and project_id = 7

            limit 10000
        ));

`

Event ID

No response

@javidrazack
Copy link
Author

Regression of #2243

@hubertdeng123
Copy link
Member

Ugh, thanks for raising. Will look at this when I can

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: No status
Development

No branches or pull requests

3 participants