🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: remove replica sync and move delay up to 30min for event prop (#12167)
Steffen Schmitz7e36ba79932c
diff --git a/worker/src/env.ts b/worker/src/env.tsindex 3da5a5f605..399967cffc 100644--- a/worker/src/env.ts+++ b/worker/src/env.ts@@ -385,6 +385,11 @@ const EnvSchema = z.object({LANGFUSE_EXPERIMENT_EARLY_EXIT_EVENT_BATCH_JOB: z.enum(["true", "false"]).default("false"),+ LANGFUSE_EXPERIMENT_EVENT_PROPAGATION_PARTITION_DELAY_MINUTES: z.coerce+ .number()+ .positive()+ .int()+ .default(10),LANGFUSE_WEBHOOK_QUEUE_PROCESSING_CONCURRENCY: z.coerce.number()diff --git a/worker/src/features/eventPropagation/handleEventPropagationJob.ts b/worker/src/features/eventPropagation/handleEventPropagationJob.tsindex b9afadae3b..e011068d64 100644--- a/worker/src/features/eventPropagation/handleEventPropagationJob.ts+++ b/worker/src/features/eventPropagation/handleEventPropagationJob.ts@@ -10,7 +10,6 @@ import {recordGauge,} from "@langfuse/shared/src/server";import { Job } from "bullmq";-import { randomUUID } from "crypto";import { env } from "../../env";const LAST_PROCESSED_PARTITION_KEY =@@ -91,14 +90,14 @@ export const handleEventPropagationJob = async (}// Query for the next partition after the last processed one- // Filter for partitions older than 6 minutes and order by partition ASC to get the oldest first+ // Filter for partitions older than LANGFUSE_EXPERIMENT_EVENT_PROPAGATION_PARTITION_DELAY_MINUTES minutes and order by partition ASC to get the oldest firstconst partitions = await queryClickhouse<{ partition: string }>({query: `SELECT DISTINCT partitionFROM system.partsWHERE table = 'observations_batch_staging'AND active = 1- AND toDateTime(partition) < now() - INTERVAL 10 MINUTE+ AND toDateTime(partition) < now() - INTERVAL ${env.LANGFUSE_EXPERIMENT_EVENT_PROPAGATION_PARTITION_DELAY_MINUTES} MINUTE${lastProcessedPartition ? `AND partition > {lastProcessedPartition: String}` : ""}ORDER BY partition ASC`,@@ -132,30 +131,6 @@ export const handleEventPropagationJob = async (// for the same span, this may create duplicates in the new events table. Deduplicating in this query// will significantly affect run-time. This may be an accepted degradation and we test the outcome// to check the likelihood of this happening in practice.-- // Generate a session ID to ensure SYNC REPLICA and INSERT-SELECT- // are routed to the same ClickHouse node (sticky session via session_id).- // This is required per ClickHouse support guidance: SYNC REPLICA fetches- // all missing parts once upfront (unlike select_sequential_consistency=1- // which retries repeatedly), but both commands must hit the same replica.- const sessionId = randomUUID();-- await commandClickhouse({- query: `SYSTEM SYNC REPLICA observations_batch_staging LIGHTWEIGHT`,- session_id: sessionId,- clickhouseConfigs: {- request_timeout: 300000, // 5 minutes timeout- },- tags: {- feature: "ingestion",- operation_name: "syncReplicaObservationsBatchStaging",- },- });-- logger.info(- `[DUAL WRITE] Synced replica for observations_batch_staging before processing partition ${partitionToProcess}`,- );-await commandClickhouse({query: `with batch_stats as (@@ -314,7 +289,6 @@ export const handleEventPropagationJob = async ()WHERE obs._partition_value = tuple('${partitionToProcess}')`,- session_id: sessionId,tags: {feature: "ingestion",partition: partitionToProcess,