mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
proper tmp table cleanup
This commit is contained in:
parent
f14114dafc
commit
f1161566b4
@ -188,6 +188,11 @@ RefreshTask::ExecutionResult RefreshTask::executeRefresh()
|
||||
while (!interrupt_execution.load() && not_finished)
|
||||
not_finished = refresh_executor->executeStep(interrupt_execution);
|
||||
|
||||
auto defer = make_scope_guard([this]
|
||||
{
|
||||
canceled.store(false);
|
||||
interrupt_execution.store(false);
|
||||
});
|
||||
if (!not_finished)
|
||||
return ExecutionResult::Finished;
|
||||
if (interrupt_execution.load() && !canceled.load())
|
||||
@ -206,9 +211,6 @@ void RefreshTask::initializeRefresh(std::shared_ptr<const StorageMaterializedVie
|
||||
refresh_block = InterpreterInsertQuery(refresh_query, refresh_context).execute();
|
||||
refresh_block->pipeline.setProgressCallback([this](const Progress & progress){ progressCallback(progress); });
|
||||
|
||||
canceled.store(false);
|
||||
interrupt_execution.store(false);
|
||||
|
||||
refresh_executor.emplace(refresh_block->pipeline);
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ std::shared_ptr<ASTInsertQuery> StorageMaterializedView::prepareRefreshQuery() c
|
||||
return insert_query;
|
||||
}
|
||||
|
||||
StorageID StorageMaterializedView::exchangeTargetTable(const StorageID & fresh_table)
|
||||
StorageID StorageMaterializedView::exchangeTargetTable(StorageID fresh_table)
|
||||
{
|
||||
auto stale_table_id = getTargetTableId();
|
||||
|
||||
@ -326,7 +326,9 @@ StorageID StorageMaterializedView::exchangeTargetTable(const StorageID & fresh_t
|
||||
target_db->renameTable(
|
||||
rename_ctx, fresh_table.table_name, *db, stale_table_id.table_name, /*exchange=*/true, /*dictionary=*/false);
|
||||
|
||||
setTargetTableId(fresh_table);
|
||||
std::swap(stale_table_id.database_name, fresh_table.database_name);
|
||||
std::swap(stale_table_id.table_name, fresh_table.table_name);
|
||||
setTargetTableId(std::move(fresh_table));
|
||||
return stale_table_id;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ private:
|
||||
|
||||
StorageID createFreshTable() const;
|
||||
std::shared_ptr<ASTInsertQuery> prepareRefreshQuery() const;
|
||||
StorageID exchangeTargetTable(const StorageID & fresh_table);
|
||||
StorageID exchangeTargetTable(StorageID fresh_table);
|
||||
|
||||
StorageID getTargetTableId() const;
|
||||
void setTargetTableId(StorageID id);
|
||||
|
Loading…
Reference in New Issue
Block a user