Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

chore: remove unused dropOnUpdateTrigger call in migration and add cleanup for orphaned job schedulers in queue service

Victor Hugo dos Santos1d1a6a52d19d
diff --git a/backend/src/db/migrations/20260327210655_drop-queue-persistence.ts b/backend/src/db/migrations/20260327210655_drop-queue-persistence.ts
index d929b04016..483f101613 100644
--- a/backend/src/db/migrations/20260327210655_drop-queue-persistence.ts
+++ b/backend/src/db/migrations/20260327210655_drop-queue-persistence.ts
@@ -1,6 +1,6 @@
import { Knex } from "knex";
-import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
+import { createOnUpdateTrigger } from "../utils";
const QUEUE_JOBS_TABLE = "queue_jobs";
@@ -8,7 +8,6 @@ export async function up(knex: Knex): Promise<void> {
const hasTable = await knex.schema.hasTable(QUEUE_JOBS_TABLE);
if (hasTable) {
await knex.schema.dropTable(QUEUE_JOBS_TABLE);
- await dropOnUpdateTrigger(knex, QUEUE_JOBS_TABLE);
}
}
diff --git a/backend/src/queue/queue-service.ts b/backend/src/queue/queue-service.ts
index b265f6fd41..6a1487e467 100644
--- a/backend/src/queue/queue-service.ts
+++ b/backend/src/queue/queue-service.ts
@@ -641,6 +641,22 @@ export const queueServiceFactory = (redisCfg: TRedisConfigKeys): TQueueServiceFa
Record<QueueName, Worker<TQueueJobTypes[QueueName]["payload"], void, TQueueJobTypes[QueueName]["name"]>>
> = {};
+ // Remove orphaned job schedulers left in Redis by the QueueInternalRecovery/QueueInternalReconciliation deleted queues.
+ void (async () => {
+ const staleQueueNames = ["queue-internal-recovery", "queue-internal-reconciliation"];
+ await Promise.allSettled(
+ staleQueueNames.map(async (name) => {
+ const staleQueue = new Queue(name, {
+ prefix: isClusterMode ? `{${name}}` : undefined,
+ connection
+ });
+ await staleQueue.obliterate({ force: true });
+ await staleQueue.close();
+ logger.info({ queue: name }, "Cleaned up orphaned internal queue from Redis");
+ })
+ );
+ })();
+
const start: TQueueServiceFactory["start"] = (name, jobFn, queueSettings) => {
if (queueContainer[name]) {
throw new Error(`${name} queue is already initialized`);