@@ -1602,7 +1602,7 @@ def _save_aggregate_new(
1602
1602
) -> GroupInfo | None :
1603
1603
project = event .project
1604
1604
1605
- primary_hashes , secondary_hashes , hashes = get_hash_values (project , job , metric_tags )
1605
+ hashes = get_hash_values (project , job , metric_tags )[ 2 ]
1606
1606
1607
1607
# Now that we've used the current and possibly secondary grouping config(s) to calculate the
1608
1608
# hashes, we're free to perform a config update if needed. Future events will use the new
@@ -1615,43 +1615,11 @@ def _save_aggregate_new(
1615
1615
1616
1616
group_creation_kwargs = _get_group_creation_kwargs (job )
1617
1617
1618
- # Because this logic is not complex enough we want to special case the situation where we
1619
- # migrate from a hierarchical hash to a non hierarchical hash. The reason being that
1620
- # there needs to be special logic to not create orphaned hashes in migration cases
1621
- # but it wants a different logic to implement splitting of hierarchical hashes.
1622
- migrate_off_hierarchical = bool (
1623
- secondary_hashes
1624
- and secondary_hashes .hierarchical_hashes
1625
- and not primary_hashes .hierarchical_hashes
1626
- )
1627
-
1628
1618
flat_grouphashes = [
1629
1619
GroupHash .objects .get_or_create (project = project , hash = hash )[0 ] for hash in hashes .hashes
1630
1620
]
1631
1621
1632
- # The root_hierarchical_hash is the least specific hash within the tree, so
1633
- # typically hierarchical_hashes[0], unless a hash `n` has been split in
1634
- # which case `root_hierarchical_hash = hierarchical_hashes[n + 1]`. Chosing
1635
- # this for select_for_update mostly provides sufficient synchronization
1636
- # when groups are created and also relieves contention by locking a more
1637
- # specific hash than `hierarchical_hashes[0]`.
1638
- existing_grouphash , root_hierarchical_hash = find_existing_grouphash_new (flat_grouphashes )
1639
-
1640
- if root_hierarchical_hash is not None :
1641
- root_hierarchical_grouphash = GroupHash .objects .get_or_create (
1642
- project = project , hash = root_hierarchical_hash
1643
- )[0 ]
1644
-
1645
- metadata .update (
1646
- hashes .group_metadata_from_hash (
1647
- existing_grouphash .hash
1648
- if existing_grouphash is not None
1649
- else root_hierarchical_hash
1650
- )
1651
- )
1652
-
1653
- else :
1654
- root_hierarchical_grouphash = None
1622
+ existing_grouphash , _ = find_existing_grouphash_new (flat_grouphashes )
1655
1623
1656
1624
# In principle the group gets the same metadata as the event, so common
1657
1625
# attributes can be defined in eventtypes.
@@ -1686,25 +1654,14 @@ def _save_aggregate_new(
1686
1654
metric_tags ["create_group_transaction.outcome" ] = "no_group"
1687
1655
1688
1656
all_grouphash_ids = [h .id for h in flat_grouphashes ]
1689
- if root_hierarchical_grouphash is not None :
1690
- all_grouphash_ids .append (root_hierarchical_grouphash .id )
1691
1657
1692
1658
all_grouphashes = list (
1693
1659
GroupHash .objects .filter (id__in = all_grouphash_ids ).select_for_update ()
1694
1660
)
1695
1661
1696
1662
flat_grouphashes = [gh for gh in all_grouphashes if gh .hash in hashes .hashes ]
1697
1663
1698
- existing_grouphash , root_hierarchical_hash = find_existing_grouphash_new (
1699
- flat_grouphashes
1700
- )
1701
-
1702
- if root_hierarchical_hash is not None :
1703
- root_hierarchical_grouphash = GroupHash .objects .get_or_create (
1704
- project = project , hash = root_hierarchical_hash
1705
- )[0 ]
1706
- else :
1707
- root_hierarchical_grouphash = None
1664
+ existing_grouphash , _ = find_existing_grouphash_new (flat_grouphashes )
1708
1665
1709
1666
if existing_grouphash is None :
1710
1667
group = _create_group (project , event , ** group_creation_kwargs )
@@ -1721,10 +1678,7 @@ def _save_aggregate_new(
1721
1678
},
1722
1679
)
1723
1680
1724
- if root_hierarchical_grouphash is not None :
1725
- new_hashes = [root_hierarchical_grouphash ]
1726
- else :
1727
- new_hashes = list (flat_grouphashes )
1681
+ new_hashes = list (flat_grouphashes )
1728
1682
1729
1683
GroupHash .objects .filter (id__in = [h .id for h in new_hashes ]).exclude (
1730
1684
state = GroupHash .State .LOCKED_IN_MIGRATION
@@ -1773,22 +1727,7 @@ def _save_aggregate_new(
1773
1727
1774
1728
is_new = False
1775
1729
1776
- # For the migration from hierarchical to non hierarchical we want to associate
1777
- # all group hashes
1778
- if migrate_off_hierarchical :
1779
- new_hashes = [h for h in flat_grouphashes if h .group_id is None ]
1780
- if root_hierarchical_grouphash and root_hierarchical_grouphash .group_id is None :
1781
- new_hashes .append (root_hierarchical_grouphash )
1782
- elif root_hierarchical_grouphash is None :
1783
- # No hierarchical grouping was run, only consider flat hashes
1784
- new_hashes = [h for h in flat_grouphashes if h .group_id is None ]
1785
- elif root_hierarchical_grouphash .group_id is None :
1786
- # The root hash is not assigned to a group.
1787
- # We ran multiple grouping algorithms
1788
- # (see secondary grouping), and the hierarchical hash is new
1789
- new_hashes = [root_hierarchical_grouphash ]
1790
- else :
1791
- new_hashes = []
1730
+ new_hashes = [h for h in flat_grouphashes if h .group_id is None ]
1792
1731
1793
1732
if new_hashes :
1794
1733
# There may still be secondary hashes that we did not use to find an
0 commit comments