Commit Graph
1766 Commits
Author SHA1 Message Date
Alexey Milovidov b22cf29766 Load executable UDF drivers during server startup
Call `loadUserDefinedExecutableFunctionDrivers` during initial
`clickhouse-server` startup before persisted user-defined functions are loaded.
This makes source-tree driver configs such as `c_function_body` available
without waiting for a later config reload.

Resolve driver config directories to absolute paths before applying relative
`create_command` and `drop_command` entries. Driver commands run from a
per-function work directory, so a relative config directory would otherwise make
source-tree example commands relative to the wrong directory.

Improve the unknown-driver exception so it distinguishes an empty driver
registry from a typo in the requested driver name.

Tests:
`ninja -C build programs/clickhouse`
`CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04241_executable_udf_driver.sh`
`CLICKHOUSE_BINARY=./build/programs/clickhouse tests/queries/0_stateless/04242_executable_udf_driver_errors.sh`
`clickhouse-server` default-config smoke with `c_function_body`

Refs: https://github.com/ClickHouse/ClickHouse/pull/105131
2026-05-16 21:19:42 +02:00
Alexey MilovidovandClaude Opus 4.7 e2e1dc4c4a Add executable UDF drivers
Introduce "drivers" for executable user-defined functions. A driver is a
small adapter program declared in a server config under
`<user_defined_executable_function_drivers_config>` that knows how to take a
user-supplied code snippet and produce a runnable executable user-defined
function configuration.

New CREATE FUNCTION syntax:

    CREATE [OR REPLACE] FUNCTION [IF NOT EXISTS] name [ON CLUSTER c]
        ARGUMENTS (a UInt8, b String) RETURNS UInt64
        ENGINE = DriverName(key1 = 'value1', key2 = 42)
        AS '...code body...'

On CREATE FUNCTION, the corresponding `create_command` of the driver is
invoked: arguments are passed via `--name`, `--return`, `--args` and the
declared engine arguments; the body is sent on stdin; the driver writes the
resulting executable UDF configuration (XML or YAML) to stdout, which is
saved into the new `<dynamic_user_defined_executable_functions_path>` and
picked up by the existing executable UDF loader. The corresponding SQL is
persisted as `ATTACH FUNCTION ...` in `<user_defined>` and re-evaluated on
restart: if the dynamic configuration is still present, the driver is not
invoked; otherwise the driver is re-run to materialize it.

On DROP FUNCTION, the `drop_command` (if any) is invoked, then the dynamic
configuration file and per-function working directory are removed.

Includes a proof-of-concept driver `c_function_body`, which compiles a user
C body into a binary (inside Docker by default for build-time isolation) and
runs it inside Docker at query time with strict sandboxing (`--network=none`,
`--read-only`, dropped capabilities, no-new-privileges, unprivileged user,
resource limits) in `executable_pool` mode for batched per-row evaluation.

See https://github.com/ClickHouse/ClickHouse/issues/71172

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-05-16 17:24:08 +00:00
Alexey MilovidovandGitHub bc91918852 Merge pull request #100277 from ClickHouse/webterminal
Add web terminal interface to clickhouse-server
2026-05-15 17:54:21 +02:00
Raúl Marín 031d2e81f5 Merge remote-tracking branch 'blessed/master' into remove-settings-vtable-v2
# Conflicts:
#	src/Core/BaseSettings.h
#	src/Core/SettingsFields.h
2026-05-07 10:39:35 +02:00
Alexey Milovidov f29d428d82 Merge remote-tracking branch 'origin/master' into webterminal 2026-05-05 18:49:01 +00:00
Raúl Marín a988acca9e Merge remote-tracking branch 'blessed/master' into remove-settings-vtable-v2
# Conflicts:
#	src/Storages/MergeTree/MergeTreeSettings.cpp
2026-05-04 11:01:32 +02:00
Alexey Milovidov 8588fcac45 Merge remote-tracking branch 'origin/master' into webterminal 2026-05-01 11:25:01 +00:00
Alexey Milovidov eff6a0e2f1 Merge remote-tracking branch 'origin/master' into revert-98038-revert-96025-clickhouse-help 2026-05-01 03:46:13 +00:00
Alexey Milovidov 6fea7f8a9d Merge remote-tracking branch 'origin/master' into fix-parquet-memory-watermark-autotune 2026-04-30 08:57:18 +00:00
Alexey Milovidov e5191b08cd Merge remote-tracking branch 'origin/master' into webterminal 2026-04-30 07:18:56 +00:00
Alexey Milovidov d4e0cf86b8 Merge remote-tracking branch 'origin/master' into revert-98038-revert-96025-clickhouse-help 2026-04-30 00:47:38 +00:00
Alexey MilovidovandGitHub 811710c52b Merge pull request #103693 from Algunenano/dns-resolver-no-eager-init
Skip local-hostname DNS lookup in client startup
2026-04-29 14:15:51 +00:00
Raúl MarínandClaude Opus 4.7 8721378d53 Do not resolve local hostname in DNSResolver singleton ctor
`DNSResolver::Impl::Impl()` was eagerly running
`Poco::Net::DNS::hostName()` followed by `hostByName` on the local
hostname. The cached result is consumed only by
`updateHostNameAndAddresses` (a server-only periodic task) and by
`getHostName`, which has its own lazy fallback. Yet the work happened
inside a process-wide Meyers singleton, so every program that calls
`DNSResolver::instance` paid the cost — including `clickhouse-client`,
`-local`, `-keeper`, and `-disks`.

