Store the graphile job ID on the executions to be able to fast-forward delayed tasks

This commit is contained in:
Eric Allam
2023-06-09 16:56:42 +01:00
parent 12d188d85a
commit 5090b64e57
6 changed files with 1283 additions and 477 deletions
@@ -158,13 +158,22 @@ export class PerformRunExecutionService {
},
});
await workerQueue.enqueue(
const job = await workerQueue.enqueue(
"performRunExecution",
{
id: runExecution.id,
},
{ tx }
);
await tx.jobRunExecution.update({
where: {
id: runExecution.id,
},
data: {
graphileJobId: job.id,
},
});
});
}
}
@@ -347,13 +356,22 @@ export class PerformRunExecutionService {
},
});
await workerQueue.enqueue(
const graphileJob = await workerQueue.enqueue(
"performRunExecution",
{
id: newJobExecution.id,
},
{ tx, runAt: resumeTask.delayUntil ?? undefined }
);
await tx.jobRunExecution.update({
where: {
id: newJobExecution.id,
},
data: {
graphileJobId: graphileJob.id,
},
});
});
}
}
@@ -389,11 +407,20 @@ export class PerformRunExecutionService {
const runAt = new Date(Date.now() + retryDelayInMs);
await workerQueue.enqueue(
const job = await workerQueue.enqueue(
"performRunExecution",
{ id: execution.id },
{ runAt, tx }
);
await tx.jobRunExecution.update({
where: {
id: execution.id,
},
data: {
graphileJobId: job.id,
},
});
});
}
@@ -483,7 +510,7 @@ export class PerformRunExecutionService {
},
});
await workerQueue.enqueue(
const job = await workerQueue.enqueue(
"performRunExecution",
{
id: runExecution.id,
@@ -491,6 +518,15 @@ export class PerformRunExecutionService {
{ tx }
);
await tx.jobRunExecution.update({
where: {
id: runExecution.id,
},
data: {
graphileJobId: job.id,
},
});
break;
}
}
@@ -141,7 +141,7 @@ export class StartRunService {
const execution = await updateRunAndCreateExecution();
await workerQueue.enqueue(
const job = await workerQueue.enqueue(
"performRunExecution",
{
id: execution.id,
@@ -149,6 +149,13 @@ export class StartRunService {
{ tx }
);
await tx.jobRunExecution.update({
where: { id: execution.id },
data: {
graphileJobId: job.id,
},
});
await workerQueue.enqueue(
"startQueuedRuns",
{
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "JobRunExecution" ADD COLUMN "graphileJobId" INTEGER;
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "JobRunExecution" ALTER COLUMN "graphileJobId" SET DATA TYPE TEXT;
+2
View File
@@ -605,6 +605,8 @@ model JobRunExecution {
resumeTask Task? @relation(fields: [resumeTaskId], references: [id], onDelete: Cascade, onUpdate: Cascade)
resumeTaskId String?
graphileJobId String?
}
enum JobRunExecutionReason {
+1229 -472
View File
File diff suppressed because it is too large Load Diff