Skip to content

feat(dynamic-sampling): add per-project volume query#114286

Open
shellmayr wants to merge 16 commits into
masterfrom
simon-hellmayr/feat/ds-per-org-eap-project-volumes
Open

feat(dynamic-sampling): add per-project volume query#114286
shellmayr wants to merge 16 commits into
masterfrom
simon-hellmayr/feat/ds-per-org-eap-project-volumes

Conversation

@shellmayr
Copy link
Copy Markdown
Member

  • Add Query to EAP for per-project span volumes that will serve as the basis for the low-volume project calculations

Closes TET-2276

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 29, 2026

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 29, 2026
@shellmayr shellmayr force-pushed the simon-hellmayr/feat/ds-per-org-eap-project-volumes branch from fd999fa to 3ec582f Compare April 29, 2026 13:00
Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py Outdated
Comment thread src/sentry/dynamic_sampling/per_org/tasks/queries.py Outdated
@shellmayr shellmayr force-pushed the simon-hellmayr/feat/ds-per-org-eap-project-volumes branch 3 times, most recently from 0d92603 to 6be8020 Compare May 6, 2026 12:18
@shellmayr shellmayr force-pushed the simon-hellmayr/feat/ds-per-org-eap-project-volumes branch from 2461de9 to 661c994 Compare May 7, 2026 13:52
shellmayr and others added 8 commits May 7, 2026 15:54
Keep the per-org project volume work on transaction segments so measure-specific EAP query changes can live on a dependent branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
@shellmayr shellmayr marked this pull request as ready for review May 8, 2026 11:51
@shellmayr shellmayr requested review from a team as code owners May 8, 2026 11:51
@shellmayr shellmayr requested a review from constantinius May 8, 2026 11:51
keep = _get_aggregate_int(row, "count_sample()")
project_volumes.append(
ProjectVolume(
project_id=ProjectId(int(row["sentry.dsc.root_project"])),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Calling int() on row["sentry.dsc.root_project"] will raise a TypeError when the value is None, which occurs for spans lacking a DSC header.
Severity: HIGH

Suggested Fix

Add a null check before casting the sentry.dsc.root_project value to an integer. Handle the None case gracefully, for example by assigning a default value or skipping the row, similar to how _get_aggregate_int handles nulls.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/dynamic_sampling/per_org/tasks/queries.py#L146

Potential issue: The code directly accesses `row["sentry.dsc.root_project"]` and
attempts to cast it to an integer using `int()`. However, when processing spans that
lack a Dynamic Sampling Context (DSC) header, which is a realistic scenario with older
SDKs or incomplete trace propagation, the value for `sentry.dsc.root_project` can be
`None`. Attempting to execute `int(None)` will raise a `TypeError`, causing the task to
crash. While other parts of the code handle null values correctly, this specific access
point lacks the necessary null check.

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions
Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on 92154b7 in this run:

tests/sentry/seer/agent/test_tools.py::TestGetTraceWaterfall::test_get_trace_waterfall_short_idlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_projectteam" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)
tests/sentry/seer/agent/test_tools.py::TestGetEventDetails::test_by_event_id_occurrencelog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_groupedmessage" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)
tests/sentry/seer/agent/test_tools.py::TestGetRepositoryDefinition::test_get_repository_definition_github_enterpriselog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_organizationmember" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)
tests/sentry/seer/agent/test_tools.py::TestGetRepositoryDefinition::test_get_repository_definition_inactive_repolog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_organizationmember" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)
tests/snuba/api/endpoints/test_organization_events_stats_ourlogs.py::OrganizationEventsStatsOurlogsEndpointTest::test_top_events_with_no_datalog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_projectteam" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)
tests/snuba/api/endpoints/test_organization_events_trace.py::OrganizationEventsTraceLightEndpointTest::test_direct_parent_with_childrenlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_projectteam" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)
tests/snuba/api/endpoints/test_organization_events_trace.py::OrganizationEventsTraceEndpointTest::test_no_projectslog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_organizationmember" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)
tests/snuba/api/endpoints/test_organization_events_trace.py::OrganizationEventsTraceMetaEndpointTest::test_no_projectslog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_organizationmember" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)
tests/snuba/api/endpoints/test_organization_trace_meta.py::OrganizationEventsTraceMetaEndpointTest::test_with_defaultlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
E   psycopg2.errors.ObjectInUse: cannot TRUNCATE "sentry_groupedmessage" because it has pending trigger events

The above exception was the direct cause of the following exception:
.venv/lib/python3.13/site-packages/django/core/management/commands/flush.py:71: in handle
    connection.ops.execute_sql_flush(sql_list)
.venv/lib/python3.13/site-packages/django/db/backends/base/operations.py:473: in execute_sql_flush
    cursor.execute(sql)
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:122: in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/sentry_sdk/utils.py:1887: in runner
    return original_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:70: in _execute__include_sql_in_error
    return execute(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:58: in _execute__clean_params
    return execute(sql, clean_bad_params(params), many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:133: in __call__
    return execute(*params)
           ^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
.venv/lib/python3.13/site-packages/django/db/backends/utils.py:103: in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/decorators.py:16: in inner
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/db/postgres/base.py:96: in execute
    return self.cursor.execute(sql)
... (21 more lines)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant