Skip to content

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

perf: increase http send and receive timeouts for clickhouse queries for batch exports (#10996)

Steffen Schmitz15a21207feb3
diff --git a/packages/shared/src/server/repositories/clickhouse.ts b/packages/shared/src/server/repositories/clickhouse.ts
index e948bbbdb6..16c84149b1 100644
--- a/packages/shared/src/server/repositories/clickhouse.ts
+++ b/packages/shared/src/server/repositories/clickhouse.ts
@@ -310,6 +310,10 @@ function handleExceptionRow<T>(parsedRow: T): T {
) {
const potentialException = (parsedRow as { exception: string }).exception;
if (potentialException.match(/^Code: (\d+)/)) {
+ logger.error(
+ `[clickhouse] Exception row detected: ${potentialException}`,
+ parsedRow,
+ );
throw new Error(potentialException);
}
}
diff --git a/worker/src/features/database-read-stream/getDatabaseReadStream.ts b/worker/src/features/database-read-stream/getDatabaseReadStream.ts
index 0b4a9b896b..329b8f4cf1 100644
--- a/worker/src/features/database-read-stream/getDatabaseReadStream.ts
+++ b/worker/src/features/database-read-stream/getDatabaseReadStream.ts
@@ -121,6 +121,12 @@ export const getDatabaseReadStreamPaginated = async ({
const clickhouseConfigs = {
request_timeout: 180_000,
+ clickhouse_settings: {
+ // Increase HTTP timeouts to prevent Code 209 errors during slow blob storage uploads
+ // See: https://github.com/ClickHouse/ClickHouse/issues/64731
+ http_send_timeout: 300,
+ http_receive_timeout: 300,
+ },
};
switch (tableName) {
@@ -384,9 +390,7 @@ export const getDatabaseReadStreamPaginated = async ({
(min, t) => (!min || t.timestamp < min ? t.timestamp : min),
undefined as Date | undefined,
),
- {
- request_timeout: 180_000,
- },
+ clickhouseConfigs,
),
]);
@@ -699,6 +703,12 @@ export const getTraceIdentifierStream = async (props: {
const clickhouseConfigs = {
request_timeout: 180_000,
+ clickhouse_settings: {
+ // Increase HTTP timeouts to prevent Code 209 errors during slow blob storage uploads
+ // See: https://github.com/ClickHouse/ClickHouse/issues/64731
+ http_send_timeout: 300,
+ http_receive_timeout: 300,
+ },
};
return new DatabaseReadStream<TraceIdentifiers>(
diff --git a/worker/src/features/database-read-stream/observation-stream.ts b/worker/src/features/database-read-stream/observation-stream.ts
index bc62d3c160..8dba48f66f 100644
--- a/worker/src/features/database-read-stream/observation-stream.ts
+++ b/worker/src/features/database-read-stream/observation-stream.ts
@@ -97,6 +97,10 @@ export const getObservationStream = async (props: {
request_timeout: 180_000, // 3 minutes
clickhouse_settings: {
join_algorithm: "partial_merge" as const,
+ // Increase HTTP timeouts to prevent Code 209 errors during slow blob storage uploads
+ // See: https://github.com/ClickHouse/ClickHouse/issues/64731
+ http_send_timeout: 300,
+ http_receive_timeout: 300,
},
};
diff --git a/worker/src/features/database-read-stream/trace-stream.ts b/worker/src/features/database-read-stream/trace-stream.ts
index d937cff730..860e7f9e0b 100644
--- a/worker/src/features/database-read-stream/trace-stream.ts
+++ b/worker/src/features/database-read-stream/trace-stream.ts
@@ -46,6 +46,10 @@ export const getTraceStream = async (props: {
request_timeout: 180_000,
clickhouse_settings: {
join_algorithm: "partial_merge" as const,
+ // Increase HTTP timeouts to prevent Code 209 errors during slow blob storage uploads
+ // See: https://github.com/ClickHouse/ClickHouse/issues/64731
+ http_send_timeout: 300,
+ http_receive_timeout: 300,
},
};