99 Commits
Author SHA1 Message Date
Alexey Milovidov f8b0369c50 Merge remote-tracking branch 'origin/master' into port-remaining-dns-paths-to-cache 2026-10-03 04:12:12 +00:00
Alexey MilovidovandClaude Opus 5 9b5682e567 Address review: keep the proxy host name, evict stale 4LW entries
Do not replace `ProxyConfig::host` with a resolved address. Poco reuses it as
the TLS peer name whenever TLS terminates at the proxy rather than at the
target - an `https` proxy, or an `http` proxy with tunneling turned off - so an
address there breaks certificate verification against the proxy's host name.
`ClickHouse` only turns tunneling on for an `https` request over an `http`
proxy (`ProxyConfiguration::useTunneling`), so every other proxied
configuration takes the `setPeerHostName(getProxyHost())` branch of
`HTTPSClientSession::connect`. Routing the proxy host through the cache needs a
resolved-proxy-host field in the session, mirroring `setResolvedHost`; the
constraint is now recorded as a comment where the substitution used to be.

The two four-letter-word helpers now drop the host from the DNS cache when a
connection attempt fails, like `Connection` and `ZooKeeper::connect` already
do. It matters most in `clickhouse-keeper-client`: a client program has no
`DNSCacheUpdater`, so nothing would ever refresh the entry and one lookup would
pin the address for the whole session.

Server paths that are not latency critical on reconnect (the Graphite writer,
the distributed query exchange source, Redis) keep relying on
`DNSCacheUpdater` to refresh the cache within `dns_cache_update_period`, which
is the same contract `Cluster` and the HTTP connection pools have always had.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 17:39:45 +00:00
Alexey MilovidovandClaude Opus 5 9f1ccd79e9 Port the remaining DNS resolution paths to the DNS cache
`Poco::Net::SocketAddress(host, port)` resolves the host name itself, through
`Poco::Net::DNS::hostByName`. Every place that constructed one from a host name
therefore bypassed `DNSResolver`, so the lookup was not cached, not shared with
the rest of the server, not visible in `system.dns_cache`, not counted, and not
subject to `dns_allow_resolve_names_to_ipv4` and
`dns_allow_resolve_names_to_ipv6`.

All of those places resolve through `DNSResolver` now:

- the ZooKeeper and Keeper client, which resolved every configured node on
  every connection attempt;
- `GraphiteWriter`, which resolved the Graphite host on every transmission;
- the four-letter-word command target of `system.zookeeper_info`;
- the Redis dictionary source and table function;
- the HTTP proxy host in `HTTPConnectionPool` - Poco resolves
  `ProxyConfig::host` on its own, so the per-endpoint `HostResolver` never
  covered it;
- the remote peer of a distributed query exchange stream, and the exchange
  listener;
- the `is_local` check of the ClickHouse dictionary source;
- `listen_host` and `bind_host` when they are host names;
- `clickhouse-keeper-client`, `clickhouse-keeper-bench` and the BuzzHouse HTTP
  helper.

A literal IP address in `listen_host` or `bind_host` is still used as is: there
is no name to look up, and `dns_allow_resolve_names_to_ipv4` and
`dns_allow_resolve_names_to_ipv6` restrict which addresses we resolve names of
remote hosts to, not which of our own addresses we may bind. Without this,
`<listen_host>::</listen_host>` would stop working on a server that has
`dns_allow_resolve_names_to_ipv6` disabled.

Detecting a literal cannot use `Poco::Net::IPAddress::tryParse` alone: it
reports failure for an address that parses to all zeroes, because it decides
success by comparing the parsed value against a default constructed one. So it
rejects `::`, the most common `listen_host` of all (the IPv4 wildcard is worked
around there with a string comparison against `0.0.0.0`). `inet_pton` is used
as a fallback; `tryParse` is still tried first because it also accepts a scope
suffix.

The ZooKeeper client drops a host from the cache whenever a connection attempt
to it fails, the same way `Connection` does, so a changed address is picked up
on the next attempt instead of waiting for `dns_cache_update_period`.

