|
2 | 2 | #include <Storages/StorageReplicatedMergeTree.h> |
3 | 3 | #include <Interpreters/Context.h> |
4 | 4 | #include <Interpreters/DatabaseCatalog.h> |
5 | | -#include "Common/ZooKeeper/Types.h" |
| 5 | +#include <Common/Exception.h> |
| 6 | +#include <Common/ZooKeeper/Types.h> |
6 | 7 | #include "Storages/MergeTree/ExportPartitionUtils.h" |
7 | 8 | #include "Storages/MergeTree/MergeTreePartExportManifest.h" |
8 | 9 |
|
9 | 10 |
|
10 | 11 | namespace DB |
11 | 12 | { |
12 | 13 |
|
| 14 | +namespace ErrorCodes |
| 15 | +{ |
| 16 | + extern const int QUERY_WAS_CANCELLED; |
| 17 | + extern const int LOGICAL_ERROR; |
| 18 | +} |
| 19 | + |
13 | 20 | namespace |
14 | 21 | { |
15 | 22 | ContextPtr getContextCopyWithTaskSettings(const ContextPtr & context, const ExportReplicatedMergeTreePartitionManifest & manifest) |
@@ -210,10 +217,22 @@ void ExportPartitionTaskScheduler::handlePartExportFailure( |
210 | 217 | const std::string & part_name, |
211 | 218 | const std::filesystem::path & export_path, |
212 | 219 | const zkutil::ZooKeeperPtr & zk, |
213 | | - const String & exception, |
| 220 | + const std::optional<Exception> & exception, |
214 | 221 | size_t max_retries |
215 | 222 | ) |
216 | 223 | { |
| 224 | + if (!exception) |
| 225 | + { |
| 226 | + throw Exception(ErrorCodes::LOGICAL_ERROR, "ExportPartition scheduler task: No exception provided for error handling. Sounds like a bug"); |
| 227 | + } |
| 228 | + |
| 229 | + /// Early exit if the query was cancelled - no need to increment error counts |
| 230 | + if (exception->code() == ErrorCodes::QUERY_WAS_CANCELLED) |
| 231 | + { |
| 232 | + LOG_INFO(storage.log, "ExportPartition scheduler task: Part {} export was cancelled, skipping error handling", part_name); |
| 233 | + return; |
| 234 | + } |
| 235 | + |
217 | 236 | Coordination::Stat locked_by_stat; |
218 | 237 | std::string locked_by; |
219 | 238 |
|
@@ -274,15 +293,15 @@ void ExportPartitionTaskScheduler::handlePartExportFailure( |
274 | 293 | num_exceptions = std::stoull(num_exceptions_string.c_str()); |
275 | 294 |
|
276 | 295 | ops.emplace_back(zkutil::makeSetRequest(last_exception_path / "part", part_name, -1)); |
277 | | - ops.emplace_back(zkutil::makeSetRequest(last_exception_path / "exception", exception, -1)); |
| 296 | + ops.emplace_back(zkutil::makeSetRequest(last_exception_path / "exception", exception->message(), -1)); |
278 | 297 | } |
279 | 298 | else |
280 | 299 | { |
281 | 300 | ops.emplace_back(zkutil::makeCreateRequest(exceptions_per_replica_path, "", zkutil::CreateMode::Persistent)); |
282 | 301 | ops.emplace_back(zkutil::makeCreateRequest(count_path, "0", zkutil::CreateMode::Persistent)); |
283 | 302 | ops.emplace_back(zkutil::makeCreateRequest(last_exception_path, "", zkutil::CreateMode::Persistent)); |
284 | 303 | ops.emplace_back(zkutil::makeCreateRequest(last_exception_path / "part", part_name, zkutil::CreateMode::Persistent)); |
285 | | - ops.emplace_back(zkutil::makeCreateRequest(last_exception_path / "exception", exception, zkutil::CreateMode::Persistent)); |
| 304 | + ops.emplace_back(zkutil::makeCreateRequest(last_exception_path / "exception", exception->message(), zkutil::CreateMode::Persistent)); |
286 | 305 | } |
287 | 306 |
|
288 | 307 | num_exceptions++; |
|
0 commit comments