Skip to content

Prevent v2 batches from being resumed before all items have been created #1614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion apps/webapp/app/v3/services/resumeBatchRun.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,25 @@ export class ResumeBatchRunService extends BaseService {
return "ERROR";
}

if (batchRun.batchVersion === "v2") {
// Make sure batchRun.items.length is equal to or greater than batchRun.runCount
if (batchRun.items.length < batchRun.runCount) {
logger.debug("ResumeBatchRunService: All items aren't yet completed [v2]", {
batchRunId: batchRun.id,
batchRun: {
id: batchRun.id,
status: batchRun.status,
itemsLength: batchRun.items.length,
runCount: batchRun.runCount,
},
});

return "PENDING";
}
}

if (batchRun.items.some((item) => !finishedBatchRunStatuses.includes(item.status))) {
logger.debug("ResumeBatchRunService: All items aren't yet completed", {
logger.debug("ResumeBatchRunService: All items aren't yet completed [v1]", {
batchRunId: batchRun.id,
batchRun: {
id: batchRun.id,
Expand Down
8 changes: 8 additions & 0 deletions references/v3-catalog/src/trigger/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,18 @@ export const batchV2TestTask = task({

for await (const liveRun0 of runs.subscribeToRun(response1.runs[0].id)) {
logger.debug("subscribed to run0", { liveRun0 });

if (liveRun0.finishedAt) {
break;
}
}

for await (const liveRun1 of runs.subscribeToRun(response1.runs[1].id)) {
logger.debug("subscribed to run1", { liveRun1 });

if (liveRun1.finishedAt) {
break;
}
}
});

Expand Down
Loading