From e9973c46e499b775e19f932f9b9d51ce8c3a3732 Mon Sep 17 00:00:00 2001 From: drrtuy Date: Fri, 18 Apr 2025 20:03:09 +0000 Subject: [PATCH] feat(TNS): change ORDER BY out-of-memory error message. Replaced bad_alloc with IDBExcept in TNS. --- dbcon/joblist/tupleannexstep.cpp | 35 +++++++++++++++++++++++++++++++ utils/windowfunction/idborderby.h | 5 +++++ 2 files changed, 40 insertions(+) diff --git a/dbcon/joblist/tupleannexstep.cpp b/dbcon/joblist/tupleannexstep.cpp index 7f04d3b13..334519418 100644 --- a/dbcon/joblist/tupleannexstep.cpp +++ b/dbcon/joblist/tupleannexstep.cpp @@ -574,6 +574,13 @@ void TupleAnnexStep::executeNoOrderByWithDistinct() dataVec.pop_back(); } } + catch (const std::bad_alloc&) + { + auto errorCode = ERR_TNS_DISTINCT_IS_TOO_BIG; + auto newException = IDBExcept(errorCode); + handleException(std::make_exception_ptr(newException), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::executeNoOrderByWithDistinct()"); + } catch (...) { handleException(std::current_exception(), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, @@ -676,6 +683,13 @@ void TupleAnnexStep::executeWithOrderBy() } } } + catch (const std::bad_alloc&) + { + auto errorCode = fOrderBy->getErrorCode(); + auto newException = IDBExcept(errorCode); + handleException(std::make_exception_ptr(newException), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::executeWithOrderBy()"); + } catch (...) { handleException(std::current_exception(), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, @@ -747,6 +761,13 @@ void TupleAnnexStep::finalizeParallelOrderByDistinct() } } } + catch (const std::bad_alloc&) + { + auto errorCode = fOrderBy->getErrorCode(); + auto newException = IDBExcept(errorCode); + handleException(std::make_exception_ptr(newException), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::finalizeParallelOrderByDistinct()"); + } catch (...) { handleException(std::current_exception(), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, @@ -939,6 +960,13 @@ void TupleAnnexStep::finalizeParallelOrderBy() } } } + catch (const std::bad_alloc&) + { + auto errorCode = fOrderBy->getErrorCode(); + auto newException = IDBExcept(errorCode); + handleException(std::make_exception_ptr(newException), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::finalizeParallelOrderBy()"); + } catch (...) { handleException(std::current_exception(), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, @@ -1147,6 +1175,13 @@ void TupleAnnexStep::executeParallelOrderBy(uint64_t id) dlOffset++; } } + catch (const std::bad_alloc&) + { + auto errorCode = fOrderBy->getErrorCode(); + auto newException = IDBExcept(errorCode); + handleException(std::make_exception_ptr(newException), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::executeParallelOrderBy()"); + } catch (...) { handleException(std::current_exception(), logging::ERR_IN_PROCESS, logging::ERR_ALWAYS_CRITICAL, diff --git a/utils/windowfunction/idborderby.h b/utils/windowfunction/idborderby.h index b67cf1fed..67f037937 100644 --- a/utils/windowfunction/idborderby.h +++ b/utils/windowfunction/idborderby.h @@ -432,6 +432,11 @@ class IdbOrderBy : public IdbCompare { return *fOrderByQueue; } + uint64_t getErrorCode() const + { + return fErrorCode; + } + void returnAllRGDataMemory2RM() { while (!fOrderByQueue->empty())