File tree 1 file changed +49
-3
lines changed
apps/webapp/app/v3/services
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 {
35
35
friendlyId : params . attemptFriendlyId ,
36
36
} ,
37
37
include : {
38
- taskRun : true ,
38
+ taskRun : {
39
+ include : {
40
+ childRuns : {
41
+ orderBy : {
42
+ createdAt : "asc" ,
43
+ } ,
44
+ take : 1 ,
45
+ } ,
46
+ } ,
47
+ } ,
39
48
backgroundWorker : {
40
49
select : {
41
50
id : true ,
@@ -93,6 +102,45 @@ export class CreateCheckpointService extends BaseService {
93
102
} ;
94
103
}
95
104
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
+
96
144
//sleep to test slow checkpoints
97
145
// await new Promise((resolve) => setTimeout(resolve, 60_000));
98
146
@@ -128,8 +176,6 @@ export class CreateCheckpointService extends BaseService {
128
176
} ,
129
177
} ) ;
130
178
131
- const { reason } = params ;
132
-
133
179
let checkpointEvent : CheckpointRestoreEvent | undefined ;
134
180
135
181
switch ( reason . type ) {
You can’t perform that action at this time.
0 commit comments