From 251e1d03e2d809cdf62a25e9c603f40ab3223d5f Mon Sep 17 00:00:00 2001 From: slvrtrn Date: Thu, 29 Feb 2024 11:06:13 +0100 Subject: [PATCH] Use 20s instead. --- CHANGELOG.md | 2 +- packages/client-common/src/client.ts | 6 +++--- .../client-node/__tests__/integration/node_client.test.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24d61731..176c6f7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Breaking changes -- Client will enable [send_progress_in_http_headers](https://clickhouse.com/docs/en/operations/settings/settings#send_progress_in_http_headers) and set `http_headers_progress_interval_ms` to `29000` (29 seconds) by default. These settings in combination allow to avoid LB timeout issues in case of long-running queries without data coming in or out, such as `INSERT FROM SELECT` and similar ones, as the connection could be marked as idle by the LB and closed abruptly. Currently, 29s is chosen as a safe value, since most LBs will have at least 30s of idle timeout. It can be overridden when creating a client instance if your LB timeout value is even lower than that by manually changing the `send_progress_in_http_headers` value. +- Client will enable [send_progress_in_http_headers](https://clickhouse.com/docs/en/operations/settings/settings#send_progress_in_http_headers) and set `http_headers_progress_interval_ms` to `20000` (20 seconds) by default. These settings in combination allow to avoid LB timeout issues in case of long-running queries without data coming in or out, such as `INSERT FROM SELECT` and similar ones, as the connection could be marked as idle by the LB and closed abruptly. Currently, 20s is chosen as a safe value, since most LBs will have at least 30s of idle timeout, and, for example, AWS LB sends KeepAlive packets every 20s. It can be overridden when creating a client instance if your LB timeout value is even lower than that by manually changing the `send_progress_in_http_headers` value. NB: these settings will be enabled only if the client instance was created without setting `readonly` flag (see below). diff --git a/packages/client-common/src/client.ts b/packages/client-common/src/client.ts index 4fa13223..3ee6b798 100644 --- a/packages/client-common/src/client.ts +++ b/packages/client-common/src/client.ts @@ -51,16 +51,16 @@ export interface ValuesEncoder { export type CloseStream = (stream: Stream) => Promise /** - * By default, {@link send_progress_in_http_headers} is enabled, and {@link http_headers_progress_interval_ms} is set to 290s. + * By default, {@link send_progress_in_http_headers} is enabled, and {@link http_headers_progress_interval_ms} is set to 20s. * These settings in combination allow to avoid LB timeout issues in case of long-running queries without data coming in or out, * such as `INSERT FROM SELECT` and similar ones, as the connection could be marked as idle by the LB and closed abruptly. - * 290s is chosen as a safe value, since AWS LB timeout is 350s by default and some other LBs might have 300s. + * 20s is chosen as a safe value, since most LBs will have at least 30s of idle timeout, and AWS LB sends KeepAlive packets every 20s. * It can be overridden when creating a client instance if your LB timeout value is even lower than that. * See also: https://docs.aws.amazon.com/elasticloadbalancing/latest/network/network-load-balancers.html#connection-idle-timeout */ const DefaultClickHouseSettings: ClickHouseSettings = { send_progress_in_http_headers: 1, - http_headers_progress_interval_ms: '290000', + http_headers_progress_interval_ms: '20000', } export interface ClickHouseClientConfigOptions { diff --git a/packages/client-node/__tests__/integration/node_client.test.ts b/packages/client-node/__tests__/integration/node_client.test.ts index aa89f8dc..c579cf19 100644 --- a/packages/client-node/__tests__/integration/node_client.test.ts +++ b/packages/client-node/__tests__/integration/node_client.test.ts @@ -89,7 +89,7 @@ describe('[Node.js] Client', () => { const searchParams = new URL(callURL).search.slice(1).split('&') expect(searchParams).toContain('enable_http_compression=1') expect(searchParams).toContain('send_progress_in_http_headers=1') - expect(searchParams).toContain('http_headers_progress_interval_ms=290000') + expect(searchParams).toContain('http_headers_progress_interval_ms=20000') expect(searchParams).toContain(jasmine.stringContaining('query_id=')) expect(searchParams.length).toEqual(4) }