mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
fix assertion in mutations with transactions
This commit is contained in:
parent
0ac33983db
commit
d6a2c631da
@ -1154,16 +1154,25 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMutate(
|
||||
}
|
||||
|
||||
TransactionID first_mutation_tid = mutations_begin_it->second.tid;
|
||||
MergeTreeTransactionPtr txn = tryGetTransactionForMutation(mutations_begin_it->second, log);
|
||||
assert(txn || first_mutation_tid.isPrehistoric());
|
||||
MergeTreeTransactionPtr txn;
|
||||
|
||||
if (txn)
|
||||
if (!first_mutation_tid.isPrehistoric())
|
||||
{
|
||||
|
||||
/// Mutate visible parts only
|
||||
/// NOTE Do not mutate visible parts in Outdated state, because it does not make sense:
|
||||
/// mutation will fail anyway due to serialization error.
|
||||
if (!part->version.isVisible(*txn))
|
||||
|
||||
/// It's possible that both mutation and transaction are already finished,
|
||||
/// because that part should not be mutated because it was not visible for that transaction.
|
||||
if (!part->version.isVisible(first_mutation_tid.start_csn, first_mutation_tid))
|
||||
continue;
|
||||
|
||||
txn = tryGetTransactionForMutation(mutations_begin_it->second, log);
|
||||
if (!txn)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot find transaction {} that has started mutation {} "
|
||||
"that is going to be applied to part {}",
|
||||
first_mutation_tid, mutations_begin_it->second.file_name, part->name);
|
||||
}
|
||||
|
||||
auto commands = std::make_shared<MutationCommands>();
|
||||
|
@ -36,3 +36,5 @@ tx14 10 22 all_1_14_2_18
|
||||
tx14 10 42 all_1_14_2_18
|
||||
tx14 10 62 all_1_14_2_18
|
||||
tx14 10 82 all_1_14_2_18
|
||||
11 2 all_2_2_0
|
||||
11 10 all_1_1_0_3
|
||||
|
@ -94,3 +94,16 @@ tx 14 "begin transaction"
|
||||
tx 14 "select 10, n, _part from mt order by n" | accept_both_parts
|
||||
|
||||
$CLICKHOUSE_CLIENT --database_atomic_wait_for_drop_and_detach_synchronously=0 -q "drop table mt"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "create table mt (n int) engine=MergeTree order by tuple()"
|
||||
$CLICKHOUSE_CLIENT --implicit_transaction=1 -q "insert into mt values (1)"
|
||||
|
||||
tx 15 "begin transaction"
|
||||
tx 16 "begin transaction"
|
||||
tx 16 "insert into mt values (2)"
|
||||
tx 15 "alter table mt update n = 10*n where 1"
|
||||
tx 15 "commit"
|
||||
tx 16 "commit"
|
||||
$CLICKHOUSE_CLIENT --implicit_transaction=1 -q "select 11, n, _part from mt order by n"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "drop table mt"
|
||||
|
Loading…
Reference in New Issue
Block a user