mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
make separate functions
This commit is contained in:
parent
0354312294
commit
4108a235f5
@ -571,17 +571,8 @@ void DatabaseAtomic::renameDictionaryInMemoryUnlocked(const StorageID & old_name
|
|||||||
const auto & dict = dynamic_cast<const IDictionary &>(*result.object);
|
const auto & dict = dynamic_cast<const IDictionary &>(*result.object);
|
||||||
dict.updateDictionaryName(new_name);
|
dict.updateDictionaryName(new_name);
|
||||||
}
|
}
|
||||||
void DatabaseAtomic::waitDetachedTableNotInUseOrThrow(const UUID & uuid, bool throw_if_in_use)
|
void DatabaseAtomic::waitDetachedTableNotInUse(const UUID & uuid)
|
||||||
{
|
{
|
||||||
if (throw_if_in_use)
|
|
||||||
{
|
|
||||||
DetachedTables not_in_use;
|
|
||||||
std::lock_guard lock{mutex};
|
|
||||||
not_in_use = cleanupDetachedTables();
|
|
||||||
assertDetachedTableNotInUse(uuid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Table is in use while its shared_ptr counter is greater than 1.
|
/// Table is in use while its shared_ptr counter is greater than 1.
|
||||||
/// We cannot trigger condvar on shared_ptr destruction, so it's busy wait.
|
/// We cannot trigger condvar on shared_ptr destruction, so it's busy wait.
|
||||||
while (true)
|
while (true)
|
||||||
@ -597,5 +588,13 @@ void DatabaseAtomic::waitDetachedTableNotInUseOrThrow(const UUID & uuid, bool th
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseAtomic::checkDetachedTableNotInUse(const UUID & uuid)
|
||||||
|
{
|
||||||
|
DetachedTables not_in_use;
|
||||||
|
std::lock_guard lock{mutex};
|
||||||
|
not_in_use = cleanupDetachedTables();
|
||||||
|
assertDetachedTableNotInUse(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,8 @@ public:
|
|||||||
void tryCreateSymlink(const String & table_name, const String & actual_data_path, bool if_data_path_exist = false);
|
void tryCreateSymlink(const String & table_name, const String & actual_data_path, bool if_data_path_exist = false);
|
||||||
void tryRemoveSymlink(const String & table_name);
|
void tryRemoveSymlink(const String & table_name);
|
||||||
|
|
||||||
void waitDetachedTableNotInUseOrThrow(const UUID & uuid, bool throw_if_in_use) override;
|
void waitDetachedTableNotInUse(const UUID & uuid) override;
|
||||||
|
void checkDetachedTableNotInUse(const UUID & uuid) override;
|
||||||
void setDetachedTableNotInUseForce(const UUID & uuid);
|
void setDetachedTableNotInUseForce(const UUID & uuid);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -345,7 +345,8 @@ public:
|
|||||||
|
|
||||||
virtual void assertCanBeDetached(bool /*cleanup*/) {}
|
virtual void assertCanBeDetached(bool /*cleanup*/) {}
|
||||||
|
|
||||||
virtual void waitDetachedTableNotInUseOrThrow(const UUID & /*uuid*/, bool /*throw_if_in_use*/) { }
|
virtual void waitDetachedTableNotInUse(const UUID & /*uuid*/) { }
|
||||||
|
virtual void checkDetachedTableNotInUse(const UUID & /*uuid*/) { }
|
||||||
|
|
||||||
/// Ask all tables to complete the background threads they are using and delete all table objects.
|
/// Ask all tables to complete the background threads they are using and delete all table objects.
|
||||||
virtual void shutdown() = 0;
|
virtual void shutdown() = 0;
|
||||||
|
@ -1003,7 +1003,10 @@ bool InterpreterCreateQuery::doCreateTable(ASTCreateQuery & create,
|
|||||||
/// so we allow waiting here. If database_atomic_wait_for_drop_and_detach_synchronously is disabled
|
/// so we allow waiting here. If database_atomic_wait_for_drop_and_detach_synchronously is disabled
|
||||||
/// and old storage instance still exists it will throw exception.
|
/// and old storage instance still exists it will throw exception.
|
||||||
bool throw_if_table_in_use = getContext()->getSettingsRef().database_atomic_wait_for_drop_and_detach_synchronously;
|
bool throw_if_table_in_use = getContext()->getSettingsRef().database_atomic_wait_for_drop_and_detach_synchronously;
|
||||||
database->waitDetachedTableNotInUseOrThrow(create.uuid, throw_if_table_in_use);
|
if (throw_if_table_in_use)
|
||||||
|
database->checkDetachedTableNotInUse(create.uuid);
|
||||||
|
else
|
||||||
|
database->waitDetachedTableNotInUse(create.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
StoragePtr res;
|
StoragePtr res;
|
||||||
|
@ -81,7 +81,7 @@ void InterpreterDropQuery::waitForTableToBeActuallyDroppedOrDetached(const ASTDr
|
|||||||
if (query.kind == ASTDropQuery::Kind::Drop)
|
if (query.kind == ASTDropQuery::Kind::Drop)
|
||||||
DatabaseCatalog::instance().waitTableFinallyDropped(uuid_to_wait);
|
DatabaseCatalog::instance().waitTableFinallyDropped(uuid_to_wait);
|
||||||
else if (query.kind == ASTDropQuery::Kind::Detach)
|
else if (query.kind == ASTDropQuery::Kind::Detach)
|
||||||
db->waitDetachedTableNotInUseOrThrow(uuid_to_wait, false);
|
db->waitDetachedTableNotInUse(uuid_to_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockIO InterpreterDropQuery::executeToTable(ASTDropQuery & query)
|
BlockIO InterpreterDropQuery::executeToTable(ASTDropQuery & query)
|
||||||
|
Loading…
Reference in New Issue
Block a user