mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #60883 from ClickHouse/uuid
Fix race in refreshable materialized views causing SELECT to fail sometimes
This commit is contained in:
commit
6c51b771c5
@ -193,6 +193,7 @@ StorageMaterializedView::StorageMaterializedView(
|
||||
|
||||
if (query.refresh_strategy)
|
||||
{
|
||||
fixed_uuid = false;
|
||||
refresher = RefreshTask::create(
|
||||
*this,
|
||||
getContext(),
|
||||
@ -687,10 +688,14 @@ void StorageMaterializedView::onActionLockRemove(StorageActionBlockType action_t
|
||||
refresher->start();
|
||||
}
|
||||
|
||||
DB::StorageID StorageMaterializedView::getTargetTableId() const
|
||||
StorageID StorageMaterializedView::getTargetTableId() const
|
||||
{
|
||||
std::lock_guard guard(target_table_id_mutex);
|
||||
return target_table_id;
|
||||
auto id = target_table_id;
|
||||
/// TODO: Avoid putting uuid into target_table_id in the first place, instead of clearing it here.
|
||||
if (!fixed_uuid)
|
||||
id.uuid = UUIDHelpers::Nil;
|
||||
return id;
|
||||
}
|
||||
|
||||
void StorageMaterializedView::setTargetTableId(DB::StorageID id)
|
||||
|
@ -110,6 +110,10 @@ private:
|
||||
|
||||
bool has_inner_table = false;
|
||||
|
||||
/// If false, inner table is replaced on each refresh. In that case, target_table_id doesn't
|
||||
/// have UUID, and we do inner table lookup by name instead.
|
||||
bool fixed_uuid = true;
|
||||
|
||||
friend class RefreshTask;
|
||||
|
||||
void checkStatementCanBeForwarded() const;
|
||||
|
Loading…
Reference in New Issue
Block a user