Skip to content

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

fix: make redis recently-processed cache cluster-safe (#8915)

Steffen Schmitz8c40cfc97d50
diff --git a/worker/src/queues/ingestionQueue.ts b/worker/src/queues/ingestionQueue.ts
index 239b076e60..1ffaacced4 100644
--- a/worker/src/queues/ingestionQueue.ts
+++ b/worker/src/queues/ingestionQueue.ts
@@ -226,18 +226,28 @@ export const ingestionQueueProcessorBuilder = (
}
// Set "seen" keys in Redis to avoid reprocessing for fast updates.
+ // We use Promise.all internally instead of a redis.pipeline since autoPipelining should handle it correctly
+ // while being redis cluster aware.
if (env.LANGFUSE_ENABLE_REDIS_SEEN_EVENT_CACHE === "true" && redis) {
- const pipeline = redis.pipeline();
- for (const event of eventFiles) {
- const key = event.file.split("/").pop() ?? "";
- pipeline.set(
- `langfuse:ingestion:recently-processed:${job.data.payload.authCheck.scope.projectId}:${job.data.payload.data.type}:${job.data.payload.data.eventBodyId}:${key?.replace(".json", "")}`,
- "1",
- "EX",
- 60 * 5, // 5 minutes
+ try {
+ await Promise.all(
+ eventFiles
+ .map((e) => e.file.split("/").pop() ?? "")
+ .map((key) =>
+ redis!.set(
+ `langfuse:ingestion:recently-processed:${job.data.payload.authCheck.scope.projectId}:${job.data.payload.data.type}:${job.data.payload.data.eventBodyId}:${key.replace(".json", "")}`,
+ "1",
+ "EX",
+ 60 * 5, // 5 minutes
+ ),
+ ),
+ );
+ } catch (e) {
+ logger.warn(
+ `Failed to set recently-processed cache. Continuing processing.`,
+ e,
);
}
- await pipeline.exec();
}
// Perform merge of those events