|
82 | 82 | from sentry.issues.producer import PayloadType, produce_occurrence_to_kafka
|
83 | 83 | from sentry.killswitches import killswitch_matches_context
|
84 | 84 | from sentry.lang.native.utils import STORE_CRASH_REPORTS_ALL, convert_crashreport_count
|
85 |
| -from sentry.locks import locks |
86 | 85 | from sentry.models.activity import Activity
|
87 | 86 | from sentry.models.environment import Environment
|
88 | 87 | from sentry.models.event import EventDict
|
@@ -701,38 +700,23 @@ def _pull_out_data(jobs: Sequence[Job], projects: ProjectsMapping) -> None:
|
701 | 700 |
|
702 | 701 |
|
703 | 702 | def _set_project_platform_if_needed(project: Project, event: Event) -> None:
|
704 |
| - if event.platform not in VALID_PLATFORMS or event.get_tag("sample_event") == "yes": |
| 703 | + if project.platform: |
705 | 704 | return
|
706 | 705 |
|
707 |
| - # Use a lock to prevent race conditions when multiple events are processed |
708 |
| - # concurrently for a project with no initial platform |
709 |
| - cache_key = f"project-platform-cache:{project.id}" |
710 |
| - lock_key = f"project-platform-lock:{project.id}" |
711 |
| - if cache.get(cache_key) is not None: |
| 706 | + if event.platform not in VALID_PLATFORMS or event.get_tag("sample_event") == "yes": |
712 | 707 | return
|
713 | 708 |
|
714 |
| - try: |
715 |
| - with locks.get(lock_key, duration=60, name="project-platform-lock").acquire(): |
716 |
| - if cache.get(cache_key) is not None: |
717 |
| - return |
718 |
| - else: |
719 |
| - cache.set(cache_key, "1", 60 * 5) |
720 |
| - |
721 |
| - if not project.platform: |
722 |
| - updated = Project.objects.filter( |
723 |
| - Q(id=project.id) & (Q(platform__isnull=True) | Q(platform="")) |
724 |
| - ).update(platform=event.platform) |
725 |
| - |
726 |
| - if updated: |
727 |
| - create_system_audit_entry( |
728 |
| - organization=project.organization, |
729 |
| - target_object=project.id, |
730 |
| - event=audit_log.get_event_id("PROJECT_EDIT"), |
731 |
| - data={**project.get_audit_log_data(), "platform": event.platform}, |
732 |
| - ) |
| 709 | + updated = Project.objects.filter( |
| 710 | + Q(id=project.id) & (Q(platform__isnull=True) | Q(platform="")) |
| 711 | + ).update(platform=event.platform) |
733 | 712 |
|
734 |
| - except Exception: |
735 |
| - logger.exception("Failed to infer and set project platform") |
| 713 | + if updated: |
| 714 | + create_system_audit_entry( |
| 715 | + organization=project.organization, |
| 716 | + target_object=project.id, |
| 717 | + event=audit_log.get_event_id("PROJECT_EDIT"), |
| 718 | + data={**project.get_audit_log_data(), "platform": event.platform}, |
| 719 | + ) |
736 | 720 |
|
737 | 721 |
|
738 | 722 | @sentry_sdk.tracing.trace
|
|
0 commit comments