Clients from third-party libraries (MySQL, PostgreSQL, Kafka, RabbitMQ, NATS,
MongoDB, Hive Metastore over Thrift, gRPC, NuRaft) keep their own resolvers:
handing them a pre-resolved address would defeat their own multi-address
failover and TLS host name verification.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 14:18:16 +00:00
Alexey MilovidovandClaude Opus 5 3c887ba99c Report the actual configuration file in clickhouse-keeper-client and document the new lookup
Addresses the review of #118422.

`clickhouse-keeper-client` now finds `config.yaml` and `config.yml`, but its
diagnostics still named `config.xml`: the `--config-file` help text and the
`Found keeper node in the config.xml, will use it for connection` message. A
user connected through a YAML file was pointed at a file that does not exist.
The resolved path is now threaded through `connectToKeeper` and logged, and the
help text mentions all three names.

The utility documentation of `clickhouse-keeper-client` and `clickhouse-disks`
still described the XML-only default, and the `Configuration files` section of
the `clickhouse-local` page contradicted the new `Usage` section; all three are
updated.

Test `05182_keeper_client_config_file_yaml_in_current_directory` covers the
`clickhouse-keeper-client` loader, which is separate from the shared
`BaseDaemon` path exercised by the other two tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 07:56:47 +00:00
Alexey Milovidov b0d1a4b66c Look up the default configuration file with all supported extensions
A ClickHouse configuration file can be written in XML or in YAML, but the
lookup of the *default* configuration file only knew about `.xml`, so a
`config.yaml` or `config.yml` in the current directory was silently
ignored. `clickhouse-server` was the worst case: it fell back to the
configuration embedded into the binary and started up with a
configuration the user did not write.

The other lookup paths already probe all three extensions, so
`~/.clickhouse-local/config.yaml` worked while `./config.yaml` did not.

Now the default configuration file is looked up as `config.xml`,
`config.yaml` and `config.yml`, in this order, and the first one that
exists is used. This covers `clickhouse-server`, `clickhouse-keeper`
(`keeper_config.*`), `clickhouse-local`, `clickhouse-keeper-client` and
`clickhouse-disks`. The extension probing is factored into
`tryGetConfigPath` and `getConfigPathForAnySupportedFormat`, which
`getLocalConfigPath` and `getClientConfigPath` now use as well.

A file requested explicitly with `--config-file` or `-C` is still used as
is: silently substituting a different file for the name the user typed
would be worse than reporting that it does not exist.

Closes: https://github.com/ClickHouse/ClickHouse/issues/118411
2026-09-06 14:29:38 +00:00
Alexey MilovidovandClaude Opus 4.6 d5f952b04a Enable -Wmissing-prototypes compiler warning
Add `static` to file-local functions and forward declarations
for cross-TU functions to satisfy `-Wmissing-prototypes`.

This ensures all functions have visible prototypes before their
definitions, improving code quality and catching accidental
linkage issues.

Reference: https://github.com/ClickHouse/ClickHouse/issues/76944

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 20:11:07 +00:00
Alexey Milovidov 6656530fd9 Merge pull request #96800 from GSokol/improvement/keeper_client_config
Add fields to support to keeper-client config
2026-03-22 14:46:15 +01:00
Azat KhuzhinandClaude 8ea6465c1e shell-like completion support in clickhouse keeper-client (and quoting for ls)
shell-like completion support in clickhouse keeper-client (handle
completions of arguments in quotes, i.e. 'foo ba', handle escaped
arguments, i.e. foo\ ba, make ls print quoted nodes, if they have
whitespaces)

