1.概述
clickhouse 报错如下
SQL 错误 [1002]: ClickHouse exception, code: 1002, host: localhost, port: 8123; Code: 84. DB::Exception: Directory /var/lib/clickhouse/data/quant/trade_record/tmp_merge_2012_210_215_1/ already exists. (DIRECTORY_ALREADY_EXISTS) (version 21.11.4.14 (official build))
后台merge的时候报错这个怎么办?一直报这个
怀疑是 断电了 或者重启了 导致合成成功了 但是删除没成功
异常栈如下
2021.11.29 05:44:38.294340 [ 71 ] {} <Error> void DB::MergeTreeBackgroundExecutor<DB::MergeMutateRuntimeQueue>::routine(DB::TaskRuntimeDataPtr) [Queue = DB::MergeMutateRuntimeQueue]: Code: 84. DB::Exception: Directory /var/lib/clickhouse/data/quant/price_1m/tmp_merge_201403_3_45_1/ already exists. (DIRECTORY_ALREADY_EXISTS), Stack trace (when copying this message, always include the lines below):
0. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x9b605d4 in /usr/bin/clickhouse
1. DB::MergeTask::ExecuteAndFinalizeHorizontalPart::prepare() @ 0x12d388fc in /usr/bin/clickhouse
2. bool std::__1::__function::__policy_invoker<bool ()>::__call_impl<std::__1::__function::__default_alloc_func<DB::MergeTask::ExecuteAndFinalizeHorizontalPart::subtasks::'lambda'(), bool ()> >(std::__1::__function::__policy_storage const*) @ 0x12d45c89 in /usr/bin/clickhouse
3. DB::MergeTask::ExecuteAndFinalizeHorizontalPart::execute() @ 0x12d3c90b in /usr/bin/clickhouse
4. DB::MergeTask::execute() @ 0x12d415fa in /usr/bin/clickhouse
5. DB::MergePlainMergeTreeTask::executeStep() @ 0x12fbc4ac in /usr/bin/clickhouse
6. DB::MergeTreeBackgroundExecutor<DB::MergeMutateRuntimeQueue>::routine(std::__1::shared_ptr<DB::TaskRuntimeData>) @ 0x12d5005d in /usr/bin/clickhouse
7. DB::MergeTreeBackgroundExecutor<DB::MergeMutateRuntimeQueue>::threadFunction() @ 0x12d50afa in /usr/bin/clickhouse
8. ThreadPoolImpl<ThreadFromGlobalPool>::worker(std::__1::__list_iterator<ThreadFromGlobalPool, void*>) @ 0x9ba528a in /usr/bin/clickhouse
9. ThreadFromGlobalPool::ThreadFromGlobalPool<void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()>(void&&, void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()&&...)::'lambda'()::operator()() @ 0x9ba70a7 in /usr/bin/clickhouse
10. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x9ba2697 in /usr/bin/clickhouse
11. ? @ 0x9ba609d in /usr/bin/clickhouse
12. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
13. clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
(version 21.11.4.14 (official build))
这个错误提示是因为目录/var/lib/clickhouse/data/quant/trade_record/tmp_merge_2012_210_215_1/
已经存在,导致合并操作无法继续进行。可能的原因是在之前执行的合并操作中出现了异常,未能成功删除该目录。
解决方法如下:
-
首先,确认是否有其他进程正在使用ClickHouse,如果有,请等待其他操作完成后再尝试。
-
进入ClickHouse的数据存储目录/var/lib/clickhouse/data/quant/trade_record/,查看是否有名为tmp_merge_2012_210_215_1的目录。如果存在,可以尝试手动删除该目录。
-
如果无法删除该目录,可以尝试重启ClickHouse服务,然后再次尝试删除该目录。
-
如果仍然无法解决问题,建议备份数据后,卸载并重新安装ClickHouse,然后将备份数据恢复到新安装的ClickHouse中。