fix version locking

This commit is contained in:
nicktrn
2024-05-08 08:36:19 +01:00
parent 93dca36f0c
commit bf79e6b9d3
3 changed files with 16 additions and 2 deletions
@@ -409,6 +409,7 @@ export class DevQueueConsumer {
data: {
lockedAt: new Date(),
lockedById: backgroundTask.id,
lockedToVersionId: backgroundWorker.id,
},
include: {
attempts: {
@@ -260,6 +260,14 @@ export class SharedQueueConsumer {
where: {
id: message.messageId,
},
include: {
lockedToVersion: {
include: {
deployment: true,
tasks: true,
},
},
},
});
if (!existingTaskRun) {
@@ -309,7 +317,12 @@ export class SharedQueueConsumer {
return;
}
const deployment = await findCurrentWorkerDeployment(existingTaskRun.runtimeEnvironmentId);
const deployment = existingTaskRun.lockedToVersion?.deployment
? {
...existingTaskRun.lockedToVersion.deployment,
worker: existingTaskRun.lockedToVersion,
}
: await findCurrentWorkerDeployment(existingTaskRun.runtimeEnvironmentId);
if (!deployment || !deployment.worker) {
logger.error("No matching deployment found for task run", {
@@ -384,6 +397,7 @@ export class SharedQueueConsumer {
data: {
lockedAt: new Date(),
lockedById: backgroundTask.id,
lockedToVersionId: deployment.worker.id,
},
include: {
runtimeEnvironment: true,
@@ -4,7 +4,6 @@ import {
TriggerTaskRequestBody,
packetRequiresOffloading,
} from "@trigger.dev/core/v3";
import { nanoid } from "nanoid";
import { createHash } from "node:crypto";
import { $transaction } from "~/db.server";
import { AuthenticatedEnvironment } from "~/services/apiAuth.server";