Skip to content

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

fix: lightweight updates/deletes interact incorrectly with lazy materialization in 25.10. (#13693)

Valery Meleshkinddb3699e7a57
diff --git a/packages/shared/src/env.ts b/packages/shared/src/env.ts
index f259980ba7..b74f29b883 100644
--- a/packages/shared/src/env.ts
+++ b/packages/shared/src/env.ts
@@ -99,6 +99,12 @@ const EnvSchema = z.object({
CLICKHOUSE_UPDATE_PARALLEL_MODE: z
.enum(["sync", "async", "auto"])
.default("auto"),
+ // Workaround for a 25.12 bug where lightweight updates/deletes interact
+ // incorrectly with lazy materialization. Remove after ClickHouse 26.4, or
+ // earlier if the fix is backported.
+ CLICKHOUSE_DISABLE_LAZY_MATERIALIZATION: z
+ .enum(["true", "false"])
+ .default("false"),
LANGFUSE_INGESTION_QUEUE_DELAY_MS: z.coerce
.number()
diff --git a/packages/shared/src/server/clickhouse/client.ts b/packages/shared/src/server/clickhouse/client.ts
index 8608a4e653..638d749e72 100644
--- a/packages/shared/src/server/clickhouse/client.ts
+++ b/packages/shared/src/server/clickhouse/client.ts
@@ -153,6 +153,12 @@ export class ClickHouseClientManager {
update_parallel_mode: env.CLICKHOUSE_UPDATE_PARALLEL_MODE,
}
: {}),
+ // Workaround for a 25.12 bug where lightweight updates/deletes
+ // interact incorrectly with lazy materialization. Remove after
+ // ClickHouse 26.4, or earlier if the fix is backported.
+ ...(env.CLICKHOUSE_DISABLE_LAZY_MATERIALIZATION === "true"
+ ? { query_plan_optimize_lazy_materialization: 0 }
+ : {}),
...cloudOptions,
...opts.clickhouse_settings,
async_insert: 1,