Also remove on_complete_modify_callback hack, replace it with pure
getCompletions implementation

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-16 15:20:12 +01:00
Grigorii Sokolik a5e8c4d35d Add fields to support to keeper-client config
Add support of `password` and `identity` fields to keeper-client config.
More over, those parameters could be passed via CLICKHOUSE_KEEPER_PASSWORD
and CLICKHOUSE_KEEPER_IDENTITY environment variables. The priority is
the following: CMD PARAMS > ENVIRONMENT VARIABLES > CONFIG FILE.
2026-03-09 13:51:30 +02:00
Konstantin Bogdanov 69f3701773 Exit early on empty input 2026-03-03 13:59:57 +01:00
Konstantin Bogdanov fbd81a75e1 Reorder imports 2026-03-03 12:54:14 +01:00
Konstantin Bogdanov e4826cf207 Merge remote-tracking branch 'origin/master' into keeper-completion-continue 2026-03-03 12:53:31 +01:00
Konstantin Bogdanov eea5d12af2 Lint 2026-02-24 10:42:38 +01:00
Konstantin Bogdanov 52f8fa3892 keeper-client: fix command completion and quote handling in path completion
Fix command name completion which was broken because appending a closing
quote before tokenizing caused the tokenizer to misinterpret command
prefixes (e.g. 'ls') as path arguments. Split into two-phase approach:
probe the original prefix to decide command vs path, then append quote
only for path parsing.

Fix double closing quote when TAB is pressed with cursor before an
existing closing quote — strip the old quote so completion re-adds it
with the correct suffix (closing quote for leaves, / for directories).

Remove duplicate methods (askConfirmation, getAbsolutePath, loadCommands)
now provided by KeeperClientBase.

Add PTY-based autocomplete test covering command completion, path
completion, directory trailing slash, leaf closing quote, and drill-down.

Assisted-by: Claude Opus 4.6 via GitHub Copilot
2026-02-24 10:24:24 +01:00
Azat Khuzhin 2303d6813b keeper-client: do not append trailing slash in completion
Everything works without it, and it breaks completion after it appends
leading slash.
2026-02-24 07:28:34 +01:00
Azat Khuzhin 227eb3b39f keeper-client: append double quote in the getCompletions() to pass parser 2026-02-24 07:28:33 +01:00
Azat Khuzhin 764d58df00 keeper-client: do not append trailing double quote (breaks completion) 2026-02-24 07:27:24 +01:00
Azat Khuzhin 7681b60292 keeper-client: remove slash from word delimiters (should break completion) 2026-02-24 07:27:24 +01:00
Azat Khuzhin 8ab3aa3a07 keeper-client: wrap completion of keeper paths into double quotes 2026-02-24 07:27:24 +01:00
Azat Khuzhin 317cac64f9 keeper-client: prepend parent directory to fix completion 2026-02-24 07:27:24 +01:00
Azat Khuzhin 2535c68c82 keeper-client: automatically wrap non-first argument with double quotes
It is too had to add them on your own!
2026-02-24 07:26:49 +01:00
Antonio Andelic b5fe4ced60 Merge branch 'master' into enforce-component-name 2026-02-23 15:57:28 +01:00
Alexey Milovidov 3aa3b14299 Merge pull request #97644 from ClickHouse/fix-keeper-client-test-race-condition
Fix race condition in KeeperClient test helper causing flaky test_rm_with_version
2026-02-23 03:42:24 +00:00
Alexey MilovidovandClaude Opus 4.6 5bd35fee7c Add comments explaining the BEL separator protocol in keeper-client tests-mode
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:17:51 +01:00
Alexey MilovidovandClaude Opus 4.6 9ebf3853be Fix race condition in KeeperClient.execute_query causing flaky test_rm_with_version
The `execute_query` method in the Python test helper uses `epoll` to
read from both stdout and stderr of the keeper-client process. When
a command fails, the keeper-client writes the error to stderr and then
the separator to stdout. However, when both events arrive simultaneously
in `epoll.poll()`, the loop could process stdout first, find the
separator, and return successfully without ever reading the pending
stderr error data - causing the exception to be silently swallowed.

Fix both sides:
- C++ (`KeeperClient.cpp`): flush stderr before writing the stdout
  separator, ensuring error data is in the pipe buffer first.
- Python (`keeper_utils.py`): process stderr events before stdout
  events in the poll loop, so errors are always collected before
  checking the separator.