When the local hostname could not be resolved (a normal occurrence on
fresh CI/EC2 runners where the auto-generated `ip-X-X-X-X` name is
neither in `/etc/hosts` nor served by the VPC resolver), the catch
block in the constructor logged a stack trace at error level. The
fast-test runner treats any stderr output as a test failure, so this
infrastructure flake masqueraded as a per-test failure.

Move the eager priming out of the singleton constructor:
* `Impl::Impl` is now defaulted; non-server programs no longer touch
  the local hostname during startup.
* `programs/server/Server.cpp` calls `updateHostNameAndAddresses`
  explicitly before starting `DNSCacheUpdater`, so the first cache
  tick on a healthy server still sees a populated value and does not
  spuriously emit `IPs of host name X have been changed`.

Behaviour from PR #93726 (cluster config reload on host IP change) is
preserved — verified by `test_reload_cluster_config_if_host_address_change`,
which still passes.

Failing fast tests in https://github.com/ClickHouse/ClickHouse/pull/103689
(report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103689&sha=3a119a57269adba3557204ce44e58a65054e31df&name_0=PR&name_1=Fast%20test
)
include `Tests/02001_hostname_test`, `Tests/03213_deep_json`,
`Tests/03638_merge_max_dynamic_subcolumns_in_compact_part`, and
`Tests/02433_default_expression_operator_in`, all hitting the same
`Cannot resolve host (ip-172-31-33-233)` startup path.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-04-29 03:46:28 +00:00
Alexey Milovidov dae2d6994b Address review: revert ad-hoc low-memory ratio uplifts in Server.cpp
Drop two heuristics added during PR development that override explicit
user-configured ratios on small systems:

- Forced uplift of `max_server_memory_usage_to_ram_ratio` to `0.95` when
  RAM < 4 GiB.
- Forced cap of `merges_mutations_memory_usage_to_ram_ratio` to `0.1`
  when RAM < 4 GiB.

Per reviewer feedback: too ad-hoc, removing for now. The remaining
auto-tuning (Parquet watermark, INSERT block size, background pool,
jemalloc dirty decay) is sufficient for the low-memory case and does not
silently override explicit operator settings.
2026-04-29 02:51:34 +00:00
Alexey Milovidov 4533202826 Merge remote-tracking branch 'origin/master' into revert-98038-revert-96025-clickhouse-help
# Conflicts:
#	programs/main.cpp
2026-04-28 00:04:50 +00:00
Alexey Milovidov 394853b1cc Merge remote-tracking branch 'origin/master' into mdraid-resync-warning 2026-04-27 20:50:01 +00:00
Alexey Milovidov aae661b60c Merge remote-tracking branch 'origin/master' into fix-parquet-memory-watermark-autotune 2026-04-27 18:43:02 +00:00
Alexey Milovidov 0bac680406 Merge remote-tracking branch 'origin/master' into webterminal 2026-04-27 17:08:27 +00:00
Sema ChecherindaandGitHub 64afd8852d Merge pull request #100478 from ClickHouse/feat/http-connection-socket-buffer-sizes
Add socket buffer size settings for outgoing HTTP connections
2026-04-27 06:01:57 +00:00
Alexey MilovidovandClaude Opus 4.7 e09493d002 Fix post-merge build break in sanityCheck calls
After merging master, two new call sites in `programs/server/Server.cpp`
(lines 2847-2848) pass only three arguments to `MergeTreeSettings::sanityCheck`,
which this branch expanded to take four arguments (adding the
`background_pool_auto_lowered` flag).

