mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Add a test for sticking mutations bug
This commit is contained in:
parent
558f9c7630
commit
78d357f0d2
@ -552,6 +552,29 @@ void IMergeTreeDataPart::loadRowsCount()
|
||||
auto buf = openForReading(volume->getDisk(), path);
|
||||
readIntText(rows_count, *buf);
|
||||
assertEOF(*buf);
|
||||
|
||||
#ifndef NDEBUG
|
||||
/// columns have to be loaded
|
||||
for (const auto & column : getColumns())
|
||||
{
|
||||
if (column.type->isValueRepresentedByNumber())
|
||||
{
|
||||
auto size = getColumnSize(column.name, *column.type);
|
||||
|
||||
if (size.data_uncompressed == 0)
|
||||
continue;
|
||||
|
||||
size_t rows_in_column = size.data_uncompressed / column.type->getSizeOfValueInMemory();
|
||||
if (rows_in_column != rows_count)
|
||||
{
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR,
|
||||
"Column {} has rows count {} according to size in memory "
|
||||
"and size of single value, but data part {} has {} rows", backQuote(column.name), rows_in_column, name, rows_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -237,7 +237,20 @@ void MergeTreeDataPartWide::calculateEachColumnSizes(ColumnSizeByName & each_col
|
||||
ColumnSize size = getColumnSizeImpl(column.name, *column.type, &processed_substreams);
|
||||
each_columns_size[column.name] = size;
|
||||
total_size.add(size);
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (rows_count != 0 && column.type->isValueRepresentedByNumber())
|
||||
{
|
||||
size_t rows_in_column = size.data_uncompressed / column.type->getSizeOfValueInMemory();
|
||||
if (rows_in_column != rows_count)
|
||||
{
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR,
|
||||
"Column {} has rows count {} according to size in memory and size of single value, but data part {} has {} rows", backQuote(column.name), rows_in_column, name, rows_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
47
tests/queries/0_stateless/01415_sticking_mutations.sh
Executable file
47
tests/queries/0_stateless/01415_sticking_mutations.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. $CURDIR/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS sticking_mutations"
|
||||
|
||||
$CLICKHOUSE_CLIENT -n --query "CREATE TABLE sticking_mutations (
|
||||
key UInt64,
|
||||
value1 String,
|
||||
value2 UInt8
|
||||
)
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY key;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "INSERT INTO sticking_mutations SELECT number, toString(number), number % 128 FROM numbers(1000)"
|
||||
|
||||
# if merges stopped for normal merge tree mutations will stick
|
||||
$CLICKHOUSE_CLIENT --query "SYSTEM STOP MERGES sticking_mutations"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "ALTER TABLE sticking_mutations DELETE WHERE value2 % 32 == 0, MODIFY COLUMN value1 UInt64;" &
|
||||
|
||||
|
||||
##### wait mutation to start #####
|
||||
check_query="SELECT count() FROM system.mutations WHERE table='sticking_mutations' and database='$CLICKHOUSE_DATABASE'"
|
||||
|
||||
query_result=`$CLICKHOUSE_CLIENT --query="$check_query" 2>&1`
|
||||
|
||||
while [ "$query_result" == "0" ]
|
||||
do
|
||||
query_result=`$CLICKHOUSE_CLIENT --query="$check_query" 2>&1`
|
||||
sleep 0.5
|
||||
done
|
||||
##### wait mutation to start #####
|
||||
|
||||
# Starting merges to execute sticked mutations
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SYSTEM START MERGES sticking_mutations"
|
||||
|
||||
# just to be sure, that previous mutations finished
|
||||
$CLICKHOUSE_CLIENT --query "ALTER TABLE sticking_mutations DELETE WHERE value % 31 == 0 SETTINGS mutations_sync = 1"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "OPTIMIZE TABLE sticking_mutations FINAL"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SELECT 1"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS sticking_mutations"
|
Loading…
Reference in New Issue
Block a user