Merge pull request #54225 from Hexta/recreate-secondary-index-system-data-size

Fix system.data_skipping_indices for recreated indices
This commit is contained in:
Alexey Milovidov 2023-09-05 01:13:09 +03:00 committed by GitHub
commit a59c694e4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -4852,17 +4852,18 @@ void MergeTreeData::removePartContributionToColumnAndSecondaryIndexSizes(const D
log_subtract(total_column_size.marks, part_column_size.marks, ".marks");
}
auto indexes_descriptions = getInMemoryMetadataPtr()->secondary_indices;
for (const auto & index : indexes_descriptions)
for (auto & [secondary_index_name, total_secondary_index_size] : secondary_index_sizes)
{
IndexSize & total_secondary_index_size = secondary_index_sizes[index.name];
IndexSize part_secondary_index_size = part->getSecondaryIndexSize(index.name);
if (!part->hasSecondaryIndex(secondary_index_name))
continue;
IndexSize part_secondary_index_size = part->getSecondaryIndexSize(secondary_index_name);
auto log_subtract = [&](size_t & from, size_t value, const char * field)
{
if (value > from)
LOG_ERROR(log, "Possibly incorrect index size subtraction: {} - {} = {}, index: {}, field: {}",
from, value, from - value, index.name, field);
from, value, from - value, secondary_index_name, field);
from -= value;
};

View File

@ -1 +1,2 @@
default test_table value_index minmax minmax value 1 38 12 24
default test_table value_index minmax minmax value 1 38 12 24

View File

@ -12,4 +12,10 @@ ORDER BY key SETTINGS compress_marks=false;
INSERT INTO test_table VALUES (0, 'Value');
SELECT * FROM system.data_skipping_indices WHERE database = currentDatabase();
ALTER TABLE test_table DROP INDEX value_index;
ALTER TABLE test_table ADD INDEX value_index value TYPE minmax GRANULARITY 1;
ALTER TABLE test_table MATERIALIZE INDEX value_index SETTINGS mutations_sync=1;
SELECT * FROM system.data_skipping_indices WHERE database = currentDatabase();
DROP TABLE test_table;