From d2d8c179b683f89c96608dec78eb8fef646db838 Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Tue, 13 Sep 2022 13:16:18 +0200 Subject: [PATCH] Add unreserved_space column to system.disks --- docs/en/operations/system-tables/disks.md | 1 + docs/ru/operations/system-tables/disks.md | 1 + src/Storages/System/StorageSystemDisks.cpp | 4 ++++ .../0_stateless/02117_show_create_table_system.reference | 1 + 4 files changed, 7 insertions(+) diff --git a/docs/en/operations/system-tables/disks.md b/docs/en/operations/system-tables/disks.md index 1106562da53..f4c71eb1cd2 100644 --- a/docs/en/operations/system-tables/disks.md +++ b/docs/en/operations/system-tables/disks.md @@ -11,6 +11,7 @@ Columns: - `path` ([String](../../sql-reference/data-types/string.md)) — Path to the mount point in the file system. - `free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Free space on disk in bytes. - `total_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Disk volume in bytes. +- `unreserved_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Free space which is not taken by reservations (`free_space` minus the size of reservations taken by merges, inserts, and other disk write operations currently running). - `keep_free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Amount of disk space that should stay free on disk in bytes. Defined in the `keep_free_space_bytes` parameter of disk configuration. **Example** diff --git a/docs/ru/operations/system-tables/disks.md b/docs/ru/operations/system-tables/disks.md index fc4c370cc1a..1d540b277d1 100644 --- a/docs/ru/operations/system-tables/disks.md +++ b/docs/ru/operations/system-tables/disks.md @@ -11,5 +11,6 @@ Cодержит информацию о дисках, заданных в [ко - `path` ([String](../../sql-reference/data-types/string.md)) — путь к точке монтирования в файловой системе. - `free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — свободное место на диске в байтах. - `total_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — объём диска в байтах. +- `unreserved_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — не зарезервированное cвободное место в байтах (`free_space` минус размер места, зарезервированного на выполняемые в данный момент фоновые слияния, вставки и другие операции записи на диск). - `keep_free_space` ([UInt64](../../sql-reference/data-types/int-uint.md)) — место, которое должно остаться свободным на диске в байтах. Задаётся значением параметра `keep_free_space_bytes` конфигурации дисков. diff --git a/src/Storages/System/StorageSystemDisks.cpp b/src/Storages/System/StorageSystemDisks.cpp index ef2c695d6b7..6b50b00dc30 100644 --- a/src/Storages/System/StorageSystemDisks.cpp +++ b/src/Storages/System/StorageSystemDisks.cpp @@ -21,6 +21,7 @@ StorageSystemDisks::StorageSystemDisks(const StorageID & table_id_) {"path", std::make_shared()}, {"free_space", std::make_shared()}, {"total_space", std::make_shared()}, + {"unreserved_space", std::make_shared()}, {"keep_free_space", std::make_shared()}, {"type", std::make_shared()}, {"is_encrypted", std::make_shared()}, @@ -44,6 +45,7 @@ Pipe StorageSystemDisks::read( MutableColumnPtr col_path = ColumnString::create(); MutableColumnPtr col_free = ColumnUInt64::create(); MutableColumnPtr col_total = ColumnUInt64::create(); + MutableColumnPtr col_unreserved = ColumnUInt64::create(); MutableColumnPtr col_keep = ColumnUInt64::create(); MutableColumnPtr col_type = ColumnString::create(); MutableColumnPtr col_is_encrypted = ColumnUInt8::create(); @@ -55,6 +57,7 @@ Pipe StorageSystemDisks::read( col_path->insert(disk_ptr->getPath()); col_free->insert(disk_ptr->getAvailableSpace()); col_total->insert(disk_ptr->getTotalSpace()); + col_unreserved->insert(disk_ptr->getUnreservedSpace()); col_keep->insert(disk_ptr->getKeepingFreeSpace()); auto data_source_description = disk_ptr->getDataSourceDescription(); col_type->insert(toString(data_source_description.type)); @@ -72,6 +75,7 @@ Pipe StorageSystemDisks::read( res_columns.emplace_back(std::move(col_path)); res_columns.emplace_back(std::move(col_free)); res_columns.emplace_back(std::move(col_total)); + res_columns.emplace_back(std::move(col_unreserved)); res_columns.emplace_back(std::move(col_keep)); res_columns.emplace_back(std::move(col_type)); res_columns.emplace_back(std::move(col_is_encrypted)); diff --git a/tests/queries/0_stateless/02117_show_create_table_system.reference b/tests/queries/0_stateless/02117_show_create_table_system.reference index 9e2f676bb55..a7b4725ac57 100644 --- a/tests/queries/0_stateless/02117_show_create_table_system.reference +++ b/tests/queries/0_stateless/02117_show_create_table_system.reference @@ -184,6 +184,7 @@ CREATE TABLE system.disks `path` String, `free_space` UInt64, `total_space` UInt64, + `unreserved_space` UInt64, `keep_free_space` UInt64, `type` String, `is_encrypted` UInt8,