Repository navigation
Description
Company or project name
No response
Describe the unexpected behaviour
If I drop a named collection, all the external tables(MySQL) which use this collection are invalid. And it cause the server cannot startup.
I think the check is so strict. Just throw exception when table used.
How to reproduce
Reproduce:
CREATE NAMED COLLECTION test_collection AS host = '', port = 3306, database = '', user = '', password = '';
CREATE TABLE test_mysql
(
`a` String
)
ENGINE = MySQL(test_collection, `table` = 'test_table');
DROP NAMED COLLECTION test_collection;
Then restart clickhouse server and it can't startup.
Application: Code: 722. DB::Exception: Waited job failed: Code: 695. DB::Exception: Load job 'load table default.test_mysql' failed: Code: 669. DB::Exception: There is no named collection test_collection: Cannot attach table default.test_mysql from metadata file /Users/caoyang/tmp/store/f62/f62c3530-b3c6-4493-8285-17653441e612/test_mysql.sql from query ATTACH TABLE default.test_mysql UUID '3e2371ec-48f6-4aed-9be9-8ffac527e93a' (a String) ENGINE = MySQL(test_collection, table = 'test_table'). (NAMED_COLLECTION_DOESNT_EXIST), Stack trace (when copying this message, always include the lines below):
-
Poco::Exception::Exception(String const&, int) @ 0x000000010f491b80
-
DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000109566b64
-
DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000104dfeffc
-
DB::Exception::Exception<String const&>(int, FormatStringHelperImpl<std::type_identity<String const&>::type>, String const&) @ 0x0000000104e0e59c
-
DB::NamedCollectionFactory::get(String const&) const @ 0x000000010bf82c38
-
DB::tryGetNamedCollectionWithOverrides(absl::InlinedVector<std::shared_ptrDB::IAST, 7ul, std::allocator<std::shared_ptrDB::IAST>>, std::shared_ptr<DB::Context const>, bool, std::vector<std::pair<String, std::shared_ptrDB::IAST>, std::allocator<std::pair<String, std::shared_ptrDB::IAST>>>*) @ 0x000000010d66b400
-
DB::StorageMySQL::getConfiguration(absl::InlinedVector<std::shared_ptrDB::IAST, 7ul, std::allocator<std::shared_ptrDB::IAST>>, std::shared_ptr<DB::Context const>, DB::MySQLSettings&) @ 0x000000010d7fc688
-
std::shared_ptrDB::IStorage std::__function::__policy_invoker<std::shared_ptrDB::IStorage (DB::StorageFactory::Arguments const&)>::__call_impl<std::__function::__default_alloc_func<DB::registerStorageMySQL(DB::StorageFactory&)::$_0, std::shared_ptrDB::IStorage (DB::StorageFactory::Arguments const&)>>(std::__function::__policy_storage const*, DB::StorageFactory::Arguments const&) @ 0x000000010d7ff210
-
DB::StorageFactory::get(DB::ASTCreateQuery const&, String const&, std::shared_ptrDB::Context, std::shared_ptrDB::Context, DB::ColumnsDescription const&, DB::ConstraintsDescription const&, DB::LoadingStrictnessLevel) const @ 0x000000010d700dcc
-
DB::createTableFromAST(DB::ASTCreateQuery, String const&, String const&, std::shared_ptrDB::Context, DB::LoadingStrictnessLevel) @ 0x000000010c680cfc
-
DB::DatabaseOrdinary::loadTableFromMetadata(std::shared_ptrDB::Context, String const&, DB::QualifiedTableName const&, std::shared_ptrDB::IAST const&, DB::LoadingStrictnessLevel) @ 0x000000010c692784
-
DB::AsyncLoader::worker(DB::AsyncLoader::Pool&) @ 0x0000000109542194
-
ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::worker(std::__list_iterator<ThreadFromGlobalPoolImpl<false, true>, void*>) @ 0x0000000109638694
-
ThreadFromGlobalPoolImpl<false, true>::ThreadFromGlobalPoolImpl<void ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::scheduleImpl(std::function<void ()>, Priority, std::optional, bool)::'lambda0'()>(void&&)::'lambda'()::operator()() @ 0x000000010963e880
-
ThreadPoolImplstd::thread::worker(std::__list_iterator<std::thread, void*>) @ 0x0000000109636230
-
void* std::__thread_proxy[abi:v15007]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_deletestd::__thread_struct>, void ThreadPoolImplstd::thread::scheduleImpl(std::function<void ()>, Priority, std::optional, bool)::'lambda0'()>>(void*) @ 0x000000010963d0f4
-
_pthread_start @ 0x000000019f46ffa8
-
thread_start @ 0x000000019f46ada0
(version 24.8.1.157 (official build)). (ASYNC_LOAD_FAILED) (version 24.8.1.157 (official build)). (ASYNC_LOAD_WAIT_FAILED), Stack trace (when copying this message, always include the lines below): -
Poco::Exception::Exception(String const&, int) @ 0x000000010f491b80
-
DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000109566b64
-
DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000104dfeffc
-
DB::Exception::Exception(int, FormatStringHelperImpl<std::type_identity::type>, String&&) @ 0x0000000104dfebdc
-
DB::AsyncLoader::wait(std::shared_ptrDB::LoadJob const&, bool) @ 0x000000010953fb3c
-
DB::waitLoad(unsigned long, std::vector<std::shared_ptrDB::LoadTask, std::allocator<std::shared_ptrDB::LoadTask>> const&, bool) @ 0x0000000109814e30
-
DB::loadMetadata(std::shared_ptrDB::Context, String const&, bool) @ 0x000000010d014b9c
-
DB::Server::main(std::vector<String, std::allocator> const&) @ 0x00000001097d03d8
-
Poco::Util::Application::run() @ 0x000000010f5685fc
-
DB::Server::run() @ 0x00000001097c58c0
-
Poco::Util::ServerApplication::run(int, char**) @ 0x000000010f57a8f0
-
mainEntryClickHouseServer(int, char**) @ 0x00000001097c34e4
-
main @ 0x0000000104dfbff8
-
start @ 0x000000019f117f28
(version 24.8.1.157 (official build))
Expected behavior
No response
Error message and/or stacktrace
No response
Additional context
No response
Activity
caoyang10 commentedon Mar 12, 2025
Anyone can reply?
caoyang10 commentedon Aug 11, 2025
Also, if you create an S3 engine table and then make AK/SK/bucket invalid, the server can't startup
pamarcos commentedon Feb 3, 2026
@caoyang10 sorry it took us so long to take a look at this.
What you reported is the expected behavior for the version you used if you had an existing config file. The underlying issue is that tables were loaded synchronously at that version unless async_load_databases is set to true in the configuration.
In 23.12 #57695 the default value was changed in the config.
In 25.2 #74772 the default value was changed to true.
pamarcos commentedon Feb 5, 2026
After discussing with @nikitamikhaylov we decided to implement a safe-mechanism to ensure that whenever someone tries to DROP a named collection, we traverse all its tables using it and if any, we'll throw an exception.