You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by se...@apache.org on 2017/10/27 16:02:56 UTC

[1/4] incubator-trafodion git commit: [TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver dumping core

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 371cb7110 -> acadd048d


[TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver dumping core

In case of Type 2 JDBC driver, the Trafodion SQL engine is a library that is dynamic
loaded into the process. Initialization of C++ static objects in the dynamic loaded libraries
are supposed to be done before dlopen returns. But the behavior seems to be nondeterministic when
there are multiple threads or when there are dependent static objects (An static object expects
another to be initialized before it). I think, the order of the initialization is not guaranteed
by the standard.

Refactored the code to initialize static object CharInfo::builtinCollationDB_ as part of the first
CLI call in a thread safe manner.


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

Branch: refs/heads/master
Commit: 9a8a7c39fecff583d2988c76fb443620ee64df24
Parents: 6b07d62
Author: selvaganesang <se...@esgyn.com>
Authored: Thu Oct 26 04:47:16 2017 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Thu Oct 26 04:47:16 2017 +0000

----------------------------------------------------------------------
 core/sql/cli/CliExtern.cpp   | 10 +++++++---
 core/sql/common/charinfo.cpp | 29 +++++++++++++++++++----------
 core/sql/common/charinfo.h   |  6 +++++-
 3 files changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9a8a7c39/core/sql/cli/CliExtern.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliExtern.cpp b/core/sql/cli/CliExtern.cpp
index d7454f9..8e03ff3 100644
--- a/core/sql/cli/CliExtern.cpp
+++ b/core/sql/cli/CliExtern.cpp
@@ -92,6 +92,7 @@ CLISemaphore globalSemaphore ;
 #include <unistd.h>
 #include "QRLogger.h"
 
+void initStaticVariables();
 extern char ** environ;
 
 // this is set to true after the first CLI call.
@@ -870,7 +871,8 @@ short sqInit()
       exit(1);
     }
 
-
+    // Initialize static variables
+    initStaticVariables();
     // Initialize an Instruction Info array's offset index
     ex_conv_clause::populateInstrOffsetIndex();
 
@@ -6998,5 +7000,7 @@ Lng32 SQL_EXEC_PutRoutine
 }
 #endif
 
