diff --git a/dbcon/joblist/crossenginestep.cpp b/dbcon/joblist/crossenginestep.cpp index b47c396a4..455906c0f 100644 --- a/dbcon/joblist/crossenginestep.cpp +++ b/dbcon/joblist/crossenginestep.cpp @@ -615,18 +615,12 @@ void CrossEngineStep::execute() fOutputDL->insert(rgDataDelivered); fRowsRetrieved = mysql->getRowCount(); } - catch (IDBExcept& iex) - { - catchHandler(iex.what(), iex.errorCode(), fErrorInfo, fSessionId); - } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_CROSS_ENGINE_CONNECT, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("CrossEngineStep execute caught an unknown exception", - ERR_CROSS_ENGINE_CONNECT, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_CROSS_ENGINE_CONNECT, + logging::ERR_ALWAYS_CRITICAL, + "CrossEngineStep::execute()"); } sts.msg_type = StepTeleStats::ST_SUMMARY; @@ -792,20 +786,12 @@ uint32_t CrossEngineStep::nextBand(messageqcpp::ByteStream& bs) fEndOfResult = true; } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_IN_DELIVERY, fErrorInfo, fSessionId); - - while (more) - more = fOutputDL->next(fOutputIterator, &rgDataOut); - - fEndOfResult = true; - } catch (...) { - catchHandler("CrossEngineStep next band caught an unknown exception", - ERR_IN_DELIVERY, fErrorInfo, fSessionId); - + handleException(std::current_exception(), + logging::ERR_IN_DELIVERY, + logging::ERR_ALWAYS_CRITICAL, + "CrossEngineStep::nextBand()"); while (more) more = fOutputDL->next(fOutputIterator, &rgDataOut); diff --git a/dbcon/joblist/diskjoinstep.cpp b/dbcon/joblist/diskjoinstep.cpp index 89356618b..1dc255fe1 100644 --- a/dbcon/joblist/diskjoinstep.cpp +++ b/dbcon/joblist/diskjoinstep.cpp @@ -25,34 +25,6 @@ using namespace rowgroup; using namespace joiner; using namespace logging; -// a couple space-savers... - -#define LOG(x) {\ - logging::Logger logger(16); \ - LoggingID id(16, fSessionId); \ - logger.logMessage(LOG_TYPE_ERROR, x, id); \ -} - -#define CATCH_AND_LOG \ - catch(IDBExcept &e) { \ - if (!status()) { \ - errorMessage(e.what()); \ - status(e.errorCode()); \ - LOG(string(e.what())); \ - } \ - abort(); \ - } \ - catch(exception &e) { \ - if (!status()) { \ - ostringstream os; \ - os << "Disk join caught an error: " << e.what(); \ - errorMessage(os.str().c_str()); \ - LOG(os.str()); \ - status(ERR_DBJ_UNKNOWN_ERROR); \ - } \ - abort(); \ - } - namespace joblist { @@ -231,10 +203,17 @@ void DiskJoinStep::smallReader() abort(); } } + } // try + catch (...) + { + handleException(std::current_exception(), + logging::ERR_EXEMGR_MALFUNCTION, + logging::ERR_ALWAYS_CRITICAL, + "DiskJoinStep::smallReader()"); + status(logging::ERR_EXEMGR_MALFUNCTION); + abort(); } - CATCH_AND_LOG; - while (more) more = smallDL->next(0, &rgData); } @@ -272,8 +251,15 @@ void DiskJoinStep::largeReader() if (!more) lastLargeIteration = true; } - - CATCH_AND_LOG; + catch (...) + { + handleException(std::current_exception(), + logging::ERR_EXEMGR_MALFUNCTION, + logging::ERR_ALWAYS_CRITICAL, + "DiskJoinStep::largeReader()"); + status(logging::ERR_EXEMGR_MALFUNCTION); + abort(); + } if (cancelled()) while (more) @@ -301,8 +287,15 @@ void DiskJoinStep::loadFcn() } while (ret && !cancelled()); } - - CATCH_AND_LOG; + catch (...) + { + handleException(std::current_exception(), + logging::ERR_EXEMGR_MALFUNCTION, + logging::ERR_ALWAYS_CRITICAL, + "DiskJoinStep::loadFcn()"); + status(logging::ERR_EXEMGR_MALFUNCTION); + abort(); + } loadFIFO->endOfInput(); } @@ -509,8 +502,15 @@ void DiskJoinStep::joinFcn() } } } // the try stmt above; need to reformat. - - CATCH_AND_LOG; + catch (...) + { + handleException(std::current_exception(), + logging::ERR_EXEMGR_MALFUNCTION, + logging::ERR_ALWAYS_CRITICAL, + "DiskJoinStep::joinFcn()"); + status(logging::ERR_EXEMGR_MALFUNCTION); + abort(); + } out: @@ -559,8 +559,15 @@ void DiskJoinStep::mainRunner() jobstepThreadPool.join(thrds); } } - - CATCH_AND_LOG; + catch (...) + { + handleException(std::current_exception(), + logging::ERR_EXEMGR_MALFUNCTION, + logging::ERR_ALWAYS_CRITICAL, + "DiskJoinStep::mainRunner()"); + status(logging::ERR_EXEMGR_MALFUNCTION); + abort(); + } // make sure all inputs were drained & output closed if (cancelled()) diff --git a/dbcon/joblist/jl_logger.cpp b/dbcon/joblist/jl_logger.cpp index 8a354e481..2ada20df7 100644 --- a/dbcon/joblist/jl_logger.cpp +++ b/dbcon/joblist/jl_logger.cpp @@ -58,7 +58,10 @@ Logger::Logger() : fLogId(5), fImpl->msgMap(msgMap); } -void catchHandler(const string& ex, int c, SErrorInfo& ei, unsigned sid, logging::LOG_TYPE level) +void catchHandler(const string& ex, + int c, SErrorInfo& ei, + unsigned sid, + logging::LOG_TYPE level) { boost::mutex::scoped_lock lk(logMutex); diff --git a/dbcon/joblist/jobstep.cpp b/dbcon/joblist/jobstep.cpp index 3816476d1..3ececcae4 100644 --- a/dbcon/joblist/jobstep.cpp +++ b/dbcon/joblist/jobstep.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (c) 2016-2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -209,6 +210,60 @@ bool JobStep::traceOn() const return fTraceFlags & execplan::CalpontSelectExecutionPlan::TRACE_LOG; } +////////////////////////////////////////////////////////////////////// +// DESCRIPTION: +// The m() rethrows a query runtime exception and handles it across +// all steps in a uniform +// way. +// PARAMETERS: +// e ptr to the exception raised +// errorCode error code to log +// critErrorCode is this a crit IDBExcept or not +// methodName method name to log +////////////////////////////////////////////////////////////////////// +void JobStep::handleException(std::exception_ptr e, + const int errorCode, + const unsigned infoErrorCode, + const std::string& methodName) +{ + try + { + std::rethrow_exception(e); + } + catch (const IDBExcept& iex) + { + std::cerr << methodName << " caught a internal exception. " + << std::endl; + + catchHandler(methodName + " " + iex.what(), iex.errorCode(), + fErrorInfo, fSessionId, (iex.errorCode() == infoErrorCode + ? LOG_TYPE_INFO + : LOG_TYPE_CRITICAL)); + } + catch (boost::exception& e) + { + std::cerr << methodName << " caught a boost::exception. " + << std::endl; + catchHandler(methodName + " caught " + boost::diagnostic_information(e), + errorCode, fErrorInfo, fSessionId); + } + catch (const std::exception& ex) + { + std::cerr << methodName << " caught an exception. " << std::endl; + catchHandler(methodName + " caught " + ex.what(), errorCode, + fErrorInfo, fSessionId); + } + catch (...) + { + std::ostringstream oss; + + std::cerr << methodName << " caught an unknown exception." + << std::endl; + catchHandler(methodName + " caught an unknown exception ", + errorCode, fErrorInfo, fSessionId); + } +} + } //namespace joblist // vim:ts=4 sw=4: diff --git a/dbcon/joblist/jobstep.h b/dbcon/joblist/jobstep.h index 7a13b6757..88dbeb94c 100644 --- a/dbcon/joblist/jobstep.h +++ b/dbcon/joblist/jobstep.h @@ -430,6 +430,11 @@ public: return fTimeZone; } + void handleException(std::exception_ptr e, + const int errorCode, + const unsigned infoErrorCode, + const std::string& methodName); + static threadpool::ThreadPool jobstepThreadPool; protected: diff --git a/dbcon/joblist/pdictionary.cpp b/dbcon/joblist/pdictionary.cpp index f9b733100..97ace8f77 100644 --- a/dbcon/joblist/pdictionary.cpp +++ b/dbcon/joblist/pdictionary.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (c) 2016-2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -533,7 +534,7 @@ const string pDictionaryStep::toString() const #ifdef FIFO_SINK - if (fOid < 3000)) + if (fOid < 3000) oss << " (sink)"; #endif diff --git a/dbcon/joblist/pdictionaryscan.cpp b/dbcon/joblist/pdictionaryscan.cpp index cf1c9af50..4532b1980 100644 --- a/dbcon/joblist/pdictionaryscan.cpp +++ b/dbcon/joblist/pdictionaryscan.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (c) 2016-2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -426,15 +427,12 @@ void pDictionaryScan::sendPrimitiveMessages() } } // end of loop through LBID ranges to be requested from primproc }//try - catch (const exception& e) - { - catchHandler(e.what(), ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); - sendError(ERR_DICTIONARY_SCAN); - } catch (...) { - catchHandler("pDictionaryScan caught an unknown exception.", - ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_DICTIONARY_SCAN, + logging::ERR_ALWAYS_CRITICAL, + "pDictionaryScan::sendPrimitiveMessages()"); sendError(ERR_DICTIONARY_SCAN); } @@ -547,24 +545,14 @@ void pDictionaryScan::sendAPrimitiveMessage( { fDec->write(uniqueID, primMsg); } - catch (const IDBExcept& e) - { - abort(); - cerr << "pDictionaryScan::send() caught: " << e.what() << endl; - catchHandler(e.what(), e.errorCode(), fErrorInfo, fSessionId); - } - catch (const std::exception& e) - { - abort(); - cerr << "pDictionaryScan::send() caught: " << e.what() << endl; - catchHandler(e.what(), ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); - } catch (...) { abort(); - cerr << "pDictionaryScan::send() caught unknown exception" << endl; - catchHandler("pDictionaryScan::send() caught unknown exception", - ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_DICTIONARY_SCAN, + logging::ERR_ALWAYS_CRITICAL, + "pDictionaryScan::sendAPrimitiveMessage()"); + sendError(ERR_DICTIONARY_SCAN); } fMsgsToPm++; @@ -757,15 +745,12 @@ void pDictionaryScan::receivePrimitiveMessages() catchHandler(ex.what(), ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); mutex.unlock(); } - catch (const exception& e) - { - catchHandler(e.what(), ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); - mutex.unlock(); - } catch (...) { - catchHandler("pDictionaryScan caught an unknown exception.", - ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_DICTIONARY_SCAN, + logging::ERR_ALWAYS_CRITICAL, + "pDictionaryScan::receivePrimitiveMessages()"); mutex.unlock(); } @@ -927,24 +912,13 @@ void pDictionaryScan::serializeEqualityFilter() { fDec->write(uniqueID, msg); } - catch (const IDBExcept& e) - { - abort(); - cerr << "pDictionaryScan::serializeEqualityFilter() caught: " << e.what() << endl; - catchHandler(e.what(), e.errorCode(), fErrorInfo, fSessionId); - } - catch (const std::exception& e) - { - abort(); - cerr << "pDictionaryScan::serializeEqualityFilter() caught: " << e.what() << endl; - catchHandler(e.what(), ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); - } catch (...) { abort(); - cerr << "pDictionaryScan::serializeEqualityFilter() caught unknown exception" << endl; - catchHandler("pDictionaryScan::serializeEqualityFilter() caught unknown exception", - ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_DICTIONARY_SCAN, + logging::ERR_ALWAYS_CRITICAL, + "pDictionaryScan::serializeEqualityFilter()"); } empty.swap(equalityFilter); @@ -965,23 +939,13 @@ void pDictionaryScan::destroyEqualityFilter() { fDec->write(uniqueID, msg); } - catch (const IDBExcept& e) - { - abort(); - catchHandler(e.what(), e.errorCode(), fErrorInfo, fSessionId); - } - catch (const std::exception& e) - { - abort(); - cerr << "pDictionaryScan::destroyEqualityFilter() caught: " << e.what() << endl; - catchHandler(e.what(), ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); - } catch (...) { abort(); - cerr << "pDictionaryScan::destroyEqualityFilter() caught unknown exception" << endl; - catchHandler("pDictionaryScan::destroyEqualityFilter() caught unknown exception", - ERR_DICTIONARY_SCAN, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_DICTIONARY_SCAN, + logging::ERR_ALWAYS_CRITICAL, + "pDictionaryScan::destroyEqualityFilter()"); } } diff --git a/dbcon/joblist/primitivestep.h b/dbcon/joblist/primitivestep.h index b07001c7d..35ecf86de 100644 --- a/dbcon/joblist/primitivestep.h +++ b/dbcon/joblist/primitivestep.h @@ -1343,7 +1343,6 @@ public: protected: void sendError(uint16_t status); - void processError(const std::string& ex, uint16_t err, const std::string& src); private: void formatMiniStats(); diff --git a/dbcon/joblist/subquerystep.cpp b/dbcon/joblist/subquerystep.cpp index ebf64b858..2d39b4a43 100644 --- a/dbcon/joblist/subquerystep.cpp +++ b/dbcon/joblist/subquerystep.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (c) 2016-2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -235,23 +236,14 @@ uint32_t SubAdapterStep::nextBand(messageqcpp::ByteStream& bs) rowCount = fRowGroupDeliver.getRowCount(); } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_IN_DELIVERY, fErrorInfo, fSessionId); - - while (more) - more = fOutputDL->next(fOutputIterator, &rgDataOut); - - fEndOfResult = true; - } catch (...) { - catchHandler("SubAdapterStep next band caught an unknown exception", - ERR_IN_DELIVERY, fErrorInfo, fSessionId); - + handleException(std::current_exception(), + logging::ERR_IN_DELIVERY, + logging::ERR_ALWAYS_CRITICAL, + "SubAdapterStep::nextBand()"); while (more) more = fOutputDL->next(fOutputIterator, &rgDataOut); - fEndOfResult = true; } @@ -441,14 +433,12 @@ void SubAdapterStep::execute() more = fInputDL->next(fInputIterator, &rgDataIn); } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_EXEMGR_MALFUNCTION, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("SubAdapterStep execute caught an unknown exception", - ERR_EXEMGR_MALFUNCTION, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_EXEMGR_MALFUNCTION, + logging::ERR_ALWAYS_CRITICAL, + "SubAdapterStep::execute()"); } if (cancelled()) diff --git a/dbcon/joblist/tuple-bps.cpp b/dbcon/joblist/tuple-bps.cpp index f8da404ff..02b479886 100644 --- a/dbcon/joblist/tuple-bps.cpp +++ b/dbcon/joblist/tuple-bps.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2019-2020 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1204,18 +1205,12 @@ void TupleBPS::run() fProducerThreads.reserve(fMaxNumThreads); startAggregationThread(); } - catch (const std::exception& e) - { - // log the exception - cerr << "tuple-bps::run() caught: " << e.what() << endl; - catchHandler(e.what(), ERR_TUPLE_BPS, fErrorInfo, fSessionId); - fOutputJobStepAssociation.outAt(0)->rowGroupDL()->endOfInput(); - } catch (...) { - cerr << "tuple-bps::run() caught unknown exception" << endl; - catchHandler("tuple-bps::run() caught unknown exception", - ERR_TUPLE_BPS, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_TUPLE_BPS, + logging::ERR_ALWAYS_CRITICAL, + "TupleBPS::run()"); fOutputJobStepAssociation.outAt(0)->rowGroupDL()->endOfInput(); } } @@ -1254,17 +1249,12 @@ void TupleBPS::join() { fDec->write(uniqueID, bs); } - catch (const std::exception& e) - { - // log the exception - cerr << "tuple-bps::join() write(bs) caught: " << e.what() << endl; - catchHandler(e.what(), ERR_TUPLE_BPS, fErrorInfo, fSessionId); - } catch (...) { - cerr << "tuple-bps::join() write(bs) caught unknown exception" << endl; - catchHandler("tuple-bps::join() write(bs) caught unknown exception", - ERR_TUPLE_BPS, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_TUPLE_BPS, + logging::ERR_ALWAYS_CRITICAL, + "TupleBPS::join()"); } BPPIsAllocated = false; @@ -1848,20 +1838,15 @@ void TupleBPS::sendPrimitiveMessages() interleaveJobs(&jobs); sendJobs(jobs); } - catch (const IDBExcept& e) - { - sendError(e.errorCode()); - processError(e.what(), e.errorCode(), "TupleBPS::sendPrimitiveMessages()"); - } - catch (const std::exception& ex) - { - sendError(ERR_TUPLE_BPS); - processError(ex.what(), ERR_TUPLE_BPS, "TupleBPS::sendPrimitiveMessages()"); - } catch (...) { - sendError(ERR_TUPLE_BPS); - processError("unknown", ERR_TUPLE_BPS, "TupleBPS::sendPrimitiveMessages()"); + sendError(logging::ERR_TUPLE_BPS); + handleException(std::current_exception(), + logging::ERR_TUPLE_BPS, + logging::ERR_ALWAYS_CRITICAL, + "st: " + std::to_string(fStepId) + + " TupleBPS::sendPrimitiveMessages()"); + abort_nolock(); } abort: @@ -2389,13 +2374,14 @@ void TupleBPS::receiveMultiPrimitiveMessages(uint32_t threadID) } // done reading }//try - catch (const std::exception& ex) - { - processError(ex.what(), ERR_TUPLE_BPS, "TupleBPS::receiveMultiPrimitiveMessages()"); - } catch (...) { - processError("unknown", ERR_TUPLE_BPS, "TupleBPS::receiveMultiPrimitiveMessages()"); + handleException(std::current_exception(), + logging::ERR_TUPLE_BPS, + logging::ERR_ALWAYS_CRITICAL, + "st: " + std::to_string(fStepId) + + " TupleBPS::receiveMultiPrimitiveMessages()"); + abort_nolock(); } out: @@ -2643,15 +2629,6 @@ out: dlp->endOfInput(); } -void TupleBPS::processError(const string& ex, uint16_t err, const string& src) -{ - ostringstream oss; - oss << "st: " << fStepId << " " << src << " caught an exception: " << ex << endl; - catchHandler(oss.str(), err, fErrorInfo, fSessionId); - abort_nolock(); - cerr << oss.str(); -} - const string TupleBPS::toString() const { ostringstream oss; diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp index d3d9b2165..4f93d697c 100644 --- a/dbcon/joblist/tupleaggregatestep.cpp +++ b/dbcon/joblist/tupleaggregatestep.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - Copyright (C) 2019 MariaDB Corporation + Copyright (C) 2019-2020 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -449,7 +449,6 @@ void TupleAggregateStep::doThreadedSecondPhaseAggregate(uint32_t threadID) scoped_array rowBucketVecs(new RowBucketVec[fNumOfBuckets]); scoped_array bucketDone(new bool[fNumOfBuckets]); uint32_t hashlen = fAggregator->aggMapKeyLength(); - bool caughtException = false; try { @@ -561,26 +560,15 @@ void TupleAggregateStep::doThreadedSecondPhaseAggregate(uint32_t threadID) } } // try - catch (IDBExcept& iex) - { - catchHandler(iex.what(), iex.errorCode(), fErrorInfo, fSessionId, - (iex.errorCode() == ERR_AGGREGATION_TOO_BIG ? LOG_TYPE_INFO : LOG_TYPE_CRITICAL)); - caughtException = true; - } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleAggregateStepErr, fErrorInfo, fSessionId); - caughtException = true; - } catch (...) { - catchHandler("doThreadedSecondPhaseAggregate() caught an unknown exception", - tupleAggregateStepErr, fErrorInfo, fSessionId); - caughtException = true; + handleException(std::current_exception(), + logging::tupleAggregateStepErr, + logging::ERR_AGGREGATION_TOO_BIG, + "TupleAggregateStep::doThreadedSecondPhaseAggregate()"); + fEndOfResult = true; } - if (caughtException) - fEndOfResult = true; fDoneAggregate = true; @@ -630,24 +618,12 @@ uint32_t TupleAggregateStep::nextBand_singleThread(messageqcpp::ByteStream& bs) } } } // try - catch (IDBExcept& iex) - { - catchHandler(iex.what(), iex.errorCode(), fErrorInfo, fSessionId, - (iex.errorCode() == ERR_AGGREGATION_TOO_BIG ? LOG_TYPE_INFO : LOG_TYPE_CRITICAL)); - - fEndOfResult = true; - } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleAggregateStepErr, fErrorInfo, fSessionId); - - fEndOfResult = true; - } catch (...) { - catchHandler("TupleAggregateStep next band caught an unknown exception", - tupleAggregateStepErr, fErrorInfo, fSessionId); - + handleException(std::current_exception(), + logging::tupleAggregateStepErr, + logging::ERR_AGGREGATION_TOO_BIG, + "TupleAggregateStep::doThreadedSecondPhaseAggregate()"); fEndOfResult = true; } @@ -5194,21 +5170,12 @@ void TupleAggregateStep::aggregateRowGroups() } } } // try - catch (IDBExcept& iex) - { - catchHandler(iex.what(), iex.errorCode(), fErrorInfo, fSessionId, - (iex.errorCode() == ERR_AGGREGATION_TOO_BIG ? LOG_TYPE_INFO : LOG_TYPE_CRITICAL)); - fEndOfResult = true; - } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleAggregateStepErr, fErrorInfo, fSessionId); - fEndOfResult = true; - } catch (...) { - catchHandler("TupleAggregateStep::aggregateRowGroups() caught an unknown exception", - tupleAggregateStepErr, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::tupleAggregateStepErr, + logging::ERR_AGGREGATION_TOO_BIG, + "TupleAggregateStep::aggregateRowGroups()"); fEndOfResult = true; } } @@ -5484,31 +5451,17 @@ void TupleAggregateStep::threadedAggregateRowGroups(uint32_t threadID) } } } // try - catch (IDBExcept& iex) - { - catchHandler(iex.what(), iex.errorCode(), fErrorInfo, fSessionId, - (iex.errorCode() == ERR_AGGREGATION_TOO_BIG ? LOG_TYPE_INFO : LOG_TYPE_CRITICAL)); - caughtException = true; - } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleAggregateStepErr, fErrorInfo, fSessionId); - caughtException = true; - } catch (...) { - catchHandler("threadedAggregateRowGroups() caught an unknown exception", - tupleAggregateStepErr, fErrorInfo, fSessionId); - caughtException = true; + handleException(std::current_exception(), + logging::tupleAggregateStepErr, + logging::ERR_AGGREGATION_TOO_BIG, + "TupleAggregateStep::threadedAggregateRowGroups()"); + fEndOfResult = true; + fDoneAggregate = true; } } - if (caughtException) - { - fEndOfResult = true; - fDoneAggregate = true; - } - if (!locked) fMutex.lock(); while (more) more = dlIn->next(fInputIter, &rgData); @@ -5558,19 +5511,12 @@ void TupleAggregateStep::doAggregate_singleThread() } } } // try - catch (IDBExcept& iex) - { - catchHandler(iex.what(), iex.errorCode(), fErrorInfo, fSessionId, - (iex.errorCode() == ERR_AGGREGATION_TOO_BIG ? LOG_TYPE_INFO : LOG_TYPE_CRITICAL)); - } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleAggregateStepErr, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleAggregateStep next band caught an unknown exception", - tupleAggregateStepErr, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::tupleAggregateStepErr, + logging::ERR_AGGREGATION_TOO_BIG, + "TupleAggregateStep::doAggregate_singleThread()"); } if (traceOn()) @@ -5770,16 +5716,13 @@ uint64_t TupleAggregateStep::doThreadedAggregate(ByteStream& bs, RowGroupDL* dlp fEndOfResult = true; } } - } - catch (IDBExcept& iex) + } //try + catch (...) { - catchHandler(iex.what(), iex.errorCode(), fErrorInfo, fSessionId, - (iex.errorCode() == ERR_AGGREGATION_TOO_BIG ? LOG_TYPE_INFO : LOG_TYPE_CRITICAL)); - fEndOfResult = true; - } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleAggregateStepErr, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::tupleAggregateStepErr, + logging::ERR_AGGREGATION_TOO_BIG, + "TupleAggregateStep::doThreadedAggregate()"); fEndOfResult = true; } diff --git a/dbcon/joblist/tupleannexstep.cpp b/dbcon/joblist/tupleannexstep.cpp index 841817fc5..37994ff00 100644 --- a/dbcon/joblist/tupleannexstep.cpp +++ b/dbcon/joblist/tupleannexstep.cpp @@ -328,20 +328,12 @@ uint32_t TupleAnnexStep::nextBand(messageqcpp::ByteStream& bs) fEndOfResult = true; } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_IN_DELIVERY, fErrorInfo, fSessionId); - - while (more) - more = fOutputDL->next(fOutputIterator, &rgDataOut); - - fEndOfResult = true; - } catch (...) { - catchHandler("TupleAnnexStep next band caught an unknown exception", - ERR_IN_DELIVERY, fErrorInfo, fSessionId); - + handleException(std::current_exception(), + logging::ERR_IN_DELIVERY, + logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::nextBand()"); while (more) more = fOutputDL->next(fOutputIterator, &rgDataOut); @@ -464,14 +456,12 @@ void TupleAnnexStep::executeNoOrderBy() more = fInputDL->next(fInputIterator, &rgDataIn); } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_IN_PROCESS, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleAnnexStep execute caught an unknown exception", - ERR_IN_PROCESS, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_IN_PROCESS, + logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::executeNoOrderBy()"); } while (more) @@ -566,14 +556,12 @@ void TupleAnnexStep::executeNoOrderByWithDistinct() fOutputDL->insert(rgDataOut); } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_IN_PROCESS, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleAnnexStep execute caught an unknown exception", - ERR_IN_PROCESS, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_IN_PROCESS, + logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::executeNoOrderByWithDistinct()"); } while (more) @@ -662,14 +650,12 @@ void TupleAnnexStep::executeWithOrderBy() } } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_IN_PROCESS, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleAnnexStep execute caught an unknown exception", - ERR_IN_PROCESS, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_IN_PROCESS, + logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::executeWithOrderBy()"); } while (more) @@ -736,15 +722,12 @@ void TupleAnnexStep::finalizeParallelOrderByDistinct() } } } - catch (const std::exception& ex) - { - catchHandler(ex.what(),ERR_IN_PROCESS, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleAnnexStep::finalizeParallelOrderByDistinct execute\ - caught an unknown exception 1", - ERR_IN_PROCESS, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_IN_PROCESS, + logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::finalizeParallelOrderByDistinct()"); } // OFFSET processing @@ -938,15 +921,12 @@ void TupleAnnexStep::finalizeParallelOrderBy() } } } - catch (const std::exception& ex) - { - catchHandler(ex.what(),ERR_IN_PROCESS, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleAnnexStep::finalizeParallelOrderBy execute\ - caught an unknown exception 1", - ERR_IN_PROCESS, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_IN_PROCESS, + logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::finalizeParallelOrderBy()"); } // OFFSET processing @@ -1149,14 +1129,12 @@ void TupleAnnexStep::executeParallelOrderBy(uint64_t id) if(more) dlOffset++; } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), ERR_IN_PROCESS, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleAnnexStep::executeParallelOrderBy execute caught an unknown exception", - ERR_IN_PROCESS, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::ERR_IN_PROCESS, + logging::ERR_ALWAYS_CRITICAL, + "TupleAnnexStep::executeParallelOrderBy()"); } // read out the input DL diff --git a/dbcon/joblist/tupleconstantstep.cpp b/dbcon/joblist/tupleconstantstep.cpp index 6ec49884e..15e5927a1 100644 --- a/dbcon/joblist/tupleconstantstep.cpp +++ b/dbcon/joblist/tupleconstantstep.cpp @@ -360,20 +360,12 @@ uint32_t TupleConstantStep::nextBand(messageqcpp::ByteStream& bs) fEndOfResult = true; } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleConstantStepErr, fErrorInfo, fSessionId); - - while (more) - more = fInputDL->next(fInputIterator, &rgDataIn); - - fEndOfResult = true; - } catch (...) { - catchHandler("TupleConstantStep next band caught an unknown exception", - tupleConstantStepErr, fErrorInfo, fSessionId); - + handleException(std::current_exception(), + logging::tupleConstantStepErr, + logging::ERR_ALWAYS_CRITICAL, + "TupleConstantStep::nextBand()"); while (more) more = fInputDL->next(fInputIterator, &rgDataIn); @@ -445,17 +437,14 @@ void TupleConstantStep::execute() } } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleConstantStepErr, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleConstantStep execute caught an unknown exception", - tupleConstantStepErr, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::tupleConstantStepErr, + logging::ERR_ALWAYS_CRITICAL, + "TupleConstantStep::execute()"); } -// if (!fEndOfResult) while (more) more = fInputDL->next(fInputIterator, &rgDataIn); @@ -717,8 +706,10 @@ void TupleConstantOnlyStep::run() } catch (...) { - catchHandler("TupleConstantOnlyStep run caught an unknown exception", - tupleConstantStepErr, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::tupleConstantStepErr, + logging::ERR_ALWAYS_CRITICAL, + "TupleConstantOnlyStep::run()"); } if (traceOn()) @@ -756,14 +747,12 @@ uint32_t TupleConstantOnlyStep::nextBand(messageqcpp::ByteStream& bs) fRowGroupOut.serializeRGData(bs); rowCount = fRowGroupOut.getRowCount(); } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleConstantStepErr, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleConstantStep next band caught an unknown exception", - tupleConstantStepErr, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::tupleConstantStepErr, + logging::ERR_ALWAYS_CRITICAL, + "TupleConstantOnlyStep::nextBand()"); } fEndOfResult = true; diff --git a/dbcon/joblist/tuplehashjoin.cpp b/dbcon/joblist/tuplehashjoin.cpp index f18b5d101..3b6c0639d 100644 --- a/dbcon/joblist/tuplehashjoin.cpp +++ b/dbcon/joblist/tuplehashjoin.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (c) 2016-2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -447,23 +448,12 @@ next: dlMutex.unlock(); } } - catch (boost::exception& e) - { - ostringstream oss; - oss << "TupleHashJoinStep::smallRunnerFcn failed due to " << boost::diagnostic_information(e); - fLogger->logMessage(logging::LOG_TYPE_ERROR, oss.str()); - status(logging::ERR_EXEMGR_MALFUNCTION); - } - catch (std::exception& e) - { - ostringstream oss; - oss << "TupleHashJoinStep::smallRunnerFcn failed due to " << e.what(); - fLogger->logMessage(logging::LOG_TYPE_ERROR, oss.str()); - status(logging::ERR_EXEMGR_MALFUNCTION); - } catch (...) { - fLogger->logMessage(logging::LOG_TYPE_ERROR, "TupleHashJoinStep::smallRunnerFcn failed due to an unknown reason (...)"); + handleException(std::current_exception(), + logging::ERR_EXEMGR_MALFUNCTION, + logging::ERR_JOIN_TOO_BIG, + "TupleHashJoinStep::smallRunnerFcn()"); status(logging::ERR_EXEMGR_MALFUNCTION); } @@ -755,28 +745,13 @@ void TupleHashJoinStep::hjRunner() rgData[djsJoinerMap[i]].swap(empty); } } - catch (logging::IDBExcept& e) + catch (...) { - cout << e.what() << endl; - - if (!status()) - { - errorMessage(logging::IDBErrorInfo::instance()->errorMsg(e.errorCode())); - status(e.errorCode()); - } - - abort(); - } - catch (std::exception& e) - { - cout << e.what() << endl; - - if (!status()) - { - errorMessage(logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_DBJ_UNKNOWN_ERROR)); - status(logging::ERR_DBJ_UNKNOWN_ERROR); - } - + handleException(std::current_exception(), + logging::ERR_EXEMGR_MALFUNCTION, + logging::ERR_JOIN_TOO_BIG, + "TupleHashJoinStep::hjRunner()"); + status(logging::ERR_EXEMGR_MALFUNCTION); abort(); } diff --git a/dbcon/joblist/tuplehavingstep.cpp b/dbcon/joblist/tuplehavingstep.cpp index 65c62d0a3..853e12342 100644 --- a/dbcon/joblist/tuplehavingstep.cpp +++ b/dbcon/joblist/tuplehavingstep.cpp @@ -227,21 +227,13 @@ uint32_t TupleHavingStep::nextBand(messageqcpp::ByteStream& bs) fEndOfResult = true; } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleHavingStepErr, fErrorInfo, fSessionId); - - while (more) - more = fInputDL->next(fInputIterator, &rgDataIn); - - fEndOfResult = true; - } catch (...) { - catchHandler("TupleHavingStep next band caught an unknown exception", - tupleHavingStepErr, fErrorInfo, fSessionId); - - while (more) + handleException(std::current_exception(), + logging::tupleHavingStepErr, + logging::ERR_ALWAYS_CRITICAL, + "TupleHavingStep::nextBand()"); + while (more) more = fInputDL->next(fInputIterator, &rgDataIn); fEndOfResult = true; @@ -310,14 +302,12 @@ void TupleHavingStep::execute() } } } - catch (const std::exception& ex) - { - catchHandler(ex.what(), tupleHavingStepErr, fErrorInfo, fSessionId); - } catch (...) { - catchHandler("TupleHavingStep execute caught an unknown exception", - tupleHavingStepErr, fErrorInfo, fSessionId); + handleException(std::current_exception(), + logging::tupleHavingStepErr, + logging::ERR_ALWAYS_CRITICAL, + "TupleHavingStep::nextBand()"); } while (more) diff --git a/dbcon/joblist/tupleunion.cpp b/dbcon/joblist/tupleunion.cpp index 85f90860b..914bd850d 100644 --- a/dbcon/joblist/tupleunion.cpp +++ b/dbcon/joblist/tupleunion.cpp @@ -276,13 +276,11 @@ void TupleUnion::readInput(uint32_t which) } catch (...) { - if (status() == 0) - { - errorMessage("Union step caught an unknown exception."); - status(logging::unionStepErr); - fLogger->logMessage(logging::LOG_TYPE_CRITICAL, "Union step caught an unknown exception."); - } - + handleException(std::current_exception(), + logging::unionStepErr, + logging::ERR_UNION_TOO_BIG, + "TupleUnion::readInput()"); + status(logging::unionStepErr); abort(); } diff --git a/dbcon/joblist/windowfunctionstep.cpp b/dbcon/joblist/windowfunctionstep.cpp index 1da9ef60b..48c81327c 100755 --- a/dbcon/joblist/windowfunctionstep.cpp +++ b/dbcon/joblist/windowfunctionstep.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (c) 2016-2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -228,31 +229,14 @@ uint32_t WindowFunctionStep::nextBand(messageqcpp::ByteStream& bs) fEndOfResult = true; } } - catch (IDBExcept& iex) - { - handleException(iex.what(), iex.errorCode()); - - while (more) - more = fOutputDL->next(fOutputIterator, &rgDataOut); - - fEndOfResult = true; - } - catch (const std::exception& ex) - { - handleException(ex.what(), ERR_IN_DELIVERY); - - while (more) - more = fOutputDL->next(fOutputIterator, &rgDataOut); - - fEndOfResult = true; - } catch (...) { - handleException("WindowFunctionStep caught an unknown exception", ERR_IN_DELIVERY); - + handleException(std::current_exception(), + logging::ERR_IN_DELIVERY, + logging::ERR_WF_DATA_SET_TOO_BIG, + "WindowFunctionStep::nextBand()"); while (more) more = fOutputDL->next(fOutputIterator, &rgDataOut); - fEndOfResult = true; } @@ -961,17 +945,12 @@ void WindowFunctionStep::execute() more = fInputDL->next(fInputIterator, &rgData); } } // try - catch (const IDBExcept& idb) - { - handleException(idb.what(), idb.errorCode()); - } - catch (const std::exception& ex) - { - handleException(ex.what(), ERR_READ_INPUT_DATALIST); - } catch (...) { - handleException("WindowFunctionStep caught an unknown exception", ERR_READ_INPUT_DATALIST); + handleException(std::current_exception(), + logging::ERR_READ_INPUT_DATALIST, + logging::ERR_WF_DATA_SET_TOO_BIG, + "WindowFunctionStep::execute()"); } if (traceOn()) @@ -1030,14 +1009,12 @@ void WindowFunctionStep::execute() } } - catch (const std::exception& ex) - { - handleException(ex.what(), ERR_EXECUTE_WINDOW_FUNCTION); - } catch (...) { - handleException("WindowFunctionStep caught an unknown exception", - ERR_EXECUTE_WINDOW_FUNCTION); + handleException(std::current_exception(), + logging::ERR_EXECUTE_WINDOW_FUNCTION, + logging::ERR_WF_DATA_SET_TOO_BIG, + "WindowFunctionStep::execute()"); } fOutputDL->endOfInput(); @@ -1084,21 +1061,15 @@ void WindowFunctionStep::doFunction() (*fFunctions[i].get())(); } } - catch (IDBExcept& iex) - { - handleException(iex.what(), iex.errorCode()); - } - catch (const std::exception& ex) - { - handleException(ex.what(), ERR_EXECUTE_WINDOW_FUNCTION); - } catch (...) { - handleException("doFunction caught an unknown exception", ERR_EXECUTE_WINDOW_FUNCTION); + handleException(std::current_exception(), + logging::ERR_EXECUTE_WINDOW_FUNCTION, + logging::ERR_WF_DATA_SET_TOO_BIG, + "WindowFunctionStep::doFunction()"); } } - void WindowFunctionStep::doPostProcessForSelect() { FuncExp* fe = funcexp::FuncExp::instance(); @@ -1197,13 +1168,6 @@ void WindowFunctionStep::doPostProcessForDml() } -void WindowFunctionStep::handleException(string errStr, int errCode) -{ - cerr << "Exception: " << errStr << endl; - catchHandler(errStr, errCode, fErrorInfo, fSessionId); -} - - boost::shared_ptr WindowFunctionStep::parseFrameBoundRows( const execplan::WF_Boundary& b, const map& m, diff --git a/dbcon/joblist/windowfunctionstep.h b/dbcon/joblist/windowfunctionstep.h index eaa020fc3..6cb51cb57 100644 --- a/dbcon/joblist/windowfunctionstep.h +++ b/dbcon/joblist/windowfunctionstep.h @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (c) 2016-2020 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -108,8 +109,6 @@ public: { return fRows; } - void handleException(std::string, int); - // for string table rowgroup::Row::Pointer getPointer(RowPosition& pos) { diff --git a/utils/loggingcpp/ErrorMessage.txt b/utils/loggingcpp/ErrorMessage.txt index 08233bbf6..e98a96f98 100755 --- a/utils/loggingcpp/ErrorMessage.txt +++ b/utils/loggingcpp/ErrorMessage.txt @@ -14,6 +14,9 @@ # The tokens should be separated by one tab character. The error message text may contain # any character(s) except tab. The line must end with a single '\n'. +# The id to treat all messages as CRITICAL +444 ERR_ALWAYS_CRITICAL + # Non support errors 1000 ~ 2000. # The query will go through the optimizer again with some optimization turned off 1000 ERR_MISS_JOIN %1% not joined. diff --git a/utils/windowfunction/windowfunction.cpp b/utils/windowfunction/windowfunction.cpp index 1f7e92c36..80a6c2ba5 100644 --- a/utils/windowfunction/windowfunction.cpp +++ b/utils/windowfunction/windowfunction.cpp @@ -212,17 +212,12 @@ void WindowFunction::operator()() } } } - catch (IDBExcept& iex) - { - fStep->handleException(iex.what(), iex.errorCode()); - } - catch (const std::exception& ex) - { - fStep->handleException(ex.what(), logging::ERR_EXECUTE_WINDOW_FUNCTION); - } catch (...) { - fStep->handleException("unknown exception", logging::ERR_EXECUTE_WINDOW_FUNCTION); + fStep->handleException(std::current_exception(), + logging::ERR_EXECUTE_WINDOW_FUNCTION, + logging::ERR_WF_DATA_SET_TOO_BIG, + "WindowFunction::operator()"); } }