Skip to content

Commit 8baa251

Browse files
authored
Avoid logging missing stale job key as an error (#2383)
Fixes OPS-4574
1 parent 075545c commit 8baa251

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

packages/server/api/src/app/workers/engine-controller.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,21 @@ export const flowEngineWorker: FastifyPluginAsyncTypebox = async (app) => {
235235
versionId: flowVersionId,
236236
id: flowId,
237237
});
238+
238239
if (isNil(flow)) {
239240
await flowQueue.removeRepeatingJob({
240241
flowVersionId,
241242
});
242243
return;
243244
}
245+
244246
await triggerHooks.disable({
245247
projectId: flow.projectId,
246248
flowVersion: flow.version,
247249
simulate: false,
248250
ignoreError: true,
249251
});
252+
250253
return {};
251254
});
252255

packages/server/api/src/app/workers/redis/redis-queue.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
createRedisClient,
33
distributedLock,
4-
exceptionHandler,
54
JobType,
65
logger,
76
QueueName,
@@ -38,7 +37,7 @@ export const redisQueue: QueueManager = {
3837
);
3938
await Promise.all(queues);
4039
await redisMigrations.run();
41-
logger.info('[redisQueueManager#init] Redis queues initialized');
40+
logger.info('Redis queues initialized');
4241

4342
// TODO: Remove after redis cleanup
4443
await expiredFlowRunCleaner();
@@ -81,20 +80,21 @@ export const redisQueue: QueueManager = {
8180
const queue = await ensureQueueExists(QueueName.SCHEDULED);
8281
const client = await queue.client;
8382
const repeatJob = await findRepeatableJobKey(flowVersionId);
83+
8484
if (isNil(repeatJob)) {
8585
const message = `Couldn't find job key for flow version id "${flowVersionId}"`;
86+
8687
logger.warn(message, {
8788
flowVersionId,
8889
});
89-
exceptionHandler.handle(new Error(message));
90+
9091
return;
9192
}
92-
logger.info(
93-
{
94-
flowVersionId,
95-
},
96-
'[redisQueue#removeRepeatingJob] removing the jobs',
97-
);
93+
94+
logger.info('Removing repeating job for flow version', {
95+
flowVersionId,
96+
});
97+
9898
const result = await queue.removeRepeatableByKey(repeatJob);
9999
if (!result) {
100100
throw new ApplicationError({
@@ -104,6 +104,7 @@ export const redisQueue: QueueManager = {
104104
},
105105
});
106106
}
107+
107108
await client.del(repeatingJobKey(flowVersionId));
108109
},
109110
async findJobsOlderThan(timestamp: number): Promise<string[]> {
@@ -129,10 +130,9 @@ async function findRepeatableJobKey(
129130
const client = await queue.client;
130131
const jobKey = await client.get(repeatingJobKey(flowVersionId));
131132
if (isNil(jobKey)) {
132-
logger.warn(
133-
{ flowVersionId },
134-
'Job key not found in redis, trying to find it in the queue',
135-
);
133+
logger.warn('Job key not found in redis, trying to find it in the queue', {
134+
flowVersionId,
135+
});
136136
// TODO: this temporary solution for jobs that doesn't have repeatJobKey in redis, it's also confusing because it search by flowVersionId
137137
const jobs = await queue.getJobs();
138138
const jobKeyInRedis = jobs

packages/server/worker/src/lib/executors/repeating-job-executor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,22 @@ async function executeRepeatingJob({
4949
publishedVersionId: populatedFlow?.publishedVersionId,
5050
},
5151
);
52+
5253
await engineApiService(engineToken).removeStaleFlow({
5354
flowId: populatedFlow?.id,
5455
flowVersionId,
5556
});
57+
5658
return;
5759
}
5860

5961
if (shouldSkipDisabledFlow(data, populatedFlow)) {
6062
logger.info(
63+
'Skipping workflow execution because the workflow is disabled',
6164
{
62-
message: '[FlowQueueConsumer#executeRepeatingJob]',
6365
flowVersionId,
6466
publishedVersionId: populatedFlow?.publishedVersionId,
6567
},
66-
'skipping disabled flow',
6768
);
6869
return;
6970
}

0 commit comments

Comments
 (0)