From 211cea5e7c99119777d387a6b5331e4703e24510 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 9 Apr 2023 22:50:21 +0200 Subject: [PATCH] Fix uncaught exception in case of parallel loader for hashed dictionaries Since ThreadPool::wait() rethrows the first exception (if any):
stacktrace 2023.04.09 12:53:33.629333 [ 22361 ] {} BaseDaemon: (version 22.13.1.1, build id: 5FB01DCAAFFF19F0A9A61E253567F90685989D2F) (from thread 23032) Terminate called for uncaught exception: 2023.04.09 12:53:33.630179 [ 23645 ] {} BaseDaemon: 2023.04.09 12:53:33.630213 [ 23645 ] {} BaseDaemon: Stack trace: 0x7f68b00baccc 0x7f68b006bef2 0x7f68b0056472 0x112a42fe 0x1c17f2a3 0x1c17f238 0xbf4bc3b 0x13961c6d 0x138ee529 0x138ed6bc 0x138dd2f0 0x138dd9c6 0x1571d0dd 0x16197c1f 0x161a231e 0x1619fc93 0x161a51b9 0x11151759 0x1115454e 0x7f68b00b8fd4 0x7f68b013966c 2023.04.09 12:53:33.630247 [ 23645 ] {} BaseDaemon: 3. ? @ 0x7f68b00baccc in ? 2023.04.09 12:53:33.630263 [ 23645 ] {} BaseDaemon: 4. gsignal @ 0x7f68b006bef2 in ? 2023.04.09 12:53:33.630273 [ 23645 ] {} BaseDaemon: 5. abort @ 0x7f68b0056472 in ? 2023.04.09 12:53:33.648815 [ 23645 ] {} BaseDaemon: 6. ./.build/./src/Daemon/BaseDaemon.cpp:456: terminate_handler() @ 0x112a42fe in /usr/lib/debug/usr/bin/clickhouse.debug 2023.04.09 12:53:33.651484 [ 23645 ] {} BaseDaemon: 7. ./.build/./contrib/llvm-project/libcxxabi/src/cxa_handlers.cpp:61: std::__terminate(void (*)()) @ 0x1c17f2a3 in /usr/lib/debug/usr/bin/clickhouse.debug 2023.04.09 12:53:33.654080 [ 23645 ] {} BaseDaemon: 8. ./.build/./contrib/llvm-project/libcxxabi/src/cxa_handlers.cpp:79: std::terminate() @ 0x1c17f238 in /usr/lib/debug/usr/bin/clickhouse.debug 2023.04.09 12:53:35.025565 [ 23645 ] {} BaseDaemon: 9. ? @ 0xbf4bc3b in /usr/lib/debug/usr/bin/clickhouse.debug 2023.04.09 12:53:36.495557 [ 23645 ] {} BaseDaemon: 10. DB::ParallelDictionaryLoader<(DB::DictionaryKeyType)0, true, true>::~ParallelDictionaryLoader() @ 0x13961c6d in /usr/lib/debug/usr/bin/clickhouse.debug 2023.04.09 12:53:37.833142 [ 23645 ] {} BaseDaemon: 11. DB::HashedDictionary<(DB::DictionaryKeyType)0, true, true>::loadData() @ 0x138ee529 in /usr/lib/debug/usr/bin/clickhouse.debug 2023.04.09 12:53:39.124989 [ 23645 ] {} BaseDaemon: 12. DB::HashedDictionary<(DB::DictionaryKeyType)0, true, true>::HashedDictionary(DB::StorageID const&, DB::DictionaryStructure const&, std::__1::shared_ptr, DB::HashedDictionaryStorageConfiguration const&, std::__1::shared_ptr) @ 0x138ed6bc in /usr/lib/debug/usr/bin/clickhouse.debug
Signed-off-by: Azat Khuzhin --- src/Dictionaries/HashedDictionary.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Dictionaries/HashedDictionary.cpp b/src/Dictionaries/HashedDictionary.cpp index 0e5d18363e9..5cfac20e572 100644 --- a/src/Dictionaries/HashedDictionary.cpp +++ b/src/Dictionaries/HashedDictionary.cpp @@ -114,9 +114,18 @@ public: ~ParallelDictionaryLoader() { - for (auto & queue : shards_queues) - queue->clearAndFinish(); - pool.wait(); + try + { + for (auto & queue : shards_queues) + queue->clearAndFinish(); + + /// NOTE: It is OK to not pass the exception next, since on success finish() should be called which will call wait() + pool.wait(); + } + catch (...) + { + tryLogCurrentException(dictionary.log, "Exception had been thrown during parallel load of the dictionary"); + } } private: