Skip to content

Commit 41aa85f

Browse files
authored
Merge branch 'master' into fix-stress-test
2 parents 1cbf672 + 2f64255 commit 41aa85f

File tree

257 files changed

+6696
-1371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+6696
-1371
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ enable_language(C CXX ASM)
4444
include (cmake/arch.cmake)
4545
include (cmake/target.cmake)
4646
include (cmake/tools.cmake)
47-
include (cmake/analysis.cmake)
47+
include (cmake/clang_tidy.cmake)
4848
include (cmake/git_status.cmake)
4949

5050
# Ignore export() since we don't use it,
@@ -417,7 +417,7 @@ if (COMPILER_CLANG)
417417
endif ()
418418

419419
elseif (ENABLE_THINLTO)
420-
message (${RECONFIGURE_MESSAGE_LEVEL} "ThinLTO is only available with CLang")
420+
message (${RECONFIGURE_MESSAGE_LEVEL} "ThinLTO is only available with Clang")
421421
endif ()
422422

423423
# Turns on all external libs like s3, kafka, ODBC, ...
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
option (ENABLE_CLANG_TIDY "Use clang-tidy static analyzer" OFF)
33

44
if (ENABLE_CLANG_TIDY)
5-
find_program (CLANG_TIDY_PATH NAMES "clang-tidy" "clang-tidy-13" "clang-tidy-12" "clang-tidy-11" "clang-tidy-10" "clang-tidy-9" "clang-tidy-8")
5+
6+
find_program (CLANG_TIDY_PATH NAMES "clang-tidy" "clang-tidy-14" "clang-tidy-13" "clang-tidy-12")
67

