mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Merge pull request #39477 from azat/fix-mv-drop-race
Fix LOGICAL_ERROR on race between DROP and INSERT with materialized views
This commit is contained in:
commit
0005c37acc
@ -410,6 +410,14 @@ Chain buildPushingToViewsChain(
|
||||
if (result_chain.empty())
|
||||
result_chain.addSink(std::make_shared<NullSinkToStorage>(storage_header));
|
||||
|
||||
if (result_chain.getOutputHeader().columns() != 0)
|
||||
{
|
||||
/// Convert result header to empty block.
|
||||
auto dag = ActionsDAG::makeConvertingActions(result_chain.getOutputHeader().getColumnsWithTypeAndName(), {}, ActionsDAG::MatchColumnsMode::Name);
|
||||
auto actions = std::make_shared<ExpressionActions>(std::move(dag));
|
||||
result_chain.addSink(std::make_shared<ConvertingTransform>(result_chain.getOutputHeader(), std::move(actions)));
|
||||
}
|
||||
|
||||
return result_chain;
|
||||
}
|
||||
|
||||
|
26
tests/queries/0_stateless/02380_insert_mv_race.sh
Executable file
26
tests/queries/0_stateless/02380_insert_mv_race.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: long, race
|
||||
|
||||
# Regression test for INSERT into table with MV attached,
|
||||
# to avoid possible errors if some table will disappears,
|
||||
# in case of multiple streams was used (i.e. max_insert_threads>1)
|
||||
|
||||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT -nm -q "
|
||||
DROP TABLE IF EXISTS null;
|
||||
CREATE TABLE null (key Int) ENGINE = Null;
|
||||
DROP TABLE IF EXISTS mv;
|
||||
CREATE MATERIALIZED VIEW mv ENGINE = Null() AS SELECT * FROM null;
|
||||
"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "INSERT INTO null SELECT * FROM numbers_mt(1000) settings max_threads=1000, max_insert_threads=1000, max_block_size=1" |& {
|
||||
# To avoid handling stacktrace here, get only first line (-m1)
|
||||
# this should be OK, since you cannot have multiple exceptions from the client anyway.
|
||||
grep -m1 -F 'DB::Exception:' | grep -F -v -e 'UNKNOWN_TABLE'
|
||||
} &
|
||||
sleep 0.05
|
||||
$CLICKHOUSE_CLIENT -q "DETACH TABLE mv"
|
||||
wait
|
Loading…
Reference in New Issue
Block a user