Skip to content

Commit f2b5c2a

Browse files
committed
prevent creating checkpoints for outdated batch waits
1 parent 11066b4 commit f2b5c2a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

apps/webapp/app/v3/services/createCheckpoint.server.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export class CreateCheckpointService extends BaseService {
122122
logger.error("CreateCheckpointService: Checkpoint not for most recent child run", {
123123
attemptId: attempt.id,
124124
runId: attempt.taskRunId,
125+
lastChild: lastChildRun.friendlyId,
126+
checkpointFor: reason.friendlyId,
125127
params,
126128
});
127129

@@ -134,6 +136,33 @@ export class CreateCheckpointService extends BaseService {
134136
break;
135137
}
136138
case "WAIT_FOR_BATCH": {
139+
const lastChildRun = attempt.taskRun.childRuns[0];
140+
141+
if (!lastChildRun) {
142+
logger.warn("CreateCheckpointService: No child runs, creating checkpoint regardless", {
143+
attemptId: attempt.id,
144+
runId: attempt.taskRunId,
145+
params,
146+
});
147+
148+
break;
149+
}
150+
151+
if (!reason.runFriendlyIds.includes(lastChildRun.friendlyId)) {
152+
logger.error("CreateCheckpointService: Checkpoint not for most recent batch", {
153+
attemptId: attempt.id,
154+
runId: attempt.taskRunId,
155+
lastChild: lastChildRun.friendlyId,
156+
checkpointFor: reason.runFriendlyIds,
157+
params,
158+
});
159+
160+
return {
161+
success: false,
162+
keepRunAlive: true,
163+
};
164+
}
165+
137166
break;
138167
}
139168
default: {

0 commit comments

Comments
 (0)