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

chore(issues): Improve FileIOMainThreadDetector performance #82903

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mrduncan
Copy link
Member

@mrduncan mrduncan commented Jan 3, 2025

FileIOMainThreadDetector is our most time consuming detector: https://sentry.sentry.io/traces/?groupBy=span.description&interval=15m&mode=aggregate&project=1&query=span.op%3Afunction%20span.description%3Arun_detector_on_data.%2A&statsPeriod=24h&visualize=%7B%22chartType%22%3A1%2C%22yAxes%22%3A%5B%22sum%28span.duration%29%22%2C%22count%28span.duration%29%22%2C%22p95%28span.duration%29%22%2C%22p99%28span.duration%29%22%5D%7D

This eliminates the need to recompile these glob patterns potentially for every transaction event and adds a synthetic benchmark to measure the (~4x) improvement:

Before:

$ ./bin/benchmark_detectors
1,000,000 ops
7.005 s
142,758.90 ops/s

After:

$ ./bin/benchmark_detectors
1,000,000 ops
1.806 s
553,602.94 ops/s

FileIOMainThreadDetector is our most time consuming detector:
https://sentry.sentry.io/traces/?groupBy=span.description&interval=15m&mode=aggregate&project=1&query=span.op%3Afunction%20span.description%3Arun_detector_on_data.%2A&statsPeriod=24h&visualize=%7B%22chartType%22%3A1%2C%22yAxes%22%3A%5B%22sum%28span.duration%29%22%5D%7D

This eliminates the need to recompile these glob patterns potentially
for every transaction event and adds a synthetic benchmark to measure
the (~4x) improvement:

Before:
```
$ ./bin/benchmark_detectors
1,000,000 ops
7.005 s
142,758.90 ops/s
```

After:
```
$ ./bin/benchmark_detectors
1,000,000 ops
1.806 s
553,602.94 ops/s
```
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 3, 2025
def main():
settings = get_detection_settings()

# 10 events: 1 ignored, 1 matching, and 8 ignored
Copy link
Member Author

Choose a reason for hiding this comment

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

These all came directly from tests/sentry/utils/performance_issues/test_file_io_on_main_thread_detector.py

@@ -117,7 +118,10 @@ class FileIOMainThreadDetector(BaseIOMainThreadDetector):

__slots__ = ("stored_problems",)

