Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export class DequeueSystem {
{
run: {
id: runId,
status: snapshot.runStatus,
status: lockedTaskRun.status,
attemptNumber: lockedTaskRun.attemptNumber,
},
snapshot: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ export class RunAttemptSystem {
id: runId,
},
data: {
status: "RETRYING_AFTER_FAILURE",
machinePreset: retryResult.machine,
},
include: {
Expand Down Expand Up @@ -1136,7 +1135,7 @@ export class RunAttemptSystem {
const prisma = tx ?? this.$.prisma;

return await this.$.runLock.lock("tryNackAndRequeue", [run.id], async () => {
//we nack the message, this allows another work to pick up the run
//we nack the message, this allows another worker to pick up the run
const gotRequeued = await this.$.runQueue.nackMessage({
orgId,
messageId: run.id,
Expand All @@ -1152,8 +1151,22 @@ export class RunAttemptSystem {
return { wasRequeued: false, ...result };
}

const requeuedRun = await prisma.taskRun.update({
where: {
id: run.id,
},
data: {
status: "PENDING",
},
select: {
id: true,
status: true,
attemptNumber: true,
},
});

const newSnapshot = await this.executionSnapshotSystem.createExecutionSnapshot(prisma, {
run: run,
run: requeuedRun,
snapshot: {
executionStatus: "QUEUED",
description: "Requeued the run after a failure",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ describe("RunEngine attempt failures", () => {
});
expect(result.attemptStatus).toBe("RETRY_IMMEDIATELY");
expect(result.snapshot.executionStatus).toBe("EXECUTING");
expect(result.run.status).toBe("RETRYING_AFTER_FAILURE");
expect(result.run.status).toBe("EXECUTING");

//state should be pending
const executionData3 = await engine.getRunExecutionData({ runId: run.id });
assertNonNullable(executionData3);
expect(executionData3.snapshot.executionStatus).toBe("EXECUTING");
//only when the new attempt is created, should the attempt be increased
expect(executionData3.run.attemptNumber).toBe(1);
expect(executionData3.run.status).toBe("RETRYING_AFTER_FAILURE");
expect(executionData3.run.status).toBe("EXECUTING");

//create a second attempt
const attemptResult2 = await engine.startRunAttempt({
Expand Down Expand Up @@ -600,14 +600,14 @@ describe("RunEngine attempt failures", () => {
// The run should be retried with a larger machine
expect(result.attemptStatus).toBe("RETRY_QUEUED");
expect(result.snapshot.executionStatus).toBe("QUEUED");
expect(result.run.status).toBe("RETRYING_AFTER_FAILURE");
expect(result.run.status).toBe("PENDING");

//state should be pending
const executionData = await engine.getRunExecutionData({ runId: run.id });
assertNonNullable(executionData);
expect(executionData.snapshot.executionStatus).toBe("QUEUED");
expect(executionData.run.attemptNumber).toBe(1);
expect(executionData.run.status).toBe("RETRYING_AFTER_FAILURE");
expect(executionData.run.status).toBe("PENDING");

//create a second attempt
const attemptResult2 = await engine.startRunAttempt({
Expand Down Expand Up @@ -761,14 +761,14 @@ describe("RunEngine attempt failures", () => {
// The run should be retried with a larger machine
expect(result.attemptStatus).toBe("RETRY_QUEUED");
expect(result.snapshot.executionStatus).toBe("QUEUED");
expect(result.run.status).toBe("RETRYING_AFTER_FAILURE");
expect(result.run.status).toBe("PENDING");

//state should be queued
const executionData = await engine.getRunExecutionData({ runId: run.id });
assertNonNullable(executionData);
expect(executionData.snapshot.executionStatus).toBe("QUEUED");
expect(executionData.run.attemptNumber).toBe(1);
expect(executionData.run.status).toBe("RETRYING_AFTER_FAILURE");
expect(executionData.run.status).toBe("PENDING");

await engine.runQueue.processMasterQueueForEnvironment(authenticatedEnvironment.id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ describe("RunEngine Waitpoints", () => {
expect(failResult.attemptStatus).toBe("RETRY_IMMEDIATELY");
expect(failResult.snapshot.executionStatus).toBe("EXECUTING");
expect(failResult.run.attemptNumber).toBe(1);
expect(failResult.run.status).toBe("RETRYING_AFTER_FAILURE");
expect(failResult.run.status).toBe("EXECUTING");

const executionData2 = await engine.getRunExecutionData({ runId: run.id });
assertNonNullable(executionData2);
expect(executionData2.snapshot.executionStatus).toBe("EXECUTING");
expect(executionData2.run.attemptNumber).toBe(1);
expect(executionData2.run.status).toBe("RETRYING_AFTER_FAILURE");
expect(executionData2.run.status).toBe("EXECUTING");
expect(executionData2.completedWaitpoints.length).toBe(0);

//check there are no waitpoints blocking the parent run
Expand Down
Loading