Also fix test cleanup: add `try/finally` with `drop_node_if_exists`
to `test_rm_with_version` and `test_rm_without_version`, and give
`test_rm_without_version` its own unique node path instead of
reusing `/test_rm_with_version_node`.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97554&sha=3f86a6142c6920239c1b3adedfe82ccb5fcd6515&name_0=PR&name_1=Integration%20tests%20%28amd_binary%2C%204%2F5%29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:17:51 +01:00
Raúl MarínandClaude Opus 4.6 9aa8e4ed27 Move ErrnoException from Exception.h to its own header
Extract `ErrnoException` into `Common/ErrnoException.h` to reduce the
include footprint of `Exception.h`. This removes `<base/errnoToString.h>`
and `<cerrno>` from `Exception.h`, which is included by ~95% of all
translation units.

All files referencing `ErrnoException` now include the new header
directly. Files that used `errnoToString` without `ErrnoException`
got an explicit `<base/errnoToString.h>` include.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 13:47:23 +01:00
Antonio Andelic 18453e8dac Add component names 2026-02-06 18:36:29 +01:00
pufit f94ff23aa1 Fix issue with session reconnects
Better UI
2025-12-30 03:17:56 -05:00
pufit e8f282d62a Merge branch 'master' into ch-keeper-http-api-v1
# Conflicts:
#	programs/keeper-client/KeeperClient.cpp
#	programs/keeper-client/KeeperClient.h
#	programs/server/Server.cpp
#	src/Server/HTTPRequestHandlerFactoryMain.cpp
2025-12-29 19:46:51 -05:00
Alexey Milovidov 2e3fcd24ef Merge pull request #88065 from chhetripradeep/pchhetri/keeper-client-tls-auth
clickhouse-keeper-client: Add support to connect to tls port of clickhouse-keeper
2025-10-16 19:27:11 +02:00
Mikhail Artemenko 251b28f1bb implement cpr mvr 2025-10-15 11:34:35 +00:00
chhetripradeep f142cd2936 keeper-client: add support to connect to tls-only keeper 2025-10-03 19:27:06 +08:00
Michael Stetsyuk 761aea0027 fix keeper client 2025-09-09 16:33:31 +00:00
Michael Stetsyuk 02260a224d pass zookeeper args directly 2025-09-09 09:20:09 +00:00
Antonio Andelic 43f6f91207 Add GetACL request to KeeperClient 2025-07-29 09:27:31 +02:00
Raúl Marín aa691e4f95 Merge pull request #82483 from Algunenano/includes_utils
Style: Forbid the use of quotes for includes (partial)
2025-06-26 11:41:55 +00:00
Antonio Andelic 22559a31f9 Fix tests with keeper client 2025-06-25 14:15:41 +02:00
Raúl Marín d6ac63c8d2 Style: Forbid the use of quotes for includes (partial) 2025-06-24 13:20:10 +02:00
pufit 3dabac5c0b Merge branch 'master' into ch-keeper-http-api-v1
# Conflicts:
#	src/Server/HTTP/HTTPServerRequest.h
2025-06-14 01:04:19 -04:00
pufit 8a55953def Fix build, fix style, small refactoring 2025-06-14 01:03:37 -04:00
pufit ea2f67c244 Fix copypaste 2025-06-09 20:03:17 -04:00
pufit ee5dfdd130 Make naming consistent 2025-06-09 19:58:01 -04:00
Michael Stetsyuk d195c257b7 mark exceptions as logged 2025-06-06 13:40:27 +00:00
pufit ac6c202a88 KeeperClient over Dispatcher 2025-05-03 01:08:55 -04:00
Nikita Mikhaylov ee12273297 Improve the SSH protocol 2025-03-18 14:53:35 +01:00
Azat Khuzhin 550472fbec keeper-client: suppress "Finalizing session {}" message 2025-02-20 18:40:16 +01:00
Azat Khuzhin 5de42d0c63 keeper-client: add missing new line on exit 2025-02-20 18:40:09 +01:00
alesapin a14feb1650 Update programs/keeper-client/KeeperClient.cpp 2025-01-17 20:42:09 +01:00
alesapin 136321f023 Fix clickhouse keeper-client as well 2025-01-16 19:02:21 +01:00
Gamezardashvili George dce8775516 SSH Authentication 2025-01-08 11:53:53 +01:00