IGNORED_LIST = {"*.nib", "*.plist", "*kblayout_iphone.dat"}
IGNORED_LIST = {
re.compile(fnmatch.translate(pattern))
Copy link
Member Author

Choose a reason for hiding this comment

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

sentry.utils.glob.glob_match is documented as "A beefed up version of fnmatch.fnmatch" but would appreciate any insights into ways they might diverge.

@mrduncan mrduncan marked this pull request as ready for review January 3, 2025 22:49
@mrduncan mrduncan requested a review from a team as a code owner January 3, 2025 22:49
@mrduncan mrduncan requested a review from a team January 3, 2025 22:49
Copy link
Member

@wedamija wedamija left a comment

Choose a reason for hiding this comment

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

Nice fix! Since you have the benchmark, it could be worth seeing if compiling into a single regex would be faster, like

"|".join(fnmatch.translate(pattern) for pattern in patterns)

Alternatively, these are just suffix matches on files, so would it be even faster to just do

IGNORED_SUFFIX_LIST = [".nib", ".plist", "kblayout_iphone.dat"]
file_path.endswith(suffix) for suffix in IGNORED_SUFFIX_LIST)
```?

This is ~10-15% faster and more importantly it's a lot simpler to
understand and reason about.

Before (with pre-compiled multiple regexes)
```
$ ./bin/benchmark_detectors
1,000,000 ops
1.782 s
561,138.73 ops/s
```

After
```
$ ./bin/benchmark_detectors
1,000,000 ops
1.556 s
642,830.58 ops/s
```
@mrduncan
Copy link
Member Author

mrduncan commented Jan 6, 2025

Great idea - we're probably reaching the limits of the accuracy of this benchmark but I do like the idea of moving to a suffix check since it's also way simpler to reason about:

Pre-compiled multiple regexes:

$ ./bin/benchmark_detectors
1,000,000 ops
1.782 s
561,138.73 ops/s

Pre-compiled single regex:

$ ./bin/benchmark_detectors
1,000,000 ops
1.649 s
606,374.02 ops/s

File path ends with:

$ ./bin/benchmark_detectors
1,000,000 ops
1.556 s
642,830.58 ops/s

Copy link

codecov bot commented Jan 6, 2025

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
23482 3 23479 234
View the top 3 failed tests by shortest run time
tests.symbolicator.test_minidump_full.SymbolicatorMinidumpIntegrationTest::test_missing_dsym
Stack Traces | 0.333s run time
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "auth_user_username_key"#x1B[0m
#x1B[1m#x1B[31mE   DETAIL:  Key (username)=(admin@localhost) already exists.#x1B[0m

#x1B[33mDuring handling of the above exception, another exception occurred:#x1B[0m
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:105: in _execute
    return self.cursor.execute(sql, params)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:77: in inner
    raise_the_exception(self.db, e)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:75: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:18: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:93: in inner
    raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.__traceback__)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   psycopg2.errors.UniqueViolation: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:  Key (username)=(admin@localhost) already exists.\n')#x1B[0m
#x1B[1m#x1B[31mE   SQL: INSERT INTO "auth_user" ("password", "last_login", "username", "first_name", "email", "is_staff", "is_active", "is_unclaimed", "is_superuser", "is_managed", "is_sentry_app", "is_password_expired", "last_password_change", "flags", "session_nonce", "date_joined", "last_active", "avatar_type", "avatar_url") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING "auth_user"."id"#x1B[0m

#x1B[33mThe above exception was the direct cause of the following exception:#x1B[0m
#x1B[1m#x1B[31mtests/symbolicator/test_minidump_full.py#x1B[0m:37: in initialize
    self.project.update_option("sentry:builtin_symbol_sources", [])
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:86: in project
    name="Bar", slug="bar", teams=[self.team], fire_project_created=True
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.12.6....../x64/lib/python3.12/contextlib.py#x1B[0m:81: in inner
    return func(*args, **kwds)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:76: in team
    team = self.create_team(organization=self.organization, name="foo", slug="foo")
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:71: in organization
    return self.create_organization(name="baz", slug="baz", owner=self.user)
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:65: in user
    return self.create_user("admin@localhost", is_superuser=True, is_staff=True)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:258: in create_user
    return Factories.create_user(*args, **kwargs)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.12.6....../x64/lib/python3.12/contextlib.py#x1B[0m:81: in inner
    return func(*args, **kwds)
#x1B[1m#x1B[.../sentry/testutils/factories.py#x1B[0m:907: in create_user
    user.save()
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[.../users/models/user.py#x1B[0m:225: in save
    result = super().save(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../contrib/auth/base_user.py#x1B[0m:62: in save
    super().save(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:892: in save
    self.save_base(
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:998: in save_base
    updated = self._save_table(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:1161: in _save_table
    results = self._do_insert(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:1202: in _do_insert
    return manager._insert(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/manager.py#x1B[0m:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/query.py#x1B[0m:1847: in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
#x1B[1m#x1B[31m.venv/lib/python3.12.../models/sql/compiler.py#x1B[0m:1836: in execute_sql
    cursor.execute(sql, params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:122: in execute
    return super().execute(sql, params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../site-packages/sentry_sdk/utils.py#x1B[0m:1858: in runner
    return original_function(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:79: in execute
    return self._execute_with_wrappers(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
#x1B[1m#x1B[.../sentry/testutils/hybrid_cloud.py#x1B[0m:133: in __call__
    return execute(*params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:100: in _execute
    with self.db.wrap_database_errors:
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/db/utils.py#x1B[0m:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:105: in _execute
    return self.cursor.execute(sql, params)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:77: in inner
    raise_the_exception(self.db, e)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:75: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:18: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:93: in inner
    raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.__traceback__)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   django.db.utils.IntegrityError: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:  Key (username)=(admin@localhost) already exists.\n')#x1B[0m
#x1B[1m#x1B[31mE   SQL: INSERT INTO "auth_user" ("password", "last_login", "username", "first_name", "email", "is_staff", "is_active", "is_unclaimed", "is_superuser", "is_managed", "is_sentry_app", "is_password_expired", "last_password_change", "flags", "session_nonce", "date_joined", "last_active", "avatar_type", "avatar_url") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING "auth_user"."id"#x1B[0m
tests.symbolicator.test_minidump_full.SymbolicatorMinidumpIntegrationTest::test_reprocessing
Stack Traces | 0.347s run time
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "auth_user_username_key"#x1B[0m
#x1B[1m#x1B[31mE   DETAIL:  Key (username)=(admin@localhost) already exists.#x1B[0m

#x1B[33mDuring handling of the above exception, another exception occurred:#x1B[0m
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:105: in _execute
    return self.cursor.execute(sql, params)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:77: in inner
    raise_the_exception(self.db, e)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:75: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:18: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:93: in inner
    raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.__traceback__)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   psycopg2.errors.UniqueViolation: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:  Key (username)=(admin@localhost) already exists.\n')#x1B[0m
#x1B[1m#x1B[31mE   SQL: INSERT INTO "auth_user" ("password", "last_login", "username", "first_name", "email", "is_staff", "is_active", "is_unclaimed", "is_superuser", "is_managed", "is_sentry_app", "is_password_expired", "last_password_change", "flags", "session_nonce", "date_joined", "last_active", "avatar_type", "avatar_url") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING "auth_user"."id"#x1B[0m

#x1B[33mThe above exception was the direct cause of the following exception:#x1B[0m
#x1B[1m#x1B[31mtests/symbolicator/test_minidump_full.py#x1B[0m:37: in initialize
    self.project.update_option("sentry:builtin_symbol_sources", [])
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:86: in project
    name="Bar", slug="bar", teams=[self.team], fire_project_created=True
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.12.6....../x64/lib/python3.12/contextlib.py#x1B[0m:81: in inner
    return func(*args, **kwds)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:76: in team
    team = self.create_team(organization=self.organization, name="foo", slug="foo")
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:71: in organization
    return self.create_organization(name="baz", slug="baz", owner=self.user)
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:65: in user
    return self.create_user("admin@localhost", is_superuser=True, is_staff=True)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:258: in create_user
    return Factories.create_user(*args, **kwargs)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.12.6....../x64/lib/python3.12/contextlib.py#x1B[0m:81: in inner
    return func(*args, **kwds)
#x1B[1m#x1B[.../sentry/testutils/factories.py#x1B[0m:907: in create_user
    user.save()
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[.../users/models/user.py#x1B[0m:225: in save
    result = super().save(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../contrib/auth/base_user.py#x1B[0m:62: in save
    super().save(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:892: in save
    self.save_base(
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:998: in save_base
    updated = self._save_table(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:1161: in _save_table
    results = self._do_insert(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:1202: in _do_insert
    return manager._insert(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/manager.py#x1B[0m:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/query.py#x1B[0m:1847: in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
#x1B[1m#x1B[31m.venv/lib/python3.12.../models/sql/compiler.py#x1B[0m:1836: in execute_sql
    cursor.execute(sql, params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:122: in execute
    return super().execute(sql, params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../site-packages/sentry_sdk/utils.py#x1B[0m:1858: in runner
    return original_function(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:79: in execute
    return self._execute_with_wrappers(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
#x1B[1m#x1B[.../sentry/testutils/hybrid_cloud.py#x1B[0m:133: in __call__
    return execute(*params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:100: in _execute
    with self.db.wrap_database_errors:
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/db/utils.py#x1B[0m:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:105: in _execute
    return self.cursor.execute(sql, params)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:77: in inner
    raise_the_exception(self.db, e)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:75: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:18: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:93: in inner
    raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.__traceback__)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   django.db.utils.IntegrityError: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:  Key (username)=(admin@localhost) already exists.\n')#x1B[0m
#x1B[1m#x1B[31mE   SQL: INSERT INTO "auth_user" ("password", "last_login", "username", "first_name", "email", "is_staff", "is_active", "is_unclaimed", "is_superuser", "is_managed", "is_sentry_app", "is_password_expired", "last_password_change", "flags", "session_nonce", "date_joined", "last_active", "avatar_type", "avatar_url") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING "auth_user"."id"#x1B[0m
tests.symbolicator.test_minidump_full.SymbolicatorMinidumpIntegrationTest::test_minidump_threadnames
Stack Traces | 13.8s run time
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "auth_user_username_key"#x1B[0m
#x1B[1m#x1B[31mE   DETAIL:  Key (username)=(admin@localhost) already exists.#x1B[0m

#x1B[33mDuring handling of the above exception, another exception occurred:#x1B[0m
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:105: in _execute
    return self.cursor.execute(sql, params)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:77: in inner
    raise_the_exception(self.db, e)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:75: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:18: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:93: in inner
    raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.__traceback__)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   psycopg2.errors.UniqueViolation: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:  Key (username)=(admin@localhost) already exists.\n')#x1B[0m
#x1B[1m#x1B[31mE   SQL: INSERT INTO "auth_user" ("password", "last_login", "username", "first_name", "email", "is_staff", "is_active", "is_unclaimed", "is_superuser", "is_managed", "is_sentry_app", "is_password_expired", "last_password_change", "flags", "session_nonce", "date_joined", "last_active", "avatar_type", "avatar_url") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING "auth_user"."id"#x1B[0m

#x1B[33mThe above exception was the direct cause of the following exception:#x1B[0m
#x1B[1m#x1B[31mtests/symbolicator/test_minidump_full.py#x1B[0m:37: in initialize
    self.project.update_option("sentry:builtin_symbol_sources", [])
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:86: in project
    name="Bar", slug="bar", teams=[self.team], fire_project_created=True
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.12.6....../x64/lib/python3.12/contextlib.py#x1B[0m:81: in inner
    return func(*args, **kwds)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:76: in team
    team = self.create_team(organization=self.organization, name="foo", slug="foo")
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:71: in organization
    return self.create_organization(name="baz", slug="baz", owner=self.user)
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:65: in user
    return self.create_user("admin@localhost", is_superuser=True, is_staff=True)
#x1B[1m#x1B[.../sentry/testutils/fixtures.py#x1B[0m:258: in create_user
    return Factories.create_user(*args, **kwargs)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.12.6....../x64/lib/python3.12/contextlib.py#x1B[0m:81: in inner
    return func(*args, **kwds)
#x1B[1m#x1B[.../sentry/testutils/factories.py#x1B[0m:907: in create_user
    user.save()
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[.../users/models/user.py#x1B[0m:225: in save
    result = super().save(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../contrib/auth/base_user.py#x1B[0m:62: in save
    super().save(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:892: in save
    self.save_base(
#x1B[1m#x1B[.../sentry/silo/base.py#x1B[0m:158: in override
    return original_method(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:998: in save_base
    updated = self._save_table(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:1161: in _save_table
    results = self._do_insert(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/base.py#x1B[0m:1202: in _do_insert
    return manager._insert(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/manager.py#x1B[0m:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/models/query.py#x1B[0m:1847: in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
#x1B[1m#x1B[31m.venv/lib/python3.12.../models/sql/compiler.py#x1B[0m:1836: in execute_sql
    cursor.execute(sql, params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:122: in execute
    return super().execute(sql, params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../site-packages/sentry_sdk/utils.py#x1B[0m:1858: in runner
    return original_function(*args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:79: in execute
    return self._execute_with_wrappers(
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
#x1B[1m#x1B[.../sentry/testutils/hybrid_cloud.py#x1B[0m:133: in __call__
    return execute(*params)
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:100: in _execute
    with self.db.wrap_database_errors:
#x1B[1m#x1B[31m.venv/lib/python3.12.../django/db/utils.py#x1B[0m:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
#x1B[1m#x1B[31m.venv/lib/python3.12.../db/backends/utils.py#x1B[0m:105: in _execute
    return self.cursor.execute(sql, params)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:77: in inner
    raise_the_exception(self.db, e)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:75: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:18: in inner
    return func(self, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:93: in inner
    raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.__traceback__)
#x1B[1m#x1B[.../db/postgres/decorators.py#x1B[0m:91: in inner
    return func(self, sql, *args, **kwargs)
#x1B[1m#x1B[.../db/postgres/base.py#x1B[0m:84: in execute
    return self.cursor.execute(sql, clean_bad_params(params))
#x1B[1m#x1B[31mE   django.db.utils.IntegrityError: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:  Key (username)=(admin@localhost) already exists.\n')#x1B[0m
#x1B[1m#x1B[31mE   SQL: INSERT INTO "auth_user" ("password", "last_login", "username", "first_name", "email", "is_staff", "is_active", "is_unclaimed", "is_superuser", "is_managed", "is_sentry_app", "is_password_expired", "last_password_change", "flags", "session_nonce", "date_joined", "last_active", "avatar_type", "avatar_url") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING "auth_user"."id"#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

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.

2 participants