@@ -288,35 +288,6 @@ export class CompleteAttemptService extends BaseService {
288
288
289
289
return "RETRIED" ;
290
290
} else {
291
- /*
292
- "SYSTEM_FAILURE"
293
- Steps:
294
- 1. marqs ack
295
- 2. Completes the run span OTEL event
296
- 3. Crash all incomplete OTEL events
297
- 4. Updates the run to system failure
298
-
299
- OR
300
-
301
- "COMPLETED_WITH_ERRORS"
302
- Steps:
303
- 1. marqs ack
304
- 2. Completes the run span OTEL event
305
- 3. Updates the run to completed with errors
306
- 4. Enqueues resuming task run dependencies
307
-
308
- Inputs:
309
- - taskRun: id, spanId
310
- - taskRunAttempt: id
311
- - error message
312
- - Prisma client/transaction
313
- */
314
-
315
- // No more retries, we need to fail the task run
316
- logger . debug ( "Completed attempt, ACKing message" , taskRunAttempt ) ;
317
-
318
- await marqs ?. acknowledgeMessage ( taskRunAttempt . taskRunId ) ;
319
-
320
291
// Now we need to "complete" the task run event/span
321
292
await eventRepository . completeEvent ( taskRunAttempt . taskRun . spanId , {
322
293
endTime : new Date ( ) ,
@@ -338,6 +309,14 @@ export class CompleteAttemptService extends BaseService {
338
309
sanitizedError . type === "INTERNAL_ERROR" &&
339
310
sanitizedError . code === "GRACEFUL_EXIT_TIMEOUT"
340
311
) {
312
+ const finalizeService = new FinalizeTaskRunService ( ) ;
313
+ await finalizeService . call ( {
314
+ tx : this . _prisma ,
315
+ id : taskRunAttempt . taskRunId ,
316
+ status : "SYSTEM_FAILURE" ,
317
+ completedAt : new Date ( ) ,
318
+ } ) ;
319
+
341
320
// We need to fail all incomplete spans
342
321
const inProgressEvents = await eventRepository . queryIncompleteEvents ( {
343
322
attemptId : execution . attempt . id ,
@@ -361,25 +340,13 @@ export class CompleteAttemptService extends BaseService {
361
340
} ) ;
362
341
} )
363
342
) ;
364
-
365
- await this . _prisma . taskRun . update ( {
366
- where : {
367
- id : taskRunAttempt . taskRunId ,
368
- } ,
369
- data : {
370
- status : "SYSTEM_FAILURE" ,
371
- completedAt : new Date ( ) ,
372
- } ,
373
- } ) ;
374
343
} else {
375
- await this . _prisma . taskRun . update ( {
376
- where : {
377
- id : taskRunAttempt . taskRunId ,
378
- } ,
379
- data : {
380
- status : "COMPLETED_WITH_ERRORS" ,
381
- completedAt : new Date ( ) ,
382
- } ,
344
+ const finalizeService = new FinalizeTaskRunService ( ) ;
345
+ await finalizeService . call ( {
346
+ tx : this . _prisma ,
347
+ id : taskRunAttempt . taskRunId ,
348
+ status : "COMPLETED_WITH_ERRORS" ,
349
+ completedAt : new Date ( ) ,
383
350
} ) ;
384
351
}
385
352
0 commit comments