File tree Expand file tree Collapse file tree 1 file changed +49
-3
lines changed
apps/webapp/app/v3/services Expand file tree Collapse file tree 1 file changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,16 @@ export class CreateCheckpointService extends BaseService {
3535 friendlyId : params . attemptFriendlyId ,
3636 } ,
3737 include : {
38- taskRun : true ,
38+ taskRun : {
39+ include : {
40+ childRuns : {
41+ orderBy : {
42+ createdAt : "asc" ,
43+ } ,
44+ take : 1 ,
45+ } ,
46+ } ,
47+ } ,
3948 backgroundWorker : {
4049 select : {
4150 id : true ,
@@ -93,6 +102,45 @@ export class CreateCheckpointService extends BaseService {
93102 } ;
94103 }
95104
105+ const { reason } = params ;
106+
107+ switch ( reason . type ) {
108+ case "WAIT_FOR_TASK" : {
109+ const lastChildRun = attempt . taskRun . childRuns [ 0 ] ;
110+
111+ if ( ! lastChildRun ) {
112+ logger . warn ( "CreateCheckpointService: No child runs, creating checkpoint regardless" , {
113+ attemptId : attempt . id ,
114+ runId : attempt . taskRunId ,
115+ params,
116+ } ) ;
117+
118+ break ;
119+ }
120+
121+ if ( lastChildRun . friendlyId !== reason . friendlyId ) {
122+ logger . error ( "CreateCheckpointService: Checkpoint not for most recent child run" , {
123+ attemptId : attempt . id ,
124+ runId : attempt . taskRunId ,
125+ params,
126+ } ) ;
127+
128+ return {
129+ success : false ,
130+ keepRunAlive : true ,
131+ } ;
132+ }
133+
134+ break ;
135+ }
136+ case "WAIT_FOR_BATCH" : {
137+ break ;
138+ }
139+ default : {
140+ break ;
141+ }
142+ }
143+
96144 //sleep to test slow checkpoints
97145 // await new Promise((resolve) => setTimeout(resolve, 60_000));
98146
@@ -128,8 +176,6 @@ export class CreateCheckpointService extends BaseService {
128176 } ,
129177 } ) ;
130178
131- const { reason } = params ;
132-
133179 let checkpointEvent : CheckpointRestoreEvent | undefined ;
134180
135181 switch ( reason . type ) {
You can’t perform that action at this time.
0 commit comments