Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore: retiring mutation monitor (#11837)

Valery Meleshkin5db7c7ef36a3
diff --git a/worker/src/__tests__/mutationMonitor.test.ts b/worker/src/__tests__/mutationMonitor.test.ts
deleted file mode 100644
index 0272c8ca1e..0000000000
--- a/worker/src/__tests__/mutationMonitor.test.ts
+++ /dev/null
@@ -1,382 +0,0 @@
-import { expect, describe, it, beforeEach, vi, afterEach } from "vitest";
-import { MutationMonitor } from "../features/mutation-monitoring/mutationMonitor";
-import { WorkerManager } from "../queues/workerManager";
-import * as shared from "@langfuse/shared/src/server";
-import { Worker } from "bullmq";
-
-// Mock the dependencies
-vi.mock("@langfuse/shared/src/server", async () => {
- const actual = await vi.importActual("@langfuse/shared/src/server");
- return {
- ...actual,
- queryClickhouse: vi.fn(),
- logger: {
- info: vi.fn(),
- debug: vi.fn(),
- warn: vi.fn(),
- error: vi.fn(),
- },
- QueueName: {
- TraceDelete: "trace-delete",
- ScoreDelete: "score-delete",
- DatasetDelete: "dataset-delete",
- ProjectDelete: "project-delete",
- DataRetentionProcessingQueue: "data-retention-processing-queue",
- },
- };
-});
-
-vi.mock("../queues/workerManager");
-vi.mock("../env", () => ({
- env: {
- LANGFUSE_MUTATION_MONITOR_ENABLED: "true",
- LANGFUSE_MUTATION_MONITOR_CHECK_INTERVAL_MS: 1000,
- LANGFUSE_DELETION_MUTATIONS_MAX_COUNT: 40,
- LANGFUSE_DELETION_MUTATIONS_SAFE_COUNT: 15,
- CLICKHOUSE_DB: "default",
- },
-}));
-
-describe("MutationMonitor", () => {
- // Test data
- const queueTableMapping = {
- "trace-delete": ["traces", "observations", "scores"],
- "score-delete": ["scores"],
- "dataset-delete": ["dataset_run_items_rmt"],
- "project-delete": [
- "traces",
- "observations",
- "scores",
- "dataset_run_items_rmt",
- ],
- "data-retention-processing-queue": ["traces", "observations", "scores"],
- };
-
- describe("makeDecisions tests", () => {
- it("should decide to pause queues when scores exceeds MAX", () => {
- const counts = new Map([
- ["traces", 10],
- ["observations", 10],
- ["scores", 50],
- ]);
-
- const decisions = MutationMonitor.makeDecisions(
- counts,
- queueTableMapping,
- 40, // MAX
- 15, // SAFE
- );
-
- // Pause decisions for queues affecting scores
- const pauseDecisions = decisions.filter((d) => d.action === "pause");
- expect(pauseDecisions).toHaveLength(4);
- expect(pauseDecisions.map((d) => d.queueName)).toContain("trace-delete");
- expect(pauseDecisions.map((d) => d.queueName)).toContain("score-delete");
- expect(pauseDecisions.map((d) => d.queueName)).toContain(
- "project-delete",
- );
- expect(pauseDecisions.map((d) => d.queueName)).toContain(
- "data-retention-processing-queue",
- );
-
- // Also resume decision for DatasetDelete (its table is safe)
- const resumeDecisions = decisions.filter((d) => d.action === "resume");
- expect(resumeDecisions.map((d) => d.queueName)).toContain(
- "dataset-delete",
- );
- });
-
- it("should decide to resume all queues when all tables are below SAFE", () => {
- const counts = new Map([
- ["traces", 10],
- ["observations", 12],
- ["scores", 14], // All < 15
- ["dataset_run_items_rmt", 5],
- ]);
-
- const decisions = MutationMonitor.makeDecisions(
- counts,
- queueTableMapping,
- 40,
- 15,
- );
-
- // All queues should have resume decisions (all tables safe)
- expect(decisions.every((d) => d.action === "resume")).toBe(true);
- expect(decisions).toHaveLength(5);
- expect(decisions.map((d) => d.queueName)).toContain("trace-delete");
- expect(decisions.map((d) => d.queueName)).toContain("score-delete");
- expect(decisions.map((d) => d.queueName)).toContain("dataset-delete");
- expect(decisions.map((d) => d.queueName)).toContain("project-delete");
- expect(decisions.map((d) => d.queueName)).toContain(
- "data-retention-processing-queue",
- );
- });
-
- it("should NOT decide to resume queues if ANY of their tables is >= SAFE", () => {
- const counts = new Map([
- ["traces", 10],
- ["observations", 12],
- ["scores", 15], // At SAFE threshold
- ["dataset_run_items_rmt", 5],
- ]);
-
- const decisions = MutationMonitor.makeDecisions(
- counts,
- queueTableMapping,
- 40,
- 15,
- );
-
- // Only DatasetDelete should have resume (doesn't depend on scores)
- const resumeDecisions = decisions.filter((d) => d.action === "resume");
- expect(resumeDecisions).toHaveLength(1);
- expect(resumeDecisions[0].queueName).toBe("dataset-delete");
-
- // Queues depending on scores should NOT have resume decisions
- expect(resumeDecisions.map((d) => d.queueName)).not.toContain(
- "trace-delete",
- );
- expect(resumeDecisions.map((d) => d.queueName)).not.toContain(
- "score-delete",
- );
- });
-
- it("should handle multiple tables over threshold", () => {
- const counts = new Map([
- ["traces", 50],
- ["scores", 45],
- ["observations", 10],
- ["dataset_run_items_rmt", 5],
- ]);
-
- const decisions = MutationMonitor.makeDecisions(
- counts,
- queueTableMapping,
- 40,
- 15,
- );
-
- // Pause decisions for queues affecting traces/scores
- const pauseDecisions = decisions.filter((d) => d.action === "pause");
- expect(pauseDecisions.map((d) => d.queueName)).toContain("trace-delete");
- expect(pauseDecisions.map((d) => d.queueName)).toContain("score-delete");
- expect(pauseDecisions.map((d) => d.queueName)).toContain(
- "project-delete",
- );
- expect(pauseDecisions.map((d) => d.queueName)).toContain(
- "data-retention-processing-queue",
- );
-
- // Resume decision for DatasetDelete (its table is safe)
- const resumeDecisions = decisions.filter((d) => d.action === "resume");
- expect(resumeDecisions.map((d) => d.queueName)).toContain(
- "dataset-delete",
- );
- });
-
- it("should decide to resume ScoreDelete independently", () => {
- const counts = new Map([
- ["traces", 20], // In hysteresis zone (between SAFE and MAX)
- ["observations", 10],
- ["scores", 10], // Below SAFE
- ["dataset_run_items_rmt", 5],
- ]);
-
- const decisions = MutationMonitor.makeDecisions(
- counts,
- queueTableMapping,
- 40,
- 15,
- );
-
- // ScoreDelete and DatasetDelete should resume (their tables are safe)
- const resumeDecisions = decisions.filter((d) => d.action === "resume");
- expect(resumeDecisions).toHaveLength(2);
- expect(resumeDecisions.map((d) => d.queueName)).toContain("score-delete");
- expect(resumeDecisions.map((d) => d.queueName)).toContain(
- "dataset-delete",
- );
-
- // TraceDelete should NOT resume (traces=20 >= SAFE=15)
- expect(resumeDecisions.map((d) => d.queueName)).not.toContain(
- "trace-delete",
- );
- });
-
- it("should handle DatasetDelete independently", () => {
- const counts = new Map([
- ["traces", 10],
- ["observations", 10],
- ["scores", 10],
- ["dataset_run_items_rmt", 50],
- ]);
-
- const decisions = MutationMonitor.makeDecisions(
- counts,
- queueTableMapping,
- 40,
- 15,
- );
-
- // Pause decisions for queues affecting dataset_run_items_rmt
- const pauseDecisions = decisions.filter((d) => d.action === "pause");
- expect(pauseDecisions).toHaveLength(2);
- expect(pauseDecisions.map((d) => d.queueName)).toContain(
- "dataset-delete",
- );
- expect(pauseDecisions.map((d) => d.queueName)).toContain(
- "project-delete",
- );
-
- // Resume decisions for queues only affecting traces/observations/scores
- const resumeDecisions = decisions.filter((d) => d.action === "resume");
- expect(resumeDecisions.map((d) => d.queueName)).toContain("trace-delete");
- expect(resumeDecisions.map((d) => d.queueName)).toContain("score-delete");
- expect(resumeDecisions.map((d) => d.queueName)).toContain(
- "data-retention-processing-queue",
- );
- });
-
- it("should handle empty mutation counts", () => {
- const counts = new Map([
- ["traces", 0],
- ["observations", 0],
- ["scores", 0],
- ["dataset_run_items_rmt", 0],
- ]);
-
- const decisions = MutationMonitor.makeDecisions(
- counts,
- queueTableMapping,
- 40,
- 15,
- );
-
- // All queues should have resume decisions (all tables safe)
- expect(decisions.every((d) => d.action === "resume")).toBe(true);
- expect(decisions).toHaveLength(5);
- });
-
- it("should handle missing tables in mutation counts", () => {
- const counts = new Map([
- ["traces", 50],
- // observations and scores missing (treated as 0)
- ]);
-
- const decisions = MutationMonitor.makeDecisions(
- counts,
- queueTableMapping,
- 40,
- 15,
- );
-
- // Pause decisions for queues affecting traces
- const pauseDecisions = decisions.filter((d) => d.action === "pause");
- expect(pauseDecisions.map((d) => d.queueName)).toContain("trace-delete");
- expect(pauseDecisions.map((d) => d.queueName)).toContain(
- "project-delete",
- );
- expect(pauseDecisions.map((d) => d.queueName)).toContain(
- "data-retention-processing-queue",
- );
-
- // Resume decisions for queues not affecting traces
- const resumeDecisions = decisions.filter((d) => d.action === "resume");
- expect(resumeDecisions.map((d) => d.queueName)).toContain("score-delete");
- expect(resumeDecisions.map((d) => d.queueName)).toContain(
- "dataset-delete",
- );
- });
- });
-
- describe("integration tests", () => {
- let mockWorkers: Map<string, Partial<Worker>>;
- let queryClickhouseMock: ReturnType<typeof vi.fn>;
-
- beforeEach(() => {
- MutationMonitor.resetState();
- MutationMonitor.stop();
-
- mockWorkers = new Map();
- const queueNames = [
- "trace-delete",
- "score-delete",
- "dataset-delete",
- "project-delete",
- "data-retention-processing-queue",
- ];
-
- queueNames.forEach((queueName) => {
- mockWorkers.set(queueName, {
- pause: vi.fn().mockResolvedValue(undefined),
- resume: vi.fn().mockResolvedValue(undefined),
- });
- });
-
- queryClickhouseMock = vi.mocked(shared.queryClickhouse);
- vi.mocked(WorkerManager.getWorker).mockImplementation(
- (queueName: string) => mockWorkers.get(queueName) as Worker,
- );
- });
-
- afterEach(() => {
- MutationMonitor.stop();
- vi.clearAllMocks();
- });
-
- it("should execute pause decisions from ClickHouse data", async () => {
- queryClickhouseMock.mockResolvedValueOnce([
- { database: "default", table: "traces", mutation_count: 50 },
- { database: "default", table: "observations", mutation_count: 10 },
- { database: "default", table: "scores", mutation_count: 5 },
- ]);
-
- MutationMonitor.start();
- await new Promise((resolve) => setTimeout(resolve, 100));
-
- // TraceDelete should be paused
- expect(mockWorkers.get("trace-delete")?.pause).toHaveBeenCalled();
- expect(
- mockWorkers.get("data-retention-processing-queue")?.pause,
- ).toHaveBeenCalled();
- });
-
- it("should execute resume decisions", async () => {
- // First pause
- queryClickhouseMock.mockResolvedValueOnce([
- { database: "default", table: "traces", mutation_count: 50 },
- ]);
-
- MutationMonitor.start();
- await new Promise((resolve) => setTimeout(resolve, 100));
-
- expect(mockWorkers.get("trace-delete")?.pause).toHaveBeenCalled();
- vi.clearAllMocks();
-
- // Then drop below SAFE
- queryClickhouseMock.mockResolvedValueOnce([
- { database: "default", table: "traces", mutation_count: 10 },
- { database: "default", table: "observations", mutation_count: 10 },
- { database: "default", table: "scores", mutation_count: 10 },
- ]);
-
- await new Promise((resolve) => setTimeout(resolve, 1100));
-
- // Should resume
- expect(mockWorkers.get("trace-delete")?.resume).toHaveBeenCalled();
- });
-
- it("should handle ClickHouse errors gracefully", async () => {
- queryClickhouseMock.mockRejectedValueOnce(new Error("ClickHouse error"));
-
- MutationMonitor.start();
- await new Promise((resolve) => setTimeout(resolve, 100));
-
- expect(shared.logger.error).toHaveBeenCalledWith(
- "Error checking ClickHouse mutations",
- expect.any(Error),
- );
- });
- });
-});
diff --git a/worker/src/app.ts b/worker/src/app.ts
index 0d93f7d4c1..8f7241137d 100644
--- a/worker/src/app.ts
+++ b/worker/src/app.ts
@@ -73,7 +73,6 @@ import { datasetDeleteProcessor } from "./queues/datasetDelete";
import { otelIngestionQueueProcessor } from "./queues/otelIngestionQueue";
import { eventPropagationProcessor } from "./queues/eventPropagationQueue";
import { notificationQueueProcessor } from "./queues/notificationQueue";
-import { MutationMonitor } from "./features/mutation-monitoring/mutationMonitor";
import {
BatchProjectCleaner,
BATCH_DELETION_TABLES,
@@ -557,11 +556,6 @@ if (env.QUEUE_CONSUMER_NOTIFICATION_QUEUE_IS_ENABLED === "true") {
);
}
-if (env.LANGFUSE_MUTATION_MONITOR_ENABLED === "true") {
- // Start the ClickHouse mutation monitor after all workers are registered
- MutationMonitor.start();
-}
-
// Batch project cleaners for bulk deletion of ClickHouse data
export const batchProjectCleaners: BatchProjectCleaner[] = [];
diff --git a/worker/src/env.ts b/worker/src/env.ts
index 937f924660..40a66775c5 100644
--- a/worker/src/env.ts
+++ b/worker/src/env.ts
@@ -306,21 +306,6 @@ const EnvSchema = z.object({
.positive()
.default(120_000), // 2 minutes
- // ClickHouse mutation monitoring
- LANGFUSE_MUTATION_MONITOR_ENABLED: z.enum(["true", "false"]).default("false"),
- LANGFUSE_MUTATION_MONITOR_CHECK_INTERVAL_MS: z.coerce
- .number()
- .positive()
- .default(60_000), // 1 minute
- LANGFUSE_DELETION_MUTATIONS_MAX_COUNT: z.coerce
- .number()
- .positive()
- .default(25),
- LANGFUSE_DELETION_MUTATIONS_SAFE_COUNT: z.coerce
- .number()
- .positive()
- .default(1),
-
// Batch Project Cleaner configuration
LANGFUSE_BATCH_PROJECT_CLEANER_ENABLED: z
.enum(["true", "false"])
diff --git a/worker/src/features/mutation-monitoring/mutationMonitor.ts b/worker/src/features/mutation-monitoring/mutationMonitor.ts
deleted file mode 100644
index bd94823321..0000000000
--- a/worker/src/features/mutation-monitoring/mutationMonitor.ts
+++ /dev/null
@@ -1,333 +0,0 @@
-import {
- logger,
- queryClickhouse,
- QueueName,
-} from "@langfuse/shared/src/server";
-import { env } from "../../env";
-import { WorkerManager } from "../../queues/workerManager";
-import { PeriodicRunner } from "../../utils/PeriodicRunner";
-
-interface MutationCount {
- database: string;
- table: string;
- mutation_count: number;
-}
-
-type QueueAction = "pause" | "resume";
-
-interface QueueDecision {
- queueName: QueueName;
- action: QueueAction;
- reason: string;
-}
-
-/**
- * Internal runner class that extends PeriodicRunner and delegates to MutationMonitor
- */
-class MutationMonitorRunner extends PeriodicRunner {
- protected get name(): string {
- return "MutationMonitor";
- }
-
- protected get defaultIntervalMs(): number {
- return env.LANGFUSE_MUTATION_MONITOR_CHECK_INTERVAL_MS;
- }
-
- protected async execute(): Promise<void> {
- await MutationMonitor.checkMutations();
- }
-}
-
-/**
- * MutationMonitor pauses and resumes queue processing
- * based on how ClickHouse mutations progress.
- *
- * Requires correct ClickHouse grants to work:
- * ```
- * GRANT SELECT(database, `table`, is_done) ON system.mutations TO <role>;
- * ```
- * where `role` is the role used by Langfuse to connect to ClickHouse, usually `app`.
- *
- * `QUEUE_TABLE_MAPPING` below shows how mutations on various tables map to queues.
- *
- * - `LANGFUSE_MUTATION_MONITOR_ENABLED` must be set to `true` to enable this feature.
- * - `LANGFUSE_MUTATION_MONITOR_CHECK_INTERVAL_MS` defines how often to check for mutations.
- * - `LANGFUSE_DELETION_MUTATIONS_MAX_COUNT` once any table for a queue exceeds this threshold, that queue is PAUSED.
- * `- LANGFUSE_DELETION_MUTATIONS_SAFE_COUNT` once all tables for a queue are below this threshold, that queue is RESUMED.
- */
-export class MutationMonitor {
- private static runner = new MutationMonitorRunner();
- private static pausedQueues: Set<QueueName> = new Set();
-
- // Mapping of which ClickHouse tables each deletion queue affects
- private static readonly QUEUE_TABLE_MAPPING: Partial<
- Record<QueueName, string[]>
- > = {
- [QueueName.TraceDelete]: ["traces", "observations", "scores", "events"],
- [QueueName.ScoreDelete]: ["scores"],
- [QueueName.DatasetDelete]: ["dataset_run_items_rmt"],
- [QueueName.ProjectDelete]: ["scores", "dataset_run_items_rmt"],
- [QueueName.DataRetentionProcessingQueue]: [
- "traces",
- "observations",
- "scores",
- "events",
- ],
- };
-
- private static readonly TABLES_TO_MONITOR = Array.from(
- new Set(Object.values(this.QUEUE_TABLE_MAPPING).flat()).values(),
- );
-
- /**
- * Start the mutation monitoring service
- */
- public static start(): void {
- if (env.LANGFUSE_MUTATION_MONITOR_ENABLED !== "true") {
- logger.info("Mutation monitor is disabled");
- return;
- }
-
- logger.info("Starting mutation monitor", {
- checkIntervalMs: env.LANGFUSE_MUTATION_MONITOR_CHECK_INTERVAL_MS,
- maxCount: env.LANGFUSE_DELETION_MUTATIONS_MAX_COUNT,
- safeCount: env.LANGFUSE_DELETION_MUTATIONS_SAFE_COUNT,
- });
- this.runner.start();
- }
-
- /**
- * Stop the mutation monitoring service
- */
- public static stop(): void {
- this.runner.stop();
- logger.info("Mutation monitor stopped");
- }
-
- /**
- * Decision function - determines which queues to pause/resume
- */
- public static makeDecisions(
- mutationCounts: Map<string, number>,
- queueTableMapping: Partial<Record<QueueName, string[]>>,
- maxThreshold: number,
- safeThreshold: number,
- ): QueueDecision[] {
- const decisions: QueueDecision[] = [];
- const decisionMap: Map<QueueName, QueueAction> = new Map();
-
- // Find tables over MAX threshold
- const tablesOverMax = Array.from(mutationCounts.entries())
- .filter(([, count]) => count >= maxThreshold)
- .map(([table]) => table);
-
- const tableToQueuesMap: Map<string, QueueName[]> = Object.entries(
- queueTableMapping,
- ).reduce((map, [queue, tables]) => {
- for (const table of tables) {
- if (!map.has(table)) {
- map.set(table, []);
- }
- map.get(table)!.push(queue as QueueName);
- }
- return map;
- }, new Map());
-
- // Decision 1: Pause queues affecting over-threshold tables
- for (const table of tablesOverMax) {
- const affectedQueues = tableToQueuesMap.get(table) || [];
- for (const queue of affectedQueues) {
- if (!decisionMap.has(queue)) {
- decisions.push({
- queueName: queue,
- action: "pause",
- reason: `${table}=${mutationCounts.get(table)}`,
- });
- decisionMap.set(queue, "pause");
- }
- }
- }
-
- // Decision 2: Resume queues where ALL tables are safe
- for (const [queue, tables] of Object.entries(queueTableMapping)) {
- const allSafe = tables.every(
- (table) => (mutationCounts.get(table) ?? 0) < safeThreshold,
- );
-
- if (allSafe) {
- if (!decisionMap.has(queue as QueueName)) {
- decisionMap.set(queue as QueueName, "resume");
- decisions.push({
- queueName: queue as QueueName,
- action: "resume",
- reason: "",
- });
- } else {
- // if there is a contradictory action, we log an error
- logger.error(`Contradictory decisions for ${queue}`);
- }
- }
- }
-
- return decisions;
- }
-
- /**
- * Check ClickHouse mutations and pause/resume workers as needed
- */
- public static async checkMutations(): Promise<void> {
- try {
- const query = `
- SELECT
- database,
- table,
- count() as mutation_count
- FROM system.mutations
- WHERE database = {database: String}
- AND table IN ({tables: Array(String)})
- AND is_done = 0
- GROUP BY database, table
- `;
-
- const results = await queryClickhouse<MutationCount>({
- query,
- params: {
- database: env.CLICKHOUSE_DB,
- tables: this.TABLES_TO_MONITOR,
- },
- });
-
- // Create a map of table -> mutation count
- const mutationCounts = new Map<string, number>();
- for (const table of this.TABLES_TO_MONITOR) {
- mutationCounts.set(table, 0);
- }
- for (const result of results) {
- mutationCounts.set(result.table, result.mutation_count);
- }
-
- logger.debug("Mutation stats", {
- mutationCounts: Object.fromEntries(mutationCounts),
- pausedQueues: Array.from(this.pausedQueues),
- threshold: env.LANGFUSE_DELETION_MUTATIONS_MAX_COUNT,
- });
-
- const decisions = this.makeDecisions(
- mutationCounts,
- this.QUEUE_TABLE_MAPPING,
- env.LANGFUSE_DELETION_MUTATIONS_MAX_COUNT,
- env.LANGFUSE_DELETION_MUTATIONS_SAFE_COUNT,
- );
-
- // Separate decisions by action
- const pauseDecisions = decisions.filter((d) => d.action === "pause");
- const resumeDecisions = decisions.filter((d) => d.action === "resume");
-
- // Execute pause decisions
- if (pauseDecisions.length > 0) {
- const queuesToPause = new Set(pauseDecisions.map((d) => d.queueName));
- const reasons = pauseDecisions.map((d) => d.reason);
- await this.pauseWorkers(queuesToPause, mutationCounts, reasons);
- }
-
- // Execute resume decisions
- if (resumeDecisions.length > 0) {
- const queuesToResume = new Set(resumeDecisions.map((d) => d.queueName));
- await this.resumeWorkers(queuesToResume, mutationCounts);
- }
- } catch (error) {
- logger.error("Error checking ClickHouse mutations", error);
- }
- }
-
- /**
- * Pause workers (pure execution - no decision logic)
- */
- private static async pauseWorkers(
- queuesToPause: Set<QueueName>,
- mutationCounts: Map<string, number>,
- offendingTables: string[],
- ): Promise<void> {
- for (const queueName of queuesToPause) {
- // Skip if already paused (optimization)
- if (this.pausedQueues.has(queueName)) {
- continue;
- }
-
- try {
- const worker = WorkerManager.getWorker(queueName);
- if (!worker) {
- logger.warn(`${queueName} worker not found, cannot pause`);
- continue;
- }
-
- await worker.pause();
- this.pausedQueues.add(queueName);
-
- logger.warn(`Paused ${queueName}`, {
- reason: `tables over threshold: ${offendingTables.join(", ")}`,
- threshold: env.LANGFUSE_DELETION_MUTATIONS_MAX_COUNT,
- mutationCounts: Object.fromEntries(mutationCounts),
- });
- } catch (error) {
- logger.error(`Error pausing ${queueName}`, error);
- }
- }
- }
-
- /**
- * Resume workers (pure execution - no decision logic)
- */
- private static async resumeWorkers(
- queuesToResume: Set<QueueName>,
- mutationCounts: Map<string, number>,
- ): Promise<void> {
- for (const queueName of queuesToResume) {
- // Skip if not paused (optimization)
- if (!this.pausedQueues.has(queueName)) {
- continue;
- }
-
- try {
- const worker = WorkerManager.getWorker(queueName);
- if (!worker) {
- logger.warn(`${queueName} worker not found, cannot resume`);
- continue;
- }
-
- await worker.resume();
- this.pausedQueues.delete(queueName);
-
- logger.info(`Resumed ${queueName}`, {
- reason: "all tables below safe threshold",
- safeThreshold: env.LANGFUSE_DELETION_MUTATIONS_SAFE_COUNT,
- mutationCounts: Object.fromEntries(mutationCounts),
- });
- } catch (error) {
- logger.error(`Error resuming ${queueName}`, error);
- }
- }
- }
-
- /**
- * Get the paused queues (useful for testing)
- */
- public static getPausedQueues(): Set<QueueName> {
- return new Set(this.pausedQueues);
- }
-
- /**
- * Check if a specific queue is paused (useful for testing)
- */
- public static isQueuePaused(queue: QueueName): boolean {
- return this.pausedQueues.has(queue);
- }
-
- /**
- * Reset the state (useful for testing)
- */
- public static resetState(): void {
- this.pausedQueues.clear();
- this.runner.stop();
- }
-}
diff --git a/worker/src/utils/shutdown.ts b/worker/src/utils/shutdown.ts
index 69e3547110..acc5a69cd0 100644
--- a/worker/src/utils/shutdown.ts
+++ b/worker/src/utils/shutdown.ts
@@ -9,7 +9,6 @@ import { getTokenCountWorkerManager } from "../features/tokenisation/async-usage
import { WorkerManager } from "../queues/workerManager";
import { prisma } from "@langfuse/shared/src/db";
import { BackgroundMigrationManager } from "../backgroundMigrations/backgroundMigrationManager";
-import { MutationMonitor } from "../features/mutation-monitoring/mutationMonitor";
import {
batchProjectCleaners,
batchDataRetentionCleaners,
@@ -24,9 +23,6 @@ export const onShutdown: NodeJS.SignalsListener = async (signal) => {
server.close();
logger.info("Server has been closed.");
- // Stop mutation monitor
- MutationMonitor.stop();
-
// Stop batch project cleaners
for (const cleaner of batchProjectCleaners) {
cleaner.stop();