diff --git a/be/src/common/exception.h b/be/src/common/exception.h index a702bc501c4cbd..a684b1f19092fc 100644 --- a/be/src/common/exception.h +++ b/be/src/common/exception.h @@ -154,26 +154,3 @@ inline const std::string& Exception::to_string() const { return Status::Error(e.code(), e.to_string()); \ } \ } while (0); - -#define HANDLE_ERROR_IF_CATCH_EXCEPTION_OR_RETURN_ERROR(stmt, handle_error) \ - do { \ - try { \ - doris::enable_thread_catch_bad_alloc++; \ - Defer defer {[&]() { doris::enable_thread_catch_bad_alloc--; }}; \ - { \ - Status _status_ = (stmt); \ - if (UNLIKELY(!_status_.ok())) { \ - handle_error(); \ - return _status_; \ - } \ - } \ - } catch (const doris::Exception& e) { \ - handle_error(); \ - if (e.code() == doris::ErrorCode::MEM_ALLOC_FAILED) { \ - return Status::MemoryLimitExceeded(fmt::format( \ - "PreCatch error code:{}, {}, __FILE__:{}, __LINE__:{}, __FUNCTION__:{}", \ - e.code(), e.to_string(), __FILE__, __LINE__, __PRETTY_FUNCTION__)); \ - } \ - return Status::Error(e.code(), e.to_string()); \ - } \ - } while (0); diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp index 089363f450ec0b..8dc49b215bc32a 100644 --- a/be/src/olap/compaction.cpp +++ b/be/src/olap/compaction.cpp @@ -400,15 +400,14 @@ Status CompactionMixin::execute_compact() { data_dir->disks_compaction_score_increment(permits); data_dir->disks_compaction_num_increment(1); - auto record_compaction_stats = [&]() { + auto record_compaction_stats = [&](const doris::Exception& ex) { _tablet->compaction_count.fetch_add(1, std::memory_order_relaxed); data_dir->disks_compaction_score_increment(-permits); data_dir->disks_compaction_num_increment(-1); }; - HANDLE_ERROR_IF_CATCH_EXCEPTION_OR_RETURN_ERROR(execute_compact_impl(permits), - record_compaction_stats); - record_compaction_stats(); + HANDLE_EXCEPTION_IF_CATCH_EXCEPTION(execute_compact_impl(permits), record_compaction_stats); + record_compaction_stats(doris::Exception()); if (enable_compaction_checksum) { EngineChecksumTask checksum_task(_engine, _tablet->tablet_id(), _tablet->schema_hash(), @@ -1183,8 +1182,8 @@ Status CloudCompactionMixin::execute_compact_impl(int64_t permits) { Status CloudCompactionMixin::execute_compact() { TEST_INJECTION_POINT("Compaction::do_compaction"); int64_t permits = get_compaction_permits(); - HANDLE_ERROR_IF_CATCH_EXCEPTION_OR_RETURN_ERROR(execute_compact_impl(permits), - [&]() { garbage_collection(); }); + HANDLE_EXCEPTION_IF_CATCH_EXCEPTION(execute_compact_impl(permits), + [&](const doris::Exception& ex) { garbage_collection(); }); _load_segment_to_cache(); return Status::OK(); }