Skip to content

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

fix: media and batch delete queue config fixes (#11739)

Valery Meleshkinfc41347f398b
diff --git a/worker/src/app.ts b/worker/src/app.ts
index dde2de044e..218df45b23 100644
--- a/worker/src/app.ts
+++ b/worker/src/app.ts
@@ -592,6 +592,13 @@ if (env.LANGFUSE_BATCH_DATA_RETENTION_CLEANER_ENABLED === "true") {
batchDataRetentionCleanerProcessor,
{
concurrency: 1,
+ maxStalledCount: 1000,
+ lockDuration: 60000, // 60 seconds
+ stalledInterval: 120000, // 120 seconds
+ limiter: {
+ max: 1,
+ duration: env.LANGFUSE_BATCH_DATA_RETENTION_CLEANER_INTERVAL_MS, // no more than 1 job at a time globally
+ },
},
);
@@ -630,6 +637,13 @@ if (env.LANGFUSE_BATCH_DATA_RETENTION_CLEANER_ENABLED === "true") {
mediaRetentionCleanerProcessor,
{
concurrency: 1,
+ maxStalledCount: 1000,
+ lockDuration: 60000, // 60 seconds
+ stalledInterval: 120000, // 120 seconds
+ limiter: {
+ max: 1,
+ duration: env.LANGFUSE_MEDIA_RETENTION_CLEANER_INTERVAL_MS, // no more than 1 job at a time globally
+ },
},
);
diff --git a/worker/src/features/media-retention-cleaner/index.ts b/worker/src/features/media-retention-cleaner/index.ts
index 9d7fdc1232..1e99a39249 100644
--- a/worker/src/features/media-retention-cleaner/index.ts
+++ b/worker/src/features/media-retention-cleaner/index.ts
@@ -44,6 +44,12 @@ export class MediaRetentionCleaner {
return;
}
+ // Record gauge for how far past cutoff the oldest expired item is
+ recordGauge(
+ `${METRIC_PREFIX}.seconds_past_cutoff`,
+ Math.max(workload?.secondsPastCutoff ?? 0, 0),
+ );
+
if (!workload) {
logger.info(`${instanceName}: No expired media to clean up`);
return;
@@ -54,14 +60,6 @@ export class MediaRetentionCleaner {
projectId: workload.projectId,
});
- // Record gauge for how far past cutoff the oldest expired item is
- if (workload.secondsPastCutoff !== null) {
- recordGauge(
- `${METRIC_PREFIX}.seconds_past_cutoff`,
- Math.max(workload.secondsPastCutoff, 0),
- );
- }
-
logger.info(`${instanceName}: Processing project`, {
projectId: workload.projectId,
retentionDays: workload.retentionDays,