Skip to content

Commit

Permalink
Use 20s instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
slvrtrn committed Feb 29, 2024
1 parent bdfd32f commit 251e1d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
6 changes: 3 additions & 3 deletions packages/client-common/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ export interface ValuesEncoder<Stream> {
export type CloseStream<Stream> = (stream: Stream) => Promise<void>

/**
* 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<Stream> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 251e1d0

Please sign in to comment.