@@ -116,38 +116,57 @@ def handle_owner_assignment(project, group, event):
116
116
117
117
118
118
@instrumented_task (name = "sentry.tasks.post_process.post_process_group" )
119
- def post_process_group (event , is_new , is_regression , is_new_group_environment , ** kwargs ):
119
+ def post_process_group (
120
+ event , is_new , is_regression , is_new_group_environment , cache_key = None , group_id = None , ** kwargs
121
+ ):
120
122
"""
121
123
Fires post processing hooks for a group.
122
124
"""
123
- set_current_project ( event . project_id )
124
-
125
+ from sentry . eventstore . models import Event
126
+ from sentry . eventstore . processing import event_processing_store
125
127
from sentry .utils import snuba
126
128
from sentry .reprocessing2 import is_reprocessed_event
127
129
128
130
with snuba .options_override ({"consistent" : True }):
129
- if is_reprocessed_event (event .data ):
131
+ # The event parameter will be removed after transitioning to
132
+ # event_processing_store is complete.
133
+ if cache_key and event is None :
134
+ data = event_processing_store .get (cache_key )
135
+ if not data :
136
+ logger .info (
137
+ "post_process.skipped" ,
138
+ extra = {"cache_key" : cache_key , "reason" : "missing_cache" },
139
+ )
140
+ return
141
+ event = Event (
142
+ project_id = data ["project" ], event_id = data ["event_id" ], group_id = group_id , data = data
143
+ )
144
+ elif check_event_already_post_processed (event ):
145
+ if cache_key :
146
+ event_processing_store .delete_by_key (cache_key )
130
147
logger .info (
131
148
"post_process.skipped" ,
132
149
extra = {
133
150
"project_id" : event .project_id ,
134
151
"event_id" : event .event_id ,
135
- "reason" : "reprocessed " ,
152
+ "reason" : "duplicate " ,
136
153
},
137
154
)
138
155
return
139
156
140
- if check_event_already_post_processed (event ):
157
+ if is_reprocessed_event (event . data ):
141
158
logger .info (
142
159
"post_process.skipped" ,
143
160
extra = {
144
161
"project_id" : event .project_id ,
145
162
"event_id" : event .event_id ,
146
- "reason" : "duplicate " ,
163
+ "reason" : "reprocessed " ,
147
164
},
148
165
)
149
166
return
150
167
168
+ set_current_project (event .project_id )
169
+
151
170
# NOTE: we must pass through the full Event object, and not an
152
171
# event_id since the Event object may not actually have been stored
153
172
# in the database due to sampling.
@@ -161,13 +180,13 @@ def post_process_group(event, is_new, is_regression, is_new_group_environment, *
161
180
event .data = EventDict (event .data , skip_renormalization = True )
162
181
163
182
if event .group_id :
164
- # Re-bind Group since we're pickling the whole Event object
165
- # which may contain a stale Project.
183
+ # Re-bind Group since we're reading the Event object
184
+ # from cache, which may contain a stale group and project
166
185
event .group , _ = get_group_with_redirect (event .group_id )
167
186
event .group_id = event .group .id
168
187
169
- # Re-bind Project and Org since we're pickling the whole Event object
170
- # which may contain stale parent models.
188
+ # Re-bind Project and Org since we're reading the Event object
189
+ # from cache which may contain stale parent models.
171
190
event .project = Project .objects .get_from_cache (id = event .project_id )
172
191
event .project ._organization_cache = Organization .objects .get_from_cache (
173
192
id = event .project .organization_id
@@ -232,6 +251,9 @@ def post_process_group(event, is_new, is_regression, is_new_group_environment, *
232
251
event = event ,
233
252
primary_hash = kwargs .get ("primary_hash" ),
234
253
)
254
+ if cache_key :
255
+ with metrics .timer ("tasks.post_process.delete_event_cache" ):
256
+ event_processing_store .delete_by_key (cache_key )
235
257
236
258
237
259
def process_snoozes (group ):
0 commit comments