Pass `global_context->wasBackgroundPoolAutoLowered()` at both call sites so
the startup-time sanity check agrees with the per-table checks in
`MergeTreeData.cpp`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-04-21 11:18:51 +00:00
Alexey Milovidov 97696bb1a5 Merge remote-tracking branch 'origin/master' into fix-parquet-memory-watermark-autotune 2026-04-20 15:34:32 +00:00
Alexey Milovidov 673ddb52b1 Merge remote-tracking branch 'origin/master' into revert-98038-revert-96025-clickhouse-help 2026-04-20 02:08:29 +00:00
Alexey Milovidov a1d7f12759 Merge remote-tracking branch 'origin/master' into webterminal 2026-04-19 22:57:31 +00:00
Alexey Milovidov 206415b348 Merge remote-tracking branch 'origin/master' into mdraid-resync-warning 2026-04-19 12:04:18 +00:00
Pervakov GrigoriiandGitHub 40af647f53 Merge pull request #93455 from evkuzin/raft_reload_certs
Enable TLS certificate hot-reload for Keeper Raft connections
2026-04-15 13:54:55 +00:00
Yakov OlkhovskiyandGitHub bad5772347 Merge branch 'master' into feat-arrowflight-impl 2026-04-14 08:51:46 -04:00
Sema Checherinda 7815291d77 Merge branch 'master' into feat/http-connection-socket-buffer-sizes 2026-04-14 12:17:42 +02:00
Pervakov GrigoriiandGitHub c72691eedd Merge branch 'master' into raft_reload_certs 2026-04-13 17:33:48 +02:00
Yakov OlkhovskiyandGitHub 57c643f2c4 Merge branch 'master' into feat-arrowflight-impl 2026-04-10 19:21:59 -04:00
Raúl MarínandClaude Opus 4.6 9d70fd6c5a Make SettingFieldTimespan trivially copyable
Store `Poco::Timespan::TimeDiff` (int64_t) instead of `Poco::Timespan`
in `SettingFieldTimespan`. Poco::Timespan has user-defined copy/dtor
that prevent trivial copyability despite wrapping a single int64_t.

This makes 46 settings (22 Seconds + 28 Milliseconds fields across
Settings alone) trivially copyable, enabling the compiler to include
them in the memcpy prefix of the Data copy constructor.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-04-10 13:50:16 +02:00
kssenii a39cafba2a Move FileCache to separate dir 2026-04-09 11:33:20 +02:00
Alexey MilovidovandGitHub e3fa82ea1b Merge branch 'master' into revert-98038-revert-96025-clickhouse-help 2026-04-09 00:41:28 -07:00
Alexey MilovidovandGitHub 54186dc558 Merge branch 'master' into webterminal 2026-04-08 15:46:10 -07:00
Alexey MilovidovandGitHub e33adbb058 Merge branch 'master' into mdraid-resync-warning 2026-04-07 17:48:46 -07:00
Sema Checherinda 99673a751e Merge branch 'public-master' into feat/http-connection-socket-buffer-sizes 2026-04-07 16:25:08 +02:00
Alexey MilovidovandGitHub 901425076c Merge branch 'master' into mdraid-resync-warning 2026-04-06 17:49:19 -07:00
Alexey MilovidovandGitHub 2963920eb4 Merge branch 'master' into webterminal 2026-04-06 17:48:48 -07:00
Alexey MilovidovandGitHub f515491416 Merge branch 'master' into revert-98038-revert-96025-clickhouse-help 2026-04-06 17:48:15 -07:00
Alexey Milovidov 29c91436f9 Merge remote-tracking branch 'origin/master' into fix-parquet-memory-watermark-autotune
# Conflicts:
#	src/Interpreters/InterpreterInsertQuery.cpp
2026-04-04 22:27:01 -07:00
Alexey MilovidovandGitHub c9e97cf942 Merge branch 'master' into sync-changes-14 2026-04-04 22:12:55 -07:00
Yakov Olkhovskiy 4da830e863 Merge remote-tracking branch 'origin/master' into feat-arrowflight-impl 2026-04-02 19:13:24 +00:00
Alexey Milovidov c16f4e8662 Merge remote-tracking branch 'origin/master' into webterminal 2026-04-01 19:02:32 +00:00
Azat Khuzhin 3e2f752736 Add ability limit amount of jemalloc profile flushes on MEMORY_LIMIT_EXCEEDED per time interval 2026-04-01 11:26:59 +02:00
kssenii f008115ce3 Sync changes 2026-03-31 16:36:01 +02:00
Alexey MilovidovandGitHub 9183caadf9 Merge branch 'master' into fix-parquet-memory-watermark-autotune 2026-03-31 12:12:33 +02:00
Yakov OlkhovskiyandGitHub 8f3e0475c5 Merge branch 'master' into feat-arrowflight-impl 2026-03-30 21:12:03 -04:00
Alexey MilovidovandClaude Opus 4.6 b9dfdcc17b Address review: main loop receive timeout, SSH error message
- Set a 30-second `setReceiveTimeout` in the main WebSocket I/O loop to
  prevent a malicious client from blocking the handler thread by trickling
  bytes after `poll` indicates readability. On timeout, the connection is
  terminated (not continued), avoiding protocol desync from partial frame
  reads.

- Fix the SSH `#else` branch error message to also mention non-Linux
  platforms, since the guard is `USE_SSH && defined(OS_LINUX)`.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-03-30 16:33:54 +00:00
Alexey Milovidov 2e15ae037c Merge remote-tracking branch 'origin/master' into revert-98038-revert-96025-clickhouse-help 2026-03-30 07:43:50 +00:00
Alexey Milovidov 7e8a810e60 Merge remote-tracking branch 'origin/master' into webterminal
# Conflicts:
#	src/CMakeLists.txt
2026-03-30 02:52:04 +00:00
Nikita Fomichev 19fa7af12f Merge remote-tracking branch 'origin/master' into fix-coverage-symbol-quality
# Conflicts:
#	ci/jobs/build_clickhouse.py
2026-03-29 22:32:03 +02:00