78
if (CLANG_TIDY_PATH)
89
message(STATUS
@@ -18,11 +19,7 @@ if (ENABLE_CLANG_TIDY)
1819

1920
# The variable CMAKE_CXX_CLANG_TIDY will be set inside src and base directories with non third-party code.
2021
# set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
21-
elseif (FAIL_ON_UNSUPPORTED_OPTIONS_COMBINATION)
22-
message(FATAL_ERROR "clang-tidy is not found")
2322
else ()
24-
message(STATUS
25-
"clang-tidy is not found.
26-
This is normal - the tool is only used for code static analysis and isn't essential for the build.")
23+
message(${RECONFIGURE_MESSAGE_LEVEL} "clang-tidy is not found")
2724
endif ()
2825
endif ()

contrib/NuRaft

docs/en/development/architecture.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ We maintain full backward and forward compatibility for the server TCP protocol:
159159
For most external applications, we recommend using the HTTP interface because it is simple and easy to use. The TCP protocol is more tightly linked to internal data structures: it uses an internal format for passing blocks of data, and it uses custom framing for compressed data. We haven’t released a C library for that protocol because it requires linking most of the ClickHouse codebase, which is not practical.
160160
:::
161161

162+
## Configuration {#configuration}
163+
164+
ClickHouse Server is based on POCO C++ Libraries and uses `Poco::Util::AbstractConfiguration` to represent it's configuration. Configuration is held by `Poco::Util::ServerApplication` class inherited by `DaemonBase` class, which in turn is inherited by `DB::Server` class, implementing clickhouse-server itself. So config can be accessed by `ServerApplication::config()` method.
165+
166+
Config is read from multiple files (in XML or YAML format) and merged into single `AbstractConfiguration` by `ConfigProcessor` class. Configuration is loaded at server startup and can be reloaded later if one of config files is updated, removed or added. `ConfigReloader` class is responsible for periodic monitoring of these changes and reload procedure as well. `SYSTEM RELOAD CONFIG` query also triggers config to be reloaded.
167+
168+
For queries and subsystems other than `Server` config is accessible using `Context::getConfigRef()` method. Every subsystem that is capable of reloading it's config without server restart should register itself in reload callback in `Server::main()` method. Note that if newer config has an error, most subsystems will ignore new config, log warning messages and keep working with previously loaded config. Due to the nature of `AbstractConfiguration` it is not possible to pass reference to specific section, so `String config_prefix` is usually used instead.
169+
162170
## Distributed Query Execution {#distributed-query-execution}
163171

164172
Servers in a cluster setup are mostly independent. You can create a `Distributed` table on one or all servers in a cluster. The `Distributed` table does not store data itself – it only provides a “view” to all local tables on multiple nodes of a cluster. When you SELECT from a `Distributed` table, it rewrites that query, chooses remote nodes according to load balancing settings, and sends the query to them. The `Distributed` table requests remote servers to process a query just up to a stage where intermediate results from different servers can be merged. Then it receives the intermediate results and merges them. The distributed table tries to distribute as much work as possible to remote servers and does not send much intermediate data over the network.

docs/en/development/cmake-in-clickhouse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Note that ClickHouse uses forks of these libraries, see https://github.com/Click
206206
<td><a href="https://ccache.dev/" target="_blank">https://ccache.dev/</a></td>
207207
</tr>
208208
<tr>
209-
<td><a name="enable-clang-tidy"></a><a href="https://github.com/clickhouse/clickhouse/blob/master/cmake/analysis.cmake#L2" rel="external nofollow noreferrer" target="_blank"><code class="syntax">ENABLE_CLANG_TIDY</code></a></td>
209+
<td><a name="enable-clang-tidy"></a><a href="https://github.com/clickhouse/clickhouse/blob/master/cmake/clang_tidy.cmake#L2" rel="external nofollow noreferrer" target="_blank"><code class="syntax">ENABLE_CLANG_TIDY</code></a></td>
210210
<td><code class="syntax">OFF</code></td>
211211
<td>Use clang-tidy static analyzer</td>
212212
<td><a href="https://clang.llvm.org/extra/clang-tidy/" target="_blank">https://clang.llvm.org/extra/clang-tidy/</a></td>

docs/en/interfaces/formats.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The supported formats are:
4949
| [PrettyCompactMonoBlock](#prettycompactmonoblock) |||
5050
| [PrettyNoEscapes](#prettynoescapes) |||
5151
| [PrettySpace](#prettyspace) |||
52+
| [Prometheus](#prometheus) |||
5253
| [Protobuf](#protobuf) |||
5354
| [ProtobufSingle](#protobufsingle) |||
5455
| [Avro](#data-format-avro) |||
@@ -1162,6 +1163,76 @@ You can select data from a ClickHouse table and save them into some file in the
11621163
``` bash
11631164
$ clickhouse-client --query = "SELECT * FROM test.hits FORMAT CapnProto SETTINGS format_schema = 'schema:Message'"
11641165
```
1166+
## Prometheus {#prometheus}
1167+
1168+
Expose metrics in [Prometheus text-based exposition format](https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format).
1169+
1170+
The output table should have a proper structure.
1171+
Columns `name` ([String](../sql-reference/data-types/string.md)) and `value` (number) are required.
1172+
Rows may optionally contain `help` ([String](../sql-reference/data-types/string.md)) and `timestamp` (number).
1173+
Column `type` ([String](../sql-reference/data-types/string.md)) is either `counter`, `gauge`, `histogram`, `summary`, `untyped` or empty.
1174+
Each metric value may also have some `labels` ([Map(String, String)](../sql-reference/data-types/map.md)).
1175+
Several consequent rows may refer to the one metric with different lables. The table should be sorted by metric name (e.g., with `ORDER BY name`).
1176+
1177+
There's special requirements for labels for `histogram` and `summary`, see [Prometheus doc](https://prometheus.io/docs/instrumenting/exposition_formats/#histograms-and-summaries) for the details. Special rules applied to row with labels `{'count':''}` and `{'sum':''}`, they'll be convered to `<metric_name>_count` and `<metric_name>_sum` respectively.
1178+
1179+
**Example:**
1180+
1181+
```
1182+
┌─name────────────────────────────────┬─type──────┬─help──────────────────────────────────────┬─labels─────────────────────────┬────value─┬─────timestamp─┐
1183+
│ http_request_duration_seconds │ histogram │ A histogram of the request duration. │ {'le':'0.05'} │ 24054 │ 0 │
1184+
│ http_request_duration_seconds │ histogram │ │ {'le':'0.1'} │ 33444 │ 0 │
1185+
│ http_request_duration_seconds │ histogram │ │ {'le':'0.2'} │ 100392 │ 0 │
1186+
│ http_request_duration_seconds │ histogram │ │ {'le':'0.5'} │ 129389 │ 0 │
1187+
│ http_request_duration_seconds │ histogram │ │ {'le':'1'} │ 133988 │ 0 │
1188+
│ http_request_duration_seconds │ histogram │ │ {'le':'+Inf'} │ 144320 │ 0 │
1189+
│ http_request_duration_seconds │ histogram │ │ {'sum':''} │ 53423 │ 0 │
1190+
│ http_requests_total │ counter │ Total number of HTTP requests │ {'method':'post','code':'200'} │ 1027 │ 1395066363000 │
1191+
│ http_requests_total │ counter │ │ {'method':'post','code':'400'} │ 3 │ 1395066363000 │
1192+
│ metric_without_timestamp_and_labels │ │ │ {} │ 12.47 │ 0 │
1193+
│ rpc_duration_seconds │ summary │ A summary of the RPC duration in seconds. │ {'quantile':'0.01'} │ 3102 │ 0 │
1194+
│ rpc_duration_seconds │ summary │ │ {'quantile':'0.05'} │ 3272 │ 0 │
1195+
│ rpc_duration_seconds │ summary │ │ {'quantile':'0.5'} │ 4773 │ 0 │
1196+
│ rpc_duration_seconds │ summary │ │ {'quantile':'0.9'} │ 9001 │ 0 │
1197+
│ rpc_duration_seconds │ summary │ │ {'quantile':'0.99'} │ 76656 │ 0 │
1198+
│ rpc_duration_seconds │ summary │ │ {'count':''} │ 2693 │ 0 │
1199+
│ rpc_duration_seconds │ summary │ │ {'sum':''} │ 17560473 │ 0 │
1200+
│ something_weird │ │ │ {'problem':'division by zero'} │ inf │ -3982045 │
1201+
└─────────────────────────────────────┴───────────┴───────────────────────────────────────────┴────────────────────────────────┴──────────┴───────────────┘
1202+
```
1203+
1204+
Will be formatted as:
1205+
1206+
```
1207+
# HELP http_request_duration_seconds A histogram of the request duration.
1208+
# TYPE http_request_duration_seconds histogram
1209+
http_request_duration_seconds_bucket{le="0.05"} 24054
1210+
http_request_duration_seconds_bucket{le="0.1"} 33444
1211+
http_request_duration_seconds_bucket{le="0.5"} 129389
1212+
http_request_duration_seconds_bucket{le="1"} 133988
1213+
http_request_duration_seconds_bucket{le="+Inf"} 144320
1214+
http_request_duration_seconds_sum 53423
1215+
http_request_duration_seconds_count 144320
1216+
1217+
# HELP http_requests_total Total number of HTTP requests
1218+
# TYPE http_requests_total counter
1219+
http_requests_total{code="200",method="post"} 1027 1395066363000
1220+
http_requests_total{code="400",method="post"} 3 1395066363000
1221+
1222+
metric_without_timestamp_and_labels 12.47
1223+
1224+
# HELP rpc_duration_seconds A summary of the RPC duration in seconds.
1225+
# TYPE rpc_duration_seconds summary
1226+
rpc_duration_seconds{quantile="0.01"} 3102
1227+
rpc_duration_seconds{quantile="0.05"} 3272
1228+
rpc_duration_seconds{quantile="0.5"} 4773
1229+
rpc_duration_seconds{quantile="0.9"} 9001
1230+
rpc_duration_seconds{quantile="0.99"} 76656
1231+
rpc_duration_seconds_sum 17560473
1232+
rpc_duration_seconds_count 2693
1233+
1234+
something_weird{problem="division by zero"} +Inf -3982045
1235+
```
11651236

11661237
## Protobuf {#protobuf}
11671238

docs/en/operations/clickhouse-keeper.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ ZooKeeper is one of the first well-known open-source coordination systems. It's
1313

1414
By default, ClickHouse Keeper provides the same guarantees as ZooKeeper (linearizable writes, non-linearizable reads). It has a compatible client-server protocol, so any standard ZooKeeper client can be used to interact with ClickHouse Keeper. Snapshots and logs have an incompatible format with ZooKeeper, but `clickhouse-keeper-converter` tool allows to convert ZooKeeper data to ClickHouse Keeper snapshot. Interserver protocol in ClickHouse Keeper is also incompatible with ZooKeeper so mixed ZooKeeper / ClickHouse Keeper cluster is impossible.
1515

16-
ClickHouse Keeper supports Access Control List (ACL) the same way as [ZooKeeper](https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) does. ClickHouse Keeper supports the same set of permissions and has the identical built-in schemes: `world`, `auth`, `digest`, `host` and `ip`. Digest authentication scheme uses pair `username:password`. Password is encoded in Base64.
16+
ClickHouse Keeper supports Access Control List (ACL) the same way as [ZooKeeper](https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#sc_ZooKeeperAccessControl) does. ClickHouse Keeper supports the same set of permissions and has the identical built-in schemes: `world`, `auth`, `digest`, `host` and `ip`. Digest authentication scheme uses pair `username:password`. Password is encoded in Base64.
1717

18-
:::note
18+
:::note
1919
External integrations are not supported.
2020
:::
2121

@@ -117,7 +117,7 @@ clickhouse keeper --config /etc/your_path_to_config/config.xml
117117

118118
## Four Letter Word Commands {#four-letter-word-commands}
119119

120-
ClickHouse Keeper also provides 4lw commands which are almost the same with Zookeeper. Each command is composed of four letters such as `mntr`, `stat` etc. There are some more interesting commands: `stat` gives some general information about the server and connected clients, while `srvr` and `cons` give extended details on server and connections respectively.
120+
ClickHouse Keeper also provides 4lw commands which are almost the same with Zookeeper. Each command is composed of four letters such as `mntr`, `stat` etc. There are some more interesting commands: `stat` gives some general information about the server and connected clients, while `srvr` and `cons` give extended details on server and connections respectively.
121121

122122
The 4lw commands has a white list configuration `four_letter_word_white_list` which has default value "conf,cons,crst,envi,ruok,srst,srvr,stat,wchc,wchs,dirs,mntr,isro".
123123

@@ -319,3 +319,28 @@ clickhouse-keeper-converter --zookeeper-logs-dir /var/lib/zookeeper/version-2 --
319319
4. Copy snapshot to ClickHouse server nodes with a configured `keeper` or start ClickHouse Keeper instead of ZooKeeper. The snapshot must persist on all nodes, otherwise, empty nodes can be faster and one of them can become a leader.
320320

321321
[Original article](https://clickhouse.com/docs/en/operations/clickhouse-keeper/) <!--hide-->
322+
323+
## Recovering after losing quorum
324+
325+
Because Clickhouse Keeper uses Raft it can tolerate certain amount of node crashes depending on the cluster size. \
326+
E.g. for a 3-node cluster, it will continue working correctly if only 1 node crashes.
327+
328+
Cluster configuration can be dynamically configured but there are some limitations. Reconfiguration relies on Raft also
329+
so to add/remove a node from the cluster you need to have a quorum. If you lose too many nodes in your cluster at the same time without any chance
330+
of starting them again, Raft will stop working and not allow you to reconfigure your cluster using the convenvtional way.
331+
332+
Nevertheless, Clickhouse Keeper has a recovery mode which allows you to forcfully reconfigure your cluster with only 1 node.
333+
This should be done only as your last resort if you cannot start your nodes again, or start a new instance on the same endpoint.
334+
335+
Important things to note before continuing:
336+
- Make sure that the failed nodes cannot connect to the cluster again.
337+
- Do not start any of the new nodes until it's specified in the steps.
338+
339+
After making sure that the above things are true, you need to do following:
340+
1. Pick a single Keeper node to be your new leader. Be aware that the data of that node will be used for the entire cluster so we recommend to use a node with the most up to date state.
341+
2. Before doing anything else, make a backup of the `log_storage_path` and `snapshot_storage_path` folders of the picked node.
342+
3. Reconfigure the cluster on all of the nodes you want to use.
343+
4. Send the four letter command `rcvr` to the node you picked which will move the node to the recovery mode OR stop Keeper instance on the picked node and start it again with the `--force-recovery` argument.
344+
5. One by one, start Keeper instances on the new nodes making sure that `mntr` returns `follower` for the `zk_server_state` before starting the next one.
345+
6. While in the recovery mode, the leader node will return error message for `mntr` command until it achieves quorum with the new nodes and refuse any requests from the client and the followers.
346+
7. After quorum is achieved, the leader node will return to the normal mode of operation, accepting all the requests using Raft - verify with `mntr` which should return `leader` for the `zk_server_state`.

docs/en/operations/server-configuration-parameters/settings.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Default value: 3600.
2323

2424
Data compression settings for [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)-engine tables.
2525

26-
:::warning
26+
:::warning
2727
Don’t use it if you have just started using ClickHouse.
2828
:::
2929

@@ -253,6 +253,23 @@ See also “[External dictionaries](../../sql-reference/dictionaries/external-di
253253
<dictionaries_config>*_dictionary.xml</dictionaries_config>
254254
```
255255

256+
## user_defined_executable_functions_config {#server_configuration_parameters-user_defined_executable_functions_config}
257+
258+
The path to the config file for executable user defined functions.
259+
260+
Path:
261+
262+
- Specify the absolute path or the path relative to the server config file.
263+
- The path can contain wildcards \* and ?.
264+
265+
See also “[Executable User Defined Functions](../../sql-reference/functions/index.md#executable-user-defined-functions).”.
266+
267+
**Example**
268+
269+
``` xml
270+
<user_defined_executable_functions_config>*_dictionary.xml</user_defined_executable_functions_config>
271+
```
272+
256273
## dictionaries_lazy_load {#server_configuration_parameters-dictionaries_lazy_load}
257274

258275
Lazy loading of dictionaries.
@@ -1357,6 +1374,16 @@ The directory with user files. Used in the table function [file()](../../sql-ref
13571374
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
13581375
```
13591376

1377+
## user_scripts_path {#server_configuration_parameters-user_scripts_path}
1378+
1379+
The directory with user scripts files. Used for Executable user defined functions [Executable User Defined Functions](../../sql-reference/functions/index.md#executable-user-defined-functions).
1380+
1381+
**Example**
1382+
1383+
``` xml
1384+
<user_scripts_path>/var/lib/clickhouse/user_scripts/</user_scripts_path>
1385+
```
1386+
13601387
## users_config {#users-config}
13611388

13621389
Path to the file that contains:

0 commit comments

Comments
 (0)