mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #24321 from amosbird/fixdroppartition
Fix drop partition in rare case
This commit is contained in:
commit
84f9d38620
@ -302,7 +302,7 @@ Block InterpreterKillQueryQuery::getSelectResult(const String & columns, const S
|
||||
if (where_expression)
|
||||
select_query += " WHERE " + queryToString(where_expression);
|
||||
|
||||
auto stream = executeQuery(select_query, getContext()->getGlobalContext(), true).getInputStream();
|
||||
auto stream = executeQuery(select_query, getContext(), true).getInputStream();
|
||||
Block res = stream->read();
|
||||
|
||||
if (res && stream->read())
|
||||
|
@ -268,8 +268,7 @@ void ReplicatedMergeTreeQueue::removeCoveredPartsFromMutations(const String & pa
|
||||
|
||||
bool some_mutations_are_probably_done = false;
|
||||
|
||||
auto from_it = in_partition->second.lower_bound(part_info.getDataVersion());
|
||||
for (auto it = from_it; it != in_partition->second.end(); ++it)
|
||||
for (auto it = in_partition->second.begin(); it != in_partition->second.end(); ++it)
|
||||
{
|
||||
MutationStatus & status = *it->second;
|
||||
|
||||
|
@ -4999,7 +4999,10 @@ bool StorageReplicatedMergeTree::getFakePartCoveringAllPartsInPartition(const St
|
||||
auto zookeeper = getZooKeeper();
|
||||
delimiting_block_lock = allocateBlockNumber(partition_id, zookeeper);
|
||||
right = delimiting_block_lock->getNumber();
|
||||
mutation_version = queue.getCurrentMutationVersion(partition_id, right);
|
||||
/// Make sure we cover all parts in drop range.
|
||||
/// There might be parts with mutation version greater than current block number
|
||||
/// if some part mutation has been assigned after block number allocation, but before creation of DROP_RANGE entry.
|
||||
mutation_version = MergeTreePartInfo::MAX_BLOCK_NUMBER;
|
||||
}
|
||||
|
||||
if (for_replace_range)
|
||||
|
@ -0,0 +1,7 @@
|
||||
waiting default rmt 0000000002 UPDATE m = m * toInt8(s) WHERE n = 3
|
||||
1 4 2
|
||||
2 15 5
|
||||
3 7 fail
|
||||
4 11 13
|
||||
0000000000 UPDATE m = m * toInt8(s) WHERE 1 [] 0 1
|
||||
0000000001 UPDATE m = m * toInt8(s) WHERE 1 [] 0 1
|
34
tests/queries/0_stateless/01155_old_mutation_parts_to_do.sh
Executable file
34
tests/queries/0_stateless/01155_old_mutation_parts_to_do.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
# shellcheck source=./mergetree_mutations.lib
|
||||
. "$CURDIR"/mergetree_mutations.lib
|
||||
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "drop table if exists rmt;"
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "create table rmt (n int, m int, s String) engine=ReplicatedMergeTree('/test/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/rmt', '1')
|
||||
order by n settings max_replicated_mutations_in_queue=0;"
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "insert into rmt values (1, 1, '2');" # 0_0_0_0
|
||||
${CLICKHOUSE_CLIENT} --mutations_sync=0 -q "alter table rmt update m = m*toInt8(s) where 1;" # 0000000000
|
||||
${CLICKHOUSE_CLIENT} -q "insert into rmt values (2, 3, '5');" # 0_2_2_0
|
||||
${CLICKHOUSE_CLIENT} --mutations_sync=0 -q "alter table rmt update m = m*toInt8(s) where 1;" # 0000000001
|
||||
${CLICKHOUSE_CLIENT} -q "insert into rmt values (3, 7, 'fail');" # 0_4_4_0
|
||||
${CLICKHOUSE_CLIENT} --mutations_sync=0 -q "alter table rmt update m = m*toInt8(s) where n=3;" # 0000000002, will fail to mutate 0_4_4_0 to 0_4_4_0_5
|
||||
${CLICKHOUSE_CLIENT} -q "insert into rmt values (4, 11, '13');" # 0_6_6_0
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "alter table rmt modify setting max_replicated_mutations_in_queue=1;"
|
||||
sleep 5 # test does not rely on this, but it may help to reproduce a bug
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "kill mutation where database=currentDatabase() and table='rmt' and mutation_id='0000000002'";
|
||||
${CLICKHOUSE_CLIENT} -q "system sync replica rmt;"
|
||||
|
||||
# now check that mutations 0 and 1 are finished
|
||||
wait_for_mutation "rmt" "0000000001"
|
||||
${CLICKHOUSE_CLIENT} -q "select * from rmt order by n;"
|
||||
${CLICKHOUSE_CLIENT} -q "select mutation_id, command, parts_to_do_names, parts_to_do, is_done from system.mutations where database=currentDatabase() and table='rmt';"
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "drop table rmt;"
|
@ -1,4 +1,5 @@
|
||||
42
|
||||
Hello
|
||||
waiting default mutation_table mutation_3.txt MODIFY COLUMN `value` UInt64
|
||||
42
|
||||
Hello
|
||||
|
Loading…
Reference in New Issue
Block a user