Skip to content

Commit 932d02c

Browse files
committed
Fix possible crash in case of dictionary registration failed
It is possible that CREATE DICTIONARY will be failed with CANNOT_SCHEDULE_TASK, and in this case loader will contain dangling pointer, and on the next reload it will lead to crash.
1 parent 82b1ca0 commit 932d02c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Interpreters/ExternalLoader.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,18 @@ scope_guard ExternalLoader::addConfigRepository(std::unique_ptr<IExternalLoaderC
12901290
auto * ptr = repository.get();
12911291
String name = ptr->getName();
12921292

1293-
config_files_reader->addConfigRepository(std::move(repository));
1294-
reloadConfig(name);
1293+
/// Avoid leaving dangling repository in case of reloadConfig() fails
1294+
/// (it can be possible in case of CANNOT_SCHEDULE_TASK)
1295+
try
1296+
{
1297+
config_files_reader->addConfigRepository(std::move(repository));
1298+
reloadConfig(name);
1299+
}
1300+
catch (...)
1301+
{
1302+
config_files_reader->removeConfigRepository(ptr);
1303+
throw;
1304+
}
12951305

12961306
return [this, ptr, name]()
12971307
{

0 commit comments

Comments
 (0)