From 19458a0c61b9477e8cad28ac1c3f9bd4e01afa5e Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 27 Aug 2021 10:02:45 +0300 Subject: [PATCH] Fix removing of parts in a Temporary state Parts in a temporary state is not exists in data_parts_by_info, so do not try to search there and throw LOGICAL_ERROR in case of failure:
``` 02:45:49.037546 [ 5890 ] {} test_iy9rta.concurrent_kill_4 (526aa7c8-db2a-4f0e-926a-a7c8db2a9f0e): Code: 40. DB::Exception: Part all_0_0_0_1 from r11 has different columns hash. (CHECKSUM_DOESNT_MATCH) (version 21.10.1.7910 (official build)). Data after mutation is not byte-identical to data on another replicas. We will download merged part from replica to force byte-identical result. 02:45:49.049422 [ 5890 ] {} test_iy9rta.concurrent_kill_4 (526aa7c8-db2a-4f0e-926a-a7c8db2a9f0e): Trying to immediately remove part all_0_0_0_1 (state Temporary) 02:45:49.060210 [ 5890 ] {} : Logical error: 'Part all_0_0_0_1 doesn't exist'. 02:47:01.572508 [ 29208 ] {} BaseDaemon: (version 21.10.1.7910 (official build), build id: 9309CECED9A0D32CBB00BB8EC77B91456679868E) (from thread 5890) (no query) Received signal Aborted (6) ... 02:47:06.815000 [ 29208 ] {} BaseDaemon: 8. ./obj-x86_64-linux-gnu/../src/Storages/MergeTree/MergeTreeData.cpp:2593: DB::MergeTreeData::tryRemovePartImmediately(std::__1::shared_ptr&&) @ 0x1f959e0d in /usr/bin/clickhouse 02:47:06.816309 [ 29209 ] {} BaseDaemon: 8. ./obj-x86_64-linux-gnu/../src/Storages/MergeTree/MergeTreeData.cpp:2593: DB::MergeTreeData::tryRemovePartImmediately(std::__1::shared_ptr&&) @ 0x1f959e0d in /usr/bin/clickhouse 02:47:09.455665 [ 29208 ] {} BaseDaemon: 9. ./obj-x86_64-linux-gnu/../src/Storages/StorageReplicatedMergeTree.cpp:1939: DB::StorageReplicatedMergeTree::tryExecutePartMutation(DB::ReplicatedMergeTreeLogEntry const&) @ 0x1f5f2bf6 in /usr/bin/clickhouse 02:47:09.468738 [ 29209 ] {} BaseDaemon: 9. ./obj-x86_64-linux-gnu/../src/Storages/StorageReplicatedMergeTree.cpp:1939: DB::StorageReplicatedMergeTree::tryExecutePartMutation(DB::ReplicatedMergeTreeLogEntry const&) @ 0x1f5f2bf6 in /usr/bin/clickhouse 02:47:11.776857 [ 29208 ] {} BaseDaemon: 10. ./obj-x86_64-linux-gnu/../src/Storages/StorageReplicatedMergeTree.cpp:1581: DB::StorageReplicatedMergeTree::executeLogEntry(DB::ReplicatedMergeTreeLogEntry&) @ 0x1f5e484c in /usr/bin/clickhouse 02:47:11.904232 [ 29209 ] {} BaseDaemon: 10. ./obj-x86_64-linux-gnu/../src/Storages/StorageReplicatedMergeTree.cpp:1581: DB::StorageReplicatedMergeTree::executeLogEntry(DB::ReplicatedMergeTreeLogEntry&) @ 0x1f5e484c in /usr/bin/clickhouse 02:47:13.941811 [ 29208 ] {} BaseDaemon: 11. ./obj-x86_64-linux-gnu/../src/Storages/StorageReplicatedMergeTree.cpp:3176: DB::StorageReplicatedMergeTree::processQueueEntry(std::__1::shared_ptr)::$_18::operator() shared_ptr&) const @ 0x1f65faa5 in /usr/bin/clickhouse 02:47:14.477158 [ 29209 ] {} BaseDaemon: 11. ./obj-x86_64-linux-gnu/../src/Storages/StorageReplicatedMergeTree.cpp:3176: DB::StorageReplicatedMergeTree::processQueueEntry(std::__1::shared_ptr)::$_18::operator() shared_ptr&) const @ 0x1f65faa5 in /usr/bin/clickhouse 02:47:16.475373 [ 29208 ] {} BaseDaemon: 12. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3676: decltype(std::__1::forward))(std::__1::forward&>(fp0))) std::__1::__invoke)::$_18&, std::__1::shared_ptr&>(DB::StorageReplicatedMergeTree::processQueueEntry(std::__1::shared_ptr)::$_18&, std::__1::shared_ptr&) @ 0x1f65fa32 in /usr/bin/clickhouse 02:47:16.970325 [ 29209 ] {} BaseDaemon: 12. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3676: decltype(std::__1::forward))(std::__1::forward&>(fp0))) std::__1::__invoke)::$_18&, std::__1::shared_ptr&>(DB::StorageReplicatedMergeTree::processQueueEntry(std::__1::shared_ptr)::$_18&, std::__1::shared_ptr&) @ 0x1f65fa32 in /usr/bin/clickhouse 02:47:18.979481 [ 29208 ] {} BaseDaemon: 13. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/__functional_base:317: bool std::__1::__invoke_void_return_wrapper::__call)::$_18&, std::__1::shared_ptr&>(DB::StorageReplicatedMergeTree::processQueueEntry(std::__1::shared_ptr)::$_18&, std::__1::shared_ptr BaseDaemon: 13. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/__functional_base:317: bool std::__1::__invoke_void_return_wrapper::__call)::$_18&, std::__1::shared_ptr&>(DB::StorageReplicatedMergeTree::processQueueEntry(std::__1::shared_ptr)::$_18&, std::__1::shared_ptr BaseDaemon: 14. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1608: std::__1::__function::__default_alloc_func)::$_18, bool (std::__1::shared_ptr&)>::operator()(std::__1::shared_ptr&) @ 0x1f65f9b0 in /usr/bin/clickhouse 02:47:23.546946 [ 413 ] {} Application: Child process was terminated by signal 6. ```
CI: https://clickhouse-test-reports.s3.yandex.net/0/4a8b82232c11512232df3ecdf4ffaec287116ad5/stress_test_(debug).html#fail1 --- src/Storages/MergeTree/MergeTreeData.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index 764f5d7adf7..86cbd9f1484 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -2588,17 +2588,25 @@ void MergeTreeData::tryRemovePartImmediately(DataPartPtr && part) LOG_TRACE(log, "Trying to immediately remove part {}", part->getNameWithState()); - auto it = data_parts_by_info.find(part->info); - if (it == data_parts_by_info.end() || (*it).get() != part.get()) - throw Exception("Part " + part->name + " doesn't exist", ErrorCodes::LOGICAL_ERROR); + if (part->getState() != DataPartState::Temporary) + { + auto it = data_parts_by_info.find(part->info); + if (it == data_parts_by_info.end() || (*it).get() != part.get()) + throw Exception("Part " + part->name + " doesn't exist", ErrorCodes::LOGICAL_ERROR); - part.reset(); + part.reset(); - if (!((*it)->getState() == DataPartState::Outdated && it->unique())) - return; + if (!((*it)->getState() == DataPartState::Outdated && it->unique())) + return; - modifyPartState(it, DataPartState::Deleting); - part_to_delete = *it; + modifyPartState(it, DataPartState::Deleting); + + part_to_delete = *it; + } + else + { + part_to_delete = std::move(part); + } } try