|
3 | 3 | #include <DataTypes/ObjectUtils.h> |
4 | 4 | #include <Disks/SingleDiskVolume.h> |
5 | 5 | #include <IO/HashingWriteBuffer.h> |
6 | | -#include <Common/CurrentMetrics.h> |
7 | 6 | #include <Common/logger_useful.h> |
8 | 7 | #include <Common/escapeForFileName.h> |
9 | 8 | #include <Core/Settings.h> |
@@ -55,8 +54,6 @@ namespace ProfileEvents |
55 | 54 | namespace CurrentMetrics |
56 | 55 | { |
57 | 56 | extern const Metric PartMutation; |
58 | | - extern const Metric TotalMergeFailures; |
59 | | - extern const Metric NonAbortedMergeFailures; |
60 | 57 | } |
61 | 58 |
|
62 | 59 | namespace DB |
@@ -2099,50 +2096,37 @@ bool MutateTask::execute() |
2099 | 2096 | Stopwatch watch; |
2100 | 2097 | SCOPE_EXIT({ ctx->execute_elapsed_ns += watch.elapsedNanoseconds(); }); |
2101 | 2098 |
|
2102 | | - try |
| 2099 | + switch (state) |
2103 | 2100 | { |
2104 | | - switch (state) |
| 2101 | + case State::NEED_PREPARE: |
2105 | 2102 | { |
2106 | | - case State::NEED_PREPARE: |
2107 | | - { |
2108 | | - if (!prepare()) |
2109 | | - return false; |
2110 | | - |
2111 | | - state = State::NEED_EXECUTE; |
2112 | | - return true; |
2113 | | - } |
2114 | | - case State::NEED_EXECUTE: |
2115 | | - { |
2116 | | - ctx->checkOperationIsNotCanceled(); |
2117 | | - |
2118 | | - if (task->executeStep()) |
2119 | | - return true; |
2120 | | - |
2121 | | - // The `new_data_part` is a shared pointer and must be moved to allow |
2122 | | - // part deletion in case it is needed in `MutateFromLogEntryTask::finalize`. |
2123 | | - // |
2124 | | - // `tryRemovePartImmediately` requires `std::shared_ptr::unique() == true` |
2125 | | - // to delete the part timely. When there are multiple shared pointers, |
2126 | | - // only the part state is changed to `Deleting`. |
2127 | | - // |
2128 | | - // Fetching a byte-identical part (in case of checksum mismatches) will fail with |
2129 | | - // `Part ... should be deleted after previous attempt before fetch`. |
2130 | | - promise.set_value(std::move(ctx->new_data_part)); |
| 2103 | + if (!prepare()) |
2131 | 2104 | return false; |
2132 | | - } |
| 2105 | + |
| 2106 | + state = State::NEED_EXECUTE; |
| 2107 | + return true; |
2133 | 2108 | } |
2134 | | - return false; |
2135 | | - } |
2136 | | - catch (...) |
2137 | | - { |
2138 | | - const auto error_code = getCurrentExceptionCode(); |
2139 | | - if (error_code != ErrorCodes::ABORTED) |
| 2109 | + case State::NEED_EXECUTE: |
2140 | 2110 | { |
2141 | | - CurrentMetrics::add(CurrentMetrics::NonAbortedMergeFailures); |
| 2111 | + ctx->checkOperationIsNotCanceled(); |
| 2112 | + |
| 2113 | + if (task->executeStep()) |
| 2114 | + return true; |
| 2115 | + |
| 2116 | + // The `new_data_part` is a shared pointer and must be moved to allow |
| 2117 | + // part deletion in case it is needed in `MutateFromLogEntryTask::finalize`. |
| 2118 | + // |
| 2119 | + // `tryRemovePartImmediately` requires `std::shared_ptr::unique() == true` |
| 2120 | + // to delete the part timely. When there are multiple shared pointers, |
| 2121 | + // only the part state is changed to `Deleting`. |
| 2122 | + // |
| 2123 | + // Fetching a byte-identical part (in case of checksum mismatches) will fail with |
| 2124 | + // `Part ... should be deleted after previous attempt before fetch`. |
| 2125 | + promise.set_value(std::move(ctx->new_data_part)); |
| 2126 | + return false; |
2142 | 2127 | } |
2143 | | - CurrentMetrics::add(CurrentMetrics::TotalMergeFailures); |
2144 | | - throw; |
2145 | 2128 | } |
| 2129 | + return false; |
2146 | 2130 | } |
2147 | 2131 |
|
2148 | 2132 | void MutateTask::cancel() noexcept |
|
0 commit comments