Repository: incubator-trafodion Updated Branches: refs/heads/master 444cd9cc8 -> d02fe4781
[TRAFODION-1956] Timeout for arkcmp process A new CQD COMPILER_IDLE_TIMEOUT is added to control the compiler timeout duration. Default value is 1800 seconds. The compiler processes are killed when a SQL session ends at the time of ODBC/JDBC disconnection. For an active session the compiler process is killed when a compiler process remains idle more than the compiler idle timeout. The process in session needs to do some SQL for this feature to kick in. For the idle connected process, the connection idle timeout will enable killing compiler process. The compiler idle timeout will be honored but it would take at least connection idle timeout duration. Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/decb08cc Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/decb08cc Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/decb08cc Branch: refs/heads/master Commit: decb08cc3c928b4033cae28a81e0cc31b9d18d10 Parents: b3d3531 Author: selvaganesang <[email protected]> Authored: Wed May 18 00:35:55 2016 +0000 Committer: selvaganesang <[email protected]> Committed: Wed May 18 00:35:55 2016 +0000 ---------------------------------------------------------------------- core/sql/cli/Context.cpp | 27 ++++++++++++++++++++++----- core/sql/cli/Context.h | 1 + core/sql/cli/ExSqlComp.cpp | 5 ++++- core/sql/cli/ExSqlComp.h | 2 ++ core/sql/cli/SessionDefaults.cpp | 9 +++++++++ core/sql/cli/SessionDefaults.h | 12 +++++++++++- core/sql/cli/Statement.cpp | 2 +- core/sql/executor/ex_control.cpp | 12 ++++++++++++ core/sql/regress/executor/EXPECTED020 | 1 + core/sql/sqlcomp/DefaultConstants.h | 1 + core/sql/sqlcomp/nadefaults.cpp | 2 ++ 11 files changed, 66 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/cli/Context.cpp ---------------------------------------------------------------------- diff --git a/core/sql/cli/Context.cpp b/core/sql/cli/Context.cpp index 9ea6aca..43360b1 100644 --- a/core/sql/cli/Context.cpp +++ b/core/sql/cli/Context.cpp @@ -4037,11 +4037,7 @@ void ContextCli::endSession(NABoolean cleanupEsps, sessionInUse_ = FALSE; } - // kill mxcmp, if an inMemory table definition was created in mxcmp memory. - if (inMemoryObjectDefn()) - { - killAndRecreateMxcmp(); - } + killAndRecreateMxcmp(); if (rc < 0) { // an error was returned during drop of tables in the volatile schema. @@ -4943,6 +4939,27 @@ Lng32 parse_statsReq(short statsReqType,char *statsReqStr, Lng32 statsReqStrLen, return -1; } return 0; + +} + +void ContextCli::killIdleMxcmp() +{ + Int64 currentTimestamp = -1; + Int32 compilerIdleTimeout = getSessionDefaults()->getCompilerIdleTimeout(); + Int64 recentIpcTimestamp ; + + if (compilerIdleTimeout == 0) + return; + + if (arkcmpArray_.entries() == 0) + return; + if (arkcmpArray_[0]->getServer() != NULL) { + if (currentTimestamp == -1) + currentTimestamp = NA_JulianTimestamp(); + recentIpcTimestamp = arkcmpArray_[0]->getRecentIpcTimestamp(); + if (recentIpcTimestamp != -1 && (currentTimestamp - recentIpcTimestamp >= compilerIdleTimeout)) + killAndRecreateMxcmp(); + } } void ContextCli::killAndRecreateMxcmp() http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/cli/Context.h ---------------------------------------------------------------------- diff --git a/core/sql/cli/Context.h b/core/sql/cli/Context.h index ba556c0..c6ba4ea 100644 --- a/core/sql/cli/Context.h +++ b/core/sql/cli/Context.h @@ -981,6 +981,7 @@ SQLCLI_LIB_FUNC void initVolTabList(); void resetVolTabList(); + void killIdleMxcmp(); void killAndRecreateMxcmp(); #ifdef NA_DEBUG_C_RUNTIME http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/cli/ExSqlComp.cpp ---------------------------------------------------------------------- diff --git a/core/sql/cli/ExSqlComp.cpp b/core/sql/cli/ExSqlComp.cpp index 2d132b6..0b786a3 100644 --- a/core/sql/cli/ExSqlComp.cpp +++ b/core/sql/cli/ExSqlComp.cpp @@ -413,6 +413,7 @@ ExSqlComp::ReturnStatus ExSqlComp::sendR(CmpMessageObj* c, NABoolean w) // send the message. Int64 transid = cliGlobals_->currContext()->getTransaction()->getExeXnId(); + recentIpcTimestamp_ = NA_JulianTimestamp(); sqlcompMessage_->send(w, transid); if (badConnection_) @@ -443,6 +444,7 @@ ExSqlComp::ReturnStatus ExSqlComp::sendR(CmpMessageObj* c, NABoolean w) void ExSqlComp::completeRequests() { sqlcompMessage_->waitOnMsgStream(IpcInfiniteTimeout); + recentIpcTimestamp_ = NA_JulianTimestamp(); } // The return status of ERROR here is only useful for WAITED requests -- @@ -452,6 +454,7 @@ inline ExSqlComp::ReturnStatus ExSqlComp::waitForReply() { sqlcompMessage_->waitOnMsgStream(IpcImmediately); + recentIpcTimestamp_ = NA_JulianTimestamp(); return (outstandingSendBuffers_.ioStatus_ == FINISHED) ? SUCCESS : ERROR; } @@ -1007,7 +1010,7 @@ isShared_(FALSE), lastContext_(NULL), resendingControls_(FALSE) server_ = 0; diagArea_ = ComDiagsArea::allocate(h_); - + recentIpcTimestamp_ = -1; } ExSqlComp::~ExSqlComp() http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/cli/ExSqlComp.h ---------------------------------------------------------------------- diff --git a/core/sql/cli/ExSqlComp.h b/core/sql/cli/ExSqlComp.h index ea45bdf..83830a9 100644 --- a/core/sql/cli/ExSqlComp.h +++ b/core/sql/cli/ExSqlComp.h @@ -179,6 +179,7 @@ public: inline NABoolean badConnection() {return badConnection_; } inline NABoolean breakReceived() { return breakReceived_; } inline IpcServer *getServer() { return server_; } + inline Int64 getRecentIpcTimestamp() { return recentIpcTimestamp_; } ReturnStatus setDefaultCatAndSch(); @@ -269,6 +270,7 @@ private: char* replyData_; ULng32 replyDatalen_; ReturnStatus retval_; + Int64 recentIpcTimestamp_; }; // end of ExSqlComp // ----------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/cli/SessionDefaults.cpp ---------------------------------------------------------------------- diff --git a/core/sql/cli/SessionDefaults.cpp b/core/sql/cli/SessionDefaults.cpp index 1ce2145..c01dcf3 100644 --- a/core/sql/cli/SessionDefaults.cpp +++ b/core/sql/cli/SessionDefaults.cpp @@ -75,6 +75,7 @@ static const SessionDefaults::SessionDefaultMap sessionDefaultMap[] = SDEntry(SessionDefaults::CANCEL_QUERY_ALLOWED, CANCEL_QUERY_ALLOWED, SessionDefaults::SDT_BOOLEAN, FALSE, FALSE, TRUE, FALSE), SDEntry(SessionDefaults::CANCEL_UNIQUE_QUERY, CANCEL_UNIQUE_QUERY, SessionDefaults::SDT_BOOLEAN, FALSE, FALSE, TRUE, FALSE), SDEntry(SessionDefaults::CATALOG, CATALOG, SessionDefaults::SDT_ASCII, TRUE, TRUE, FALSE, FALSE), + SDEntry(SessionDefaults::COMPILER_IDLE_TIMEOUT, COMPILER_IDLE_TIMEOUT, SessionDefaults::SDT_BINARY_SIGNED, FALSE, TRUE, TRUE, TRUE), SDEntry(SessionDefaults::DBTR_PROCESS, DBTR_PROCESS, SessionDefaults::SDT_BOOLEAN, TRUE, FALSE, FALSE, FALSE), SDEntry(SessionDefaults::ESP_ASSIGN_DEPTH, ESP_ASSIGN_DEPTH, SessionDefaults::SDT_BINARY_SIGNED, FALSE, TRUE, TRUE, TRUE), SDEntry(SessionDefaults::ESP_ASSIGN_TIME_WINDOW, ESP_ASSIGN_TIME_WINDOW, SessionDefaults::SDT_BINARY_SIGNED, FALSE, TRUE, TRUE, TRUE), @@ -193,6 +194,8 @@ SessionDefaults::SessionDefaults(CollHeap * heap) setEspStopIdleTimeout(60); // Default is 1800 (idle ESPs time out in 30 minutes) setEspIdleTimeout(30*60); + // Default is 1800 (Compiler Idle time out in 30 minutes) + setCompilerIdleTimeout(30*60); // Default is 0 (inactive ESPs never time out) setEspInactiveTimeout(0); // how long master waits for release work reply from esps (default is 15 @@ -399,6 +402,12 @@ void SessionDefaults::setSessionDefaultAttributeValue } break; + case COMPILER_IDLE_TIMEOUT: + { + setCompilerIdleTimeout(defaultValueAsLong); + } + break; + case ESP_INACTIVE_TIMEOUT: { setEspInactiveTimeout(defaultValueAsLong); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/cli/SessionDefaults.h ---------------------------------------------------------------------- diff --git a/core/sql/cli/SessionDefaults.h b/core/sql/cli/SessionDefaults.h index 2520165..cdca15f 100644 --- a/core/sql/cli/SessionDefaults.h +++ b/core/sql/cli/SessionDefaults.h @@ -132,6 +132,7 @@ public: SUSPEND_LOGGING, USER_EXPERIENCE_LEVEL, WMS_PROCESS, + COMPILER_IDLE_TIMEOUT, LAST_SESSION_DEFAULT_ATTRIBUTE // This enum entry should be last always. Add new enums before this entry }; @@ -191,6 +192,12 @@ public: wmsProcess_ = v; updateDefaultsValueString(WMS_PROCESS, DisAmbiguate, wmsProcess_); } + + void setCompilerIdleTimeout(Lng32 compilerIdleTimeout) + { + compilerIdleTimeout_ = compilerIdleTimeout; + updateDefaultsValueString(COMPILER_IDLE_TIMEOUT, compilerIdleTimeout_); + } void setIsoMappingName(const char * attrValue, Lng32 attrValueLen); void setIsoMappingEnum(); @@ -470,6 +477,7 @@ public: Lng32 getEspAssignTimeWindow(){ return espAssignTimeWindow_; } Lng32 getEspStopIdleTimeout() { return espStopIdleTimeout_; } Lng32 getEspIdleTimeout() { return espIdleTimeout_; } + Lng32 getCompilerIdleTimeout() { return compilerIdleTimeout_; } Lng32 getEspInactiveTimeout() { return espInactiveTimeout_; } Lng32 getEspReleaseWorkTimeout() { return espReleaseWorkTimeout_; } Lng32 getMaxPollingInterval() { return maxPollingInterval_; } @@ -673,7 +681,9 @@ private: Lng32 espStopIdleTimeout_; // number of seconds an esp should wait idle before it times out Lng32 espIdleTimeout_; - // number of seconds an esp should remain inactive before times out + // number of seconds the compiler process can remain idle before it is killed by the master + Lng32 compilerIdleTimeout_; + // numcompilerIber of seconds an esp should remain inactive before times out Lng32 espInactiveTimeout_; // number of seconds that master waits for release work reply from esps Lng32 espReleaseWorkTimeout_; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/cli/Statement.cpp ---------------------------------------------------------------------- diff --git a/core/sql/cli/Statement.cpp b/core/sql/cli/Statement.cpp index 832e461..a1f2171 100644 --- a/core/sql/cli/Statement.cpp +++ b/core/sql/cli/Statement.cpp @@ -1872,7 +1872,7 @@ RETCODE Statement::prepare2(char *source, ComDiagsArea &diagsArea, } } // while retry - + context_->killIdleMxcmp(); assignRootTdb((ex_root_tdb *)fetched_gen_code); root_tdb_size = (Lng32) fetched_gen_code_len; } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/executor/ex_control.cpp ---------------------------------------------------------------------- diff --git a/core/sql/executor/ex_control.cpp b/core/sql/executor/ex_control.cpp index fc12254..3d93243 100644 --- a/core/sql/executor/ex_control.cpp +++ b/core/sql/executor/ex_control.cpp @@ -439,6 +439,12 @@ short ExControlTcb::work() currContext->getSessionDefaults()-> setEspIdleTimeout(lvl); } + else if (strcmp(value[1], "COMPILER_IDLE_TIMEOUT") == 0) + { + int lvl = (int) strtoul(value[2], NULL, 10); + currContext->getSessionDefaults()-> + setCompilerIdleTimeout(lvl); + } } } } @@ -516,6 +522,7 @@ short ExSetSessionDefaultTcb::work() (strcmp(defaultName, "ESP_ASSIGN_TIME_WINDOW") != 0) && (strcmp(defaultName, "ESP_STOP_IDLE_TIMEOUT") != 0) && (strcmp(defaultName, "ESP_IDLE_TIMEOUT") != 0) && + (strcmp(defaultName, "COMPILER_IDLE_TIMEOUT") != 0) && (strcmp(defaultName, "ESP_INACTIVE_TIMEOUT") != 0) && (strcmp(defaultName, "ESP_RELEASE_WORK_TIMEOUT") != 0) && (strcmp(defaultName, "MAX_POLLING_INTERVAL") != 0) && @@ -675,6 +682,11 @@ short ExSetSessionDefaultTcb::work() currContext->getSessionDefaults() ->setEspIdleTimeout(defaultValueAsLong); } + else if (strcmp(defaultName, "COMPILER_IDLE_TIMEOUT") == 0) + { + currContext->getSessionDefaults() + ->setCompilerIdleTimeout(defaultValueAsLong); + } else if (strcmp(defaultName, "ESP_INACTIVE_TIMEOUT") == 0) { currContext->getSessionDefaults() http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/regress/executor/EXPECTED020 ---------------------------------------------------------------------- diff --git a/core/sql/regress/executor/EXPECTED020 b/core/sql/regress/executor/EXPECTED020 index 5d2f932..de240ca 100644 --- a/core/sql/regress/executor/EXPECTED020 +++ b/core/sql/regress/executor/EXPECTED020 @@ -356,6 +356,7 @@ A B Current SESSION DEFAULTs ALTPRI_ESP FALSE ALTPRI_MASTER TRUE + COMPILER_IDLE_TIMEOUT 1800 ESP_ASSIGN_DEPTH -1 ESP_ASSIGN_TIME_WINDOW 60 ESP_CLOSE_ERROR_LOGGING FALSE http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/sqlcomp/DefaultConstants.h ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/DefaultConstants.h b/core/sql/sqlcomp/DefaultConstants.h index e8cf41d..8faee51 100644 --- a/core/sql/sqlcomp/DefaultConstants.h +++ b/core/sql/sqlcomp/DefaultConstants.h @@ -3817,6 +3817,7 @@ enum DefaultConstants // // 2 : todo HIVE_SCAN_SPECIAL_MODE, + COMPILER_IDLE_TIMEOUT, // This enum constant must be the LAST one in the list; it's a count, // not an Attribute (it's not IN DefaultDefaults; it's the SIZE of it)! __NUM_DEFAULT_ATTRIBUTES http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/decb08cc/core/sql/sqlcomp/nadefaults.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp index 1eb05cf..3ecefc3 100644 --- a/core/sql/sqlcomp/nadefaults.cpp +++ b/core/sql/sqlcomp/nadefaults.cpp @@ -593,6 +593,8 @@ SDDkwd__(CAT_ENABLE_QUERY_INVALIDATION, "ON"), DDkwd__(COLLECT_REORG_STATS, "ON"), + DDint__(COMPILER_IDLE_TIMEOUT, "1800"), // To match with set session defaults value + // tracking compilers specific defaults DDint__(COMPILER_TRACKING_INTERVAL, "0"), DD_____(COMPILER_TRACKING_LOGFILE, "NONE"),