-
-
+void initStaticVariables()
+{
+   CharInfo::initBuiltinCollationDB();
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9a8a7c39/core/sql/common/charinfo.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/charinfo.cpp b/core/sql/common/charinfo.cpp
index d52244e..c2cb8e2 100644
--- a/core/sql/common/charinfo.cpp
+++ b/core/sql/common/charinfo.cpp
@@ -103,7 +103,7 @@ static const struct mapCS mapCSArray[] = {
   { /*18*/ CharInfo::GBK,            SQLCHARSETSTRING_GBK,         3, TRUE,    FALSE,  1,    2, "?" },
 };
 
-static const size_t SIZEOF_CS = sizeof(mapCSArray)/sizeof(mapCS);
+#define SIZEOF_CS  (sizeof(mapCSArray)/sizeof(mapCS))
 
 const char* CharInfo::getCharSetName(CharSet cs, NABoolean retUnknownAsBlank)
 {
@@ -363,7 +363,7 @@ void CollationInfo::display() const
 CollationDB::CollationDB(CollHeap *h)
   : CollationDBSupertype(h), heap_(h), refreshNeeded_(TRUE)
 {
-    if (this == &CharInfo::builtinCollationDB_) return;
+    if (this == CharInfo::builtinCollationDB_) return;
     cmpCurrentContext->getCollationDBList()->insert(this);
 }
 
@@ -371,13 +371,14 @@ CollationDB::CollationDB(CollHeap *h, const CollationInfo *co, size_t count)
   : CollationDBSupertype(h), heap_(h), refreshNeeded_(!!count)
 { 
    while (count--) CollationDBSupertype::insert(co++);
-   if (this == &CharInfo::builtinCollationDB_) return;
-   cmpCurrentContext->getCollationDBList()->insert(this);
+   if (this == CharInfo::builtinCollationDB_) return;
+   if (cmpCurrentContext != NULL)
+      cmpCurrentContext->getCollationDBList()->insert(this);
 }
 
 CollationDB::~CollationDB()
 { 
-   if (this == &CharInfo::builtinCollationDB_) return;
+   if (this == CharInfo::builtinCollationDB_) return;
    clearAndReset();
    cmpCurrentContext->getCollationDBList()->remove(this);
 }
@@ -529,8 +530,10 @@ static const CollationInfo mapCOArray[] = {
   CollationInfo(NULL, CharInfo::UNKNOWN_COLLATION,  SQLCOLLATIONSTRING_UNKNOWN,
   			STATIC_NEG)
 };
-static const size_t SIZEOF_CO = sizeof(mapCOArray)/sizeof(CollationInfo);
-const CollationDB CharInfo::builtinCollationDB_(NULL, mapCOArray, SIZEOF_CO);
+
+#define SIZEOF_CO (sizeof(mapCOArray)/sizeof(CollationInfo))
+
+const CollationDB *CharInfo::builtinCollationDB_;
 
 CharInfo::Collation CharInfo::getCollationEnum(const char* name,
 					       NABoolean formatNSK,
@@ -550,18 +553,18 @@ CharInfo::Collation CharInfo::getCollationEnum(const char* name,
     return CharInfo::UNKNOWN_COLLATION;
 
   // Collapse any nonzero formatNSK to single bit, for XOR
-  return builtinCollationDB_.getCollationEnum(name, !!formatNSK, namlen);
+  return builtinCollationDB_->getCollationEnum(name, !!formatNSK, namlen);
 }
 
 const char* CharInfo::getCollationName(Collation co,
 				       NABoolean retUnknownAsBlank)
 {
-  return builtinCollationDB_.getCollationName(co, retUnknownAsBlank);
+  return builtinCollationDB_->getCollationName(co, retUnknownAsBlank);
 }
 
 Int32 CharInfo::getCollationFlags(Collation co)
 {
-  return builtinCollationDB_.getCollationFlags(co);
+  return builtinCollationDB_->getCollationFlags(co);
 }
 
 //****************************************************************************
@@ -693,3 +696,9 @@ Int32 CharInfo::getMaxConvertedLenInBytes(CharSet sourceCS,
   return ((sourceLenInBytes/minBytesPerChar(sourceCS)) *
           maxBytesPerChar(targetCS));
 }
+
+void CharInfo::initBuiltinCollationDB()
+{
+   builtinCollationDB_ = new CollationDB(NULL, mapCOArray, SIZEOF_CO);
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9a8a7c39/core/sql/common/charinfo.h
----------------------------------------------------------------------
diff --git a/core/sql/common/charinfo.h b/core/sql/common/charinfo.h
index 88aceb0..e9cfcbf 100644
--- a/core/sql/common/charinfo.h
+++ b/core/sql/common/charinfo.h
@@ -50,6 +50,7 @@
 #include "NAWinNT.h"
 #include "ComCharSetDefs.h"
 #include "sql_charset_strings.h"
+#include "charinfo.h"
 
 // Forward references
 class ComMPLoc;
@@ -260,11 +261,14 @@ public:
                                          Int32   sourceLenInBytes,
                                          CharSet targetCS);
 
+  static void initBuiltinCollationDB();
+ 
+
 private:
 friend class CollationDB;			// needs to access builtinCDB_
 
    static const char*	const localeCharSet_;
-   static const CollationDB   builtinCollationDB_;
+   static const CollationDB   *builtinCollationDB_;
 
 }; // CharInfo
 


[3/4] incubator-trafodion git commit: [TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver

Posted by se...@apache.org.
[TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver

Reworked the code as per the comment in the git


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

Branch: refs/heads/master
Commit: ef881cf53838c6cb0250fb4587b386379e6c7c6e
Parents: c792319
Author: selvaganesang <se...@esgyn.com>
Authored: Thu Oct 26 19:42:17 2017 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Thu Oct 26 19:42:17 2017 +0000

----------------------------------------------------------------------
 core/sql/cli/CliExtern.cpp   | 12 ------------
 core/sql/cli/CliSemaphore.h  |  1 +
 core/sql/cli/Globals.cpp     | 10 ++--------
 core/sql/common/charinfo.cpp | 29 +++++++++++++++++++++--------
 core/sql/common/charinfo.h   |  2 +-
 5 files changed, 25 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/cli/CliExtern.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliExtern.cpp b/core/sql/cli/CliExtern.cpp
index 8e03ff3..38a766c 100644
--- a/core/sql/cli/CliExtern.cpp
+++ b/core/sql/cli/CliExtern.cpp
@@ -77,10 +77,6 @@
 #include "dfs2rec.h"
 #include "Statement.h"
 #include "ComSqlId.h"
-
-CLISemaphore globalSemaphore ;
-
-
 #include "seabed/ms.h"
 #include "seabed/fs.h"
 #include "seabed/fserr.h"
@@ -92,7 +88,6 @@ CLISemaphore globalSemaphore ;
 #include <unistd.h>
 #include "QRLogger.h"
 
-void initStaticVariables();
 extern char ** environ;
 
 // this is set to true after the first CLI call.
@@ -871,8 +866,6 @@ short sqInit()
       exit(1);
     }
 
-    // Initialize static variables
-    initStaticVariables();
     // Initialize an Instruction Info array's offset index
     ex_conv_clause::populateInstrOffsetIndex();
 
@@ -6999,8 +6992,3 @@ Lng32 SQL_EXEC_PutRoutine
 #ifdef __cplusplus
 }
 #endif
-
-void initStaticVariables()
-{
-   CharInfo::initBuiltinCollationDB();
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/cli/CliSemaphore.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/CliSemaphore.h b/core/sql/cli/CliSemaphore.h
index 84ad90e..980fc54 100644
--- a/core/sql/cli/CliSemaphore.h
+++ b/core/sql/cli/CliSemaphore.h
@@ -83,5 +83,6 @@ inline CLISemaphore::~CLISemaphore()
    DeleteCriticalSection(&cs);
 }
 
+extern CLISemaphore globalSemaphore;
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/cli/Globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Globals.cpp b/core/sql/cli/Globals.cpp
index 32cb6b0..b9dd6e5 100644
--- a/core/sql/cli/Globals.cpp
+++ b/core/sql/cli/Globals.cpp
@@ -66,15 +66,9 @@
 
 
 #include "ExCextdecs.h"
-#ifndef NA_NO_GLOBAL_EXE_VARS
-// if global variables are allowed in the CLI, and if there isn't
-// a cheat define set, then simply define the CLI globals here
-#ifndef CLI_GLOBALS_DEF_
 CliGlobals * cli_globals = NULL;
-#endif
-// On NSK we store the cli globals in a flat segment with a fixed
-// segment id.
-#endif
+
+CLISemaphore globalSemaphore ;
 
 #include "CmpContext.h"
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/common/charinfo.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/charinfo.cpp b/core/sql/common/charinfo.cpp
index c2cb8e2..547e09c 100644
--- a/core/sql/common/charinfo.cpp
+++ b/core/sql/common/charinfo.cpp
@@ -54,6 +54,7 @@
 #include "CmpConnection.h"
 #include "CmpContext.h"
 #include "CmpCommon.h"
+#include "CliSemaphore.h"
 
 using namespace std;
 
@@ -364,7 +365,8 @@ CollationDB::CollationDB(CollHeap *h)
   : CollationDBSupertype(h), heap_(h), refreshNeeded_(TRUE)
 {
     if (this == CharInfo::builtinCollationDB_) return;
-    cmpCurrentContext->getCollationDBList()->insert(this);
+    if (cmpCurrentContext != NULL)
+       cmpCurrentContext->getCollationDBList()->insert(this);
 }
 
 CollationDB::CollationDB(CollHeap *h, const CollationInfo *co, size_t count)
@@ -430,7 +432,8 @@ CollationDB * CollationDB::nextCDB() const
 
 const CollationInfo* CollationDB::getCollationInfo(CharInfo::Collation co) const
 {
-  CollIndex i, n = entries();
+  CollIndex i, n;
+  n = entries();
   for (i = 0; i < n; i++)
     if (co == at(i)->co_)
       return at(i);
@@ -533,7 +536,7 @@ static const CollationInfo mapCOArray[] = {
 
 #define SIZEOF_CO (sizeof(mapCOArray)/sizeof(CollationInfo))
 
-const CollationDB *CharInfo::builtinCollationDB_;
+const CollationDB *CharInfo::builtinCollationDB_ = NULL;
 
 CharInfo::Collation CharInfo::getCollationEnum(const char* name,
 					       NABoolean formatNSK,
@@ -553,18 +556,18 @@ CharInfo::Collation CharInfo::getCollationEnum(const char* name,
     return CharInfo::UNKNOWN_COLLATION;
 
   // Collapse any nonzero formatNSK to single bit, for XOR
-  return builtinCollationDB_->getCollationEnum(name, !!formatNSK, namlen);
+  return builtinCollationDB()->getCollationEnum(name, !!formatNSK, namlen);
 }
 
 const char* CharInfo::getCollationName(Collation co,
 				       NABoolean retUnknownAsBlank)
 {
-  return builtinCollationDB_->getCollationName(co, retUnknownAsBlank);
+  return builtinCollationDB()->getCollationName(co, retUnknownAsBlank);
 }
 
 Int32 CharInfo::getCollationFlags(Collation co)
 {
-  return builtinCollationDB_->getCollationFlags(co);
+  return builtinCollationDB()->getCollationFlags(co);
 }
 
 //****************************************************************************
@@ -697,8 +700,18 @@ Int32 CharInfo::getMaxConvertedLenInBytes(CharSet sourceCS,
           maxBytesPerChar(targetCS));
 }
 
-void CharInfo::initBuiltinCollationDB()
+const CollationDB *CharInfo::builtinCollationDB()
 {
-   builtinCollationDB_ = new CollationDB(NULL, mapCOArray, SIZEOF_CO);
+   if (CharInfo::builtinCollationDB_ != NULL)
+      return CharInfo::builtinCollationDB_;
+   globalSemaphore.get(); 
+   if (CharInfo::builtinCollationDB_ != NULL) 
+   {
+      globalSemaphore.release();
+      return CharInfo::builtinCollationDB_;
+   }
+   CharInfo::builtinCollationDB_ = new CollationDB(NULL, mapCOArray, SIZEOF_CO);
+   globalSemaphore.release();
+   return CharInfo::builtinCollationDB_;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef881cf5/core/sql/common/charinfo.h
----------------------------------------------------------------------
diff --git a/core/sql/common/charinfo.h b/core/sql/common/charinfo.h
index 8857613..0864a4e 100644
--- a/core/sql/common/charinfo.h
+++ b/core/sql/common/charinfo.h
@@ -260,7 +260,7 @@ public:
                                          Int32   sourceLenInBytes,
                                          CharSet targetCS);
 
-  static void initBuiltinCollationDB();
+  static const CollationDB *builtinCollationDB();
  
 
 private:


[4/4] incubator-trafodion git commit: Merge PR 1277 [TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver

Posted by se...@apache.org.
Merge PR 1277 [TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver


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

Branch: refs/heads/master
Commit: acadd048d0a756f43e2c789db23943c79a8c4e87
Parents: 371cb71 ef881cf
Author: selvaganesang <se...@apache.org>
Authored: Fri Oct 27 16:01:18 2017 +0000
Committer: selvaganesang <se...@apache.org>
Committed: Fri Oct 27 16:01:18 2017 +0000

----------------------------------------------------------------------
 core/sql/cli/CliExtern.cpp   |  8 -------
 core/sql/cli/CliSemaphore.h  |  1 +
 core/sql/cli/Globals.cpp     | 10 ++-------
 core/sql/common/charinfo.cpp | 46 +++++++++++++++++++++++++++++----------
 core/sql/common/charinfo.h   |  5 ++++-
 5 files changed, 41 insertions(+), 29 deletions(-)
----------------------------------------------------------------------



[2/4] incubator-trafodion git commit: [TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver dumping core

Posted by se...@apache.org.
[TRAFODION-2783] jdbc_test_cdh fails at times with type 2 JDBC driver dumping core

Removed recursive inclusion of charinfo.h


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

Branch: refs/heads/master
Commit: c79231924bd148aca43827e19694c85941825959
Parents: 9a8a7c3
Author: selvaganesang <se...@esgyn.com>
Authored: Thu Oct 26 05:03:07 2017 +0000
Committer: selvaganesang <se...@esgyn.com>
Committed: Thu Oct 26 05:03:07 2017 +0000

----------------------------------------------------------------------
 core/sql/common/charinfo.h | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/c7923192/core/sql/common/charinfo.h
----------------------------------------------------------------------
diff --git a/core/sql/common/charinfo.h b/core/sql/common/charinfo.h
index e9cfcbf..8857613 100644
--- a/core/sql/common/charinfo.h
+++ b/core/sql/common/charinfo.h
@@ -50,7 +50,6 @@
 #include "NAWinNT.h"
 #include "ComCharSetDefs.h"
 #include "sql_charset_strings.h"
-#include "charinfo.h"
 
 // Forward references
 class ComMPLoc;