[TRAFODION-2963] RMS infrastructure now reads the configured pid Max from 
/proc/sys/kernel/pid_max

Changes to avoid log storm when there is a pid violation


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/0f04ef97
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/0f04ef97
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/0f04ef97

Branch: refs/heads/master
Commit: 0f04ef978472adadc0fad4d534b7ea9515ba2ceb
Parents: a972349
Author: selvaganesang <[email protected]>
Authored: Wed Jun 27 23:05:02 2018 +0000
Committer: selvaganesang <[email protected]>
Committed: Wed Jun 27 23:05:02 2018 +0000

----------------------------------------------------------------------
 core/sql/cli/Globals.cpp              |  8 ++------
 core/sql/executor/ex_esp_frag_dir.cpp |  8 ++------
 core/sql/runtimestats/SqlStats.cpp    | 15 +++++++++++++++
 core/sql/runtimestats/SqlStats.h      |  4 ++++
 4 files changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/0f04ef97/core/sql/cli/Globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Globals.cpp b/core/sql/cli/Globals.cpp
index 4e2b144..6f498fb 100644
--- a/core/sql/cli/Globals.cpp
+++ b/core/sql/cli/Globals.cpp
@@ -179,16 +179,12 @@ void CliGlobals::init( NABoolean espProcess,
     statsGlobals_ = (StatsGlobals *)shareStatsSegment(shmId_);
     NABoolean reportError = FALSE;
     char msg[256];;
-    if (statsGlobals_ != NULL && myPin_ >= 
statsGlobals_->getConfiguredPidMax())
-       reportError = TRUE;
     if ((statsGlobals_ == NULL)
-      || ((statsGlobals_ != NULL) && 
-        ((statsGlobals_->getVersion() != 
StatsGlobals::CURRENT_SHARED_OBJECTS_VERSION_) ||
-        (myPin_ >= statsGlobals_->getConfiguredPidMax()))))
+      || ((statsGlobals_ != NULL) && (statsGlobals_->getInitError(myPin_, 
reportError))))
     {
       if (reportError) {
          snprintf(msg, sizeof(msg),
-          "Pid %d,%d is higher than the configured pid max %d",
+          "Version mismatch or Pid %d,%d is higher than the configured pid max 
%d",
            myCpu_, myPin_, statsGlobals_->getConfiguredPidMax());
          SQLMXLoggingArea::logExecRtInfo(__FILE__, __LINE__, msg, 0);
       }

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0f04ef97/core/sql/executor/ex_esp_frag_dir.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_esp_frag_dir.cpp 
b/core/sql/executor/ex_esp_frag_dir.cpp
index 233f952..e0205f0 100644
--- a/core/sql/executor/ex_esp_frag_dir.cpp
+++ b/core/sql/executor/ex_esp_frag_dir.cpp
@@ -103,16 +103,12 @@ ExEspFragInstanceDir::ExEspFragInstanceDir(CliGlobals 
*cliGlobals,
   tid_ = syscall(SYS_gettid);
   NABoolean reportError = FALSE;
   char msg[256];;
-  if (statsGlobals_ != NULL && pid_ >= statsGlobals_->getConfiguredPidMax())
-     reportError = TRUE;
   if ((statsGlobals_ == NULL)
-     || ((statsGlobals_ != NULL) && 
-        ((statsGlobals_->getVersion() != 
StatsGlobals::CURRENT_SHARED_OBJECTS_VERSION_) ||
-        (pid_ >= statsGlobals_->getConfiguredPidMax()))))
+     || ((statsGlobals_ != NULL) &&  (statsGlobals_->getInitError(pid_, 
reportError))))
   {
     if (reportError) {
          snprintf(msg, sizeof(msg), 
-          "Pid %d,%d is higher than the configured pid max %d",
+          "Version mismatch or Pid %d,%d is higher than the configured pid max 
%d",
            cpu_, pid_, statsGlobals_->getConfiguredPidMax()); 
          SQLMXLoggingArea::logExecRtInfo(__FILE__, __LINE__, msg, 0);
     }

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0f04ef97/core/sql/runtimestats/SqlStats.cpp
----------------------------------------------------------------------
diff --git a/core/sql/runtimestats/SqlStats.cpp 
b/core/sql/runtimestats/SqlStats.cpp
index dc25b52..3fcf9d3 100644
--- a/core/sql/runtimestats/SqlStats.cpp
+++ b/core/sql/runtimestats/SqlStats.cpp
@@ -74,6 +74,7 @@ StatsGlobals::StatsGlobals(void *baseAddr, short envType, 
Lng32 maxSegSize)
       , pidToCheck_(0)
       , ssmpDumpedTimestamp_(0)
       , lobLocks_(NULL)
+      , pidViolationCount_(0)
 {
   statsHeap_.setSharedMemory();
   //Phandle wrapper in porting layer
@@ -1616,6 +1617,20 @@ void StatsGlobals::createMemoryMonitor()
    memMonitor_->enableLogger();
 }
 
+NABoolean StatsGlobals::getInitError(pid_t pid, NABoolean &reportError)
+{
+   NABoolean retcode = FALSE;
+   reportError = FALSE; 
+   if ((getVersion() != StatsGlobals::CURRENT_SHARED_OBJECTS_VERSION_) ||
+        (pid >= configuredPidMax_))
+   {
+      retcode = TRUE;
+      if (pidViolationCount_++ < PID_VIOLATION_MAX_COUNT) 
+         reportError = TRUE;
+   } 
+   return retcode; 
+}
+
 short getMasterCpu(char *uniqueStmtId, Lng32 uniqueStmtIdLen, char *nodeName, 
short maxLen, short &cpu)
 {
   Int32 nodeNumber = 0;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0f04ef97/core/sql/runtimestats/SqlStats.h
----------------------------------------------------------------------
diff --git a/core/sql/runtimestats/SqlStats.h b/core/sql/runtimestats/SqlStats.h
index 8e7dbeb..1cfc18f 100644
--- a/core/sql/runtimestats/SqlStats.h
+++ b/core/sql/runtimestats/SqlStats.h
@@ -72,6 +72,7 @@ class MemoryMonitor;
 #define PID_MAX_DEFAULT     65536
 #define PID_MAX_DEFAULT_MAX 131072
 #define PID_MAX_DEFAULT_MIN 32768
+#define PID_VIOLATION_MAX_COUNT 100
 
 typedef struct GlobalStatsArray
 {
@@ -201,6 +202,7 @@ public:
   RtsExplainFrag *getExplainInfo() { return explainInfo_; }
   void deleteExplainFrag();
   ULng32 getFlags() const { return flags_; }
+  NABoolean reportError(pid_t pid);
 private:
   enum Flags
   {
@@ -496,6 +498,7 @@ public:
   Long &getSsmpProcSemId() { return ssmpProcSemId_; } 
   void setSscpProcSemId(Long semId) { sscpProcSemId_ = semId; } 
   void setSeabedError(Int32 error) { seabedError_ = error; }
+  NABoolean getInitError(pid_t pid, NABoolean &reportError );
 private:
   void *statsSharedSegAddr_;
   Lng32 version_;             // A field used to prevent downrev compiler or 
other 
@@ -536,6 +539,7 @@ private:
   MemoryMonitor *memMonitor_;
   SyncHashQueue *lobLocks_;
   pid_t configuredPidMax_;
+  Int64 pidViolationCount_;
 };
 StatsGlobals * shareStatsSegment(Int32 &shmid, NABoolean checkForSSMP = TRUE);
 short getMasterCpu(char *uniqueStmtId, Lng32 uniqueStmtIdLen, char *nodeName, 
short maxLen, short &cpu);

Reply via email to