forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into keeper-disk-move-fix
- Loading branch information
Showing
249 changed files
with
7,716 additions
and
2,111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <base/cgroupsv2.h> | ||
|
||
#include <base/defines.h> | ||
|
||
#include <fstream> | ||
#include <sstream> | ||
|
||
|
||
bool cgroupsV2Enabled() | ||
{ | ||
#if defined(OS_LINUX) | ||
/// This file exists iff the host has cgroups v2 enabled. | ||
auto controllers_file = default_cgroups_mount / "cgroup.controllers"; | ||
if (!std::filesystem::exists(controllers_file)) | ||
return false; | ||
return true; | ||
#else | ||
return false; | ||
#endif | ||
} | ||
|
||
bool cgroupsV2MemoryControllerEnabled() | ||
{ | ||
#if defined(OS_LINUX) | ||
chassert(cgroupsV2Enabled()); | ||
/// According to https://docs.kernel.org/admin-guide/cgroup-v2.html: | ||
/// - file 'cgroup.controllers' defines which controllers *can* be enabled | ||
/// - file 'cgroup.subtree_control' defines which controllers *are* enabled | ||
/// Caveat: nested groups may disable controllers. For simplicity, check only the top-level group. | ||
std::ifstream subtree_control_file(default_cgroups_mount / "cgroup.subtree_control"); | ||
if (!subtree_control_file.is_open()) | ||
return false; | ||
std::string controllers; | ||
std::getline(subtree_control_file, controllers); | ||
if (controllers.find("memory") == std::string::npos) | ||
return false; | ||
return true; | ||
#else | ||
return false; | ||
#endif | ||
} | ||
|
||
std::string cgroupV2OfProcess() | ||
{ | ||
#if defined(OS_LINUX) | ||
chassert(cgroupsV2Enabled()); | ||
/// All PIDs assigned to a cgroup are in /sys/fs/cgroups/{cgroup_name}/cgroup.procs | ||
/// A simpler way to get the membership is: | ||
std::ifstream cgroup_name_file("/proc/self/cgroup"); | ||
if (!cgroup_name_file.is_open()) | ||
return ""; | ||
/// With cgroups v2, there will be a *single* line with prefix "0::/" | ||
/// (see https://docs.kernel.org/admin-guide/cgroup-v2.html) | ||
std::string cgroup; | ||
std::getline(cgroup_name_file, cgroup); | ||
static const std::string v2_prefix = "0::/"; | ||
if (!cgroup.starts_with(v2_prefix)) | ||
return ""; | ||
cgroup = cgroup.substr(v2_prefix.length()); | ||
return cgroup; | ||
#else | ||
return ""; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <filesystem> | ||
#include <string> | ||
|
||
#if defined(OS_LINUX) | ||
/// I think it is possible to mount the cgroups hierarchy somewhere else (e.g. when in containers). | ||
/// /sys/fs/cgroup was still symlinked to the actual mount in the cases that I have seen. | ||
static inline const std::filesystem::path default_cgroups_mount = "/sys/fs/cgroup"; | ||
#endif | ||
|
||
/// Is cgroups v2 enabled on the system? | ||
bool cgroupsV2Enabled(); | ||
|
||
/// Is the memory controller of cgroups v2 enabled on the system? | ||
/// Assumes that cgroupsV2Enabled() is enabled. | ||
bool cgroupsV2MemoryControllerEnabled(); | ||
|
||
/// Which cgroup does the process belong to? | ||
/// Returns an empty string if the cgroup cannot be determined. | ||
/// Assumes that cgroupsV2Enabled() is enabled. | ||
std::string cgroupV2OfProcess(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
slug: /en/operations/system-tables/dns_cache | ||
--- | ||
# dns_cache | ||
|
||
Contains information about cached DNS records. | ||
|
||
Columns: | ||
|
||
- `hostname` ([String](../../sql-reference/data-types/string.md)) — cached hostname | ||
- `ip_address` ([String](../../sql-reference/data-types/string.md)) — ip address for the hostname | ||
- `ip_family` ([Enum](../../sql-reference/data-types/enum.md)) — family of the ip address, possible values: | ||
- 'IPv4' | ||
- 'IPv6' | ||
- 'UNIX_LOCAL' | ||
- `cached_at` ([DateTime](../../sql-reference/data-types/datetime.md)) - when the record was cached | ||
|
||
**Example** | ||
|
||
Query: | ||
|
||
```sql | ||
SELECT * FROM system.dns_cache; | ||
``` | ||
|
||
Result: | ||
|
||
| hostname | ip\_address | ip\_family | cached\_at | | ||
| :--- | :--- | :--- | :--- | | ||
| localhost | ::1 | IPv6 | 2024-02-11 17:04:40 | | ||
| localhost | 127.0.0.1 | IPv4 | 2024-02-11 17:04:40 | | ||
|
||
**See also** | ||
|
||
- [disable_internal_dns_cache setting](../../operations/server-configuration-parameters/settings.md#disable_internal_dns_cache) | ||
- [dns_cache_max_size setting](../../operations/server-configuration-parameters/settings.md#dns_cache_max_size) | ||
- [dns_cache_update_period setting](../../operations/server-configuration-parameters/settings.md#dns_cache_update_period) | ||
- [dns_max_consecutive_failures setting](../../operations/server-configuration-parameters/settings.md#dns_max_consecutive_failures) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
slug: /en/operations/system-tables/settings_changes | ||
--- | ||
# settings_changes | ||
|
||
Contains information about setting changes in previous ClickHouse versions. | ||
|
||
Columns: | ||
|
||
- `version` ([String](../../sql-reference/data-types/string.md)) — The ClickHouse version in which settings were changed | ||
- `changes` ([Array](../../sql-reference/data-types/array.md) of [Tuple](../../sql-reference/data-types/tuple.md)) — A description of the setting changes: (setting name, previous value, new value, reason for the change) | ||
|
||
**Example** | ||
|
||
``` sql | ||
SELECT * | ||
FROM system.settings_changes | ||
WHERE version = '23.5' | ||
FORMAT Vertical | ||
``` | ||
|
||
``` text | ||
Row 1: | ||
────── | ||
version: 23.5 | ||
changes: [('input_format_parquet_preserve_order','1','0','Allow Parquet reader to reorder rows for better parallelism.'),('parallelize_output_from_storages','0','1','Allow parallelism when executing queries that read from file/url/s3/etc. This may reorder rows.'),('use_with_fill_by_sorting_prefix','0','1','Columns preceding WITH FILL columns in ORDER BY clause form sorting prefix. Rows with different values in sorting prefix are filled independently'),('output_format_parquet_compliant_nested_types','0','1','Change an internal field name in output Parquet file schema.')] | ||
``` | ||
|
||
**See also** | ||
|
||
- [Settings](../../operations/settings/index.md#session-settings-intro) | ||
- [system.settings](settings.md) |
Oops, something went wrong.