@@ -161,14 +161,39 @@ pub(crate) fn delete_invocation(
161
161
"Deleting invocation" ,
162
162
) ;
163
163
164
- // Delete the invocation payload
165
- let invocation_key =
164
+ // Check if the invocation was deleted before the task completes
165
+ let invocation_ctx_key =
166
166
GraphInvocationCtx :: key_from ( & req. namespace , & req. compute_graph , & req. invocation_id ) ;
167
- delete_cf_prefix (
168
- txn,
169
- & IndexifyObjectsColumns :: GraphInvocations . cf_db ( & db) ,
170
- invocation_key. as_bytes ( ) ,
171
- ) ?;
167
+ let invocation_ctx = txn
168
+ . get_cf (
169
+ & IndexifyObjectsColumns :: GraphInvocationCtx . cf_db ( & db) ,
170
+ & invocation_ctx_key,
171
+ )
172
+ . map_err ( |e| anyhow ! ( "failed to get invocation: {}" , e) ) ?;
173
+ let invocation_ctx = match invocation_ctx {
174
+ Some ( v) => JsonEncoder :: decode :: < GraphInvocationCtx > ( & v) ?,
175
+ None => {
176
+ info ! (
177
+ namespace = & req. namespace,
178
+ compute_graph = & req. compute_graph,
179
+ invocation_id = & req. invocation_id,
180
+ "Invocation to delete not found: {}" ,
181
+ & req. invocation_id
182
+ ) ;
183
+ return Ok ( ( ) ) ;
184
+ }
185
+ } ;
186
+
187
+ // Delete the invocation payload
188
+ {
189
+ let invocation_key =
190
+ InvocationPayload :: key_from ( & req. namespace , & req. compute_graph , & req. invocation_id ) ;
191
+
192
+ txn. delete_cf (
193
+ & IndexifyObjectsColumns :: GraphInvocations . cf_db ( & db) ,
194
+ & invocation_key,
195
+ ) ?;
196
+ }
172
197
173
198
let mut tasks_deleted = Vec :: new ( ) ;
174
199
let task_prefix =
@@ -247,26 +272,16 @@ pub(crate) fn delete_invocation(
247
272
}
248
273
249
274
// Delete Graph Invocation Context
250
-
251
275
delete_cf_prefix (
252
276
txn,
253
277
IndexifyObjectsColumns :: GraphInvocationCtx . cf_db ( & db) ,
254
- invocation_key . as_bytes ( ) ,
278
+ invocation_ctx_key . as_bytes ( ) ,
255
279
) ?;
256
280
257
281
// Delete Graph Invocation Context Secondary Index
258
- // Note We don't delete the secondary index here because it's too much work to
259
- // get the invocation id from the secondary index key. We purge all the
260
- // secondary index keys for graphs if they are ever deleted.
261
- //
262
- // TODO: Only delete the secondary index keys for this invocation
263
- delete_cf_prefix (
264
- txn,
282
+ txn. delete_cf (
265
283
IndexifyObjectsColumns :: GraphInvocationCtxSecondaryIndex . cf_db ( & db) ,
266
- & GraphInvocationCtx :: secondary_index_key_prefix_from_compute_graph (
267
- & req. namespace ,
268
- & req. compute_graph ,
269
- ) ,
284
+ & invocation_ctx. secondary_index_key ( ) ,
270
285
) ?;
271
286
272
287
let node_output_prefix =
@@ -580,13 +595,6 @@ pub fn delete_compute_graph(
580
595
delete_invocation ( db. clone ( ) , txn, & req) ?;
581
596
}
582
597
583
- // Delete Graph Invocation Context Secondary Index
584
- delete_cf_prefix (
585
- txn,
586
- IndexifyObjectsColumns :: GraphInvocationCtxSecondaryIndex . cf_db ( & db) ,
587
- & GraphInvocationCtx :: secondary_index_key_prefix_from_compute_graph ( namespace, name) ,
588
- ) ?;
589
-
590
598
for iter in make_prefix_iterator (
591
599
txn,
592
600
& IndexifyObjectsColumns :: ComputeGraphVersions . cf_db ( & db) ,
0 commit comments