From 9b1157537b5a1a054e936a01712d628f80fca9f5 Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Wed, 9 May 2007 14:31:22 +0200 Subject: [PATCH 1/2] Bug #28287 Sign problem in test "ndb_restore_print" - corrected previous patch - some platforms do strange things with char... use Int8 to be sure of signedness --- ndb/include/ndbapi/NdbRecAttr.hpp | 32 +++++++++++++++++++++++++++++-- ndb/src/ndbapi/NdbRecAttr.cpp | 6 +++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/ndb/include/ndbapi/NdbRecAttr.hpp b/ndb/include/ndbapi/NdbRecAttr.hpp index 92cd5706a8d..9679d3995d3 100644 --- a/ndb/include/ndbapi/NdbRecAttr.hpp +++ b/ndb/include/ndbapi/NdbRecAttr.hpp @@ -164,7 +164,14 @@ public: * * @return Char value. */ - Int8 char_value() const; + char char_value() const; + + /** + * Get value stored in NdbRecAttr object. + * + * @return Int8 value. + */ + Int8 int8_value() const; /** * Get value stored in NdbRecAttr object. @@ -201,6 +208,13 @@ public: */ Uint8 u_char_value() const; + /** + * Get value stored in NdbRecAttr object. + * + * @return Uint8 value. + */ + Uint8 u_8_value() const; + /** * Get value stored in NdbRecAttr object. * @@ -340,8 +354,15 @@ NdbRecAttr::short_value() const } inline -Int8 +char NdbRecAttr::char_value() const +{ + return *(char*)theRef; +} + +inline +Int8 +NdbRecAttr::int8_value() const { return *(Int8*)theRef; } @@ -367,6 +388,13 @@ NdbRecAttr::u_char_value() const return *(Uint8*)theRef; } +inline +Uint8 +NdbRecAttr::u_8_value() const +{ + return *(Uint8*)theRef; +} + inline void NdbRecAttr::release() diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 996c0256baa..8de163d1c22 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -272,7 +272,7 @@ ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r, out << r.u_short_value(); break; case NdbDictionary::Column::Tinyunsigned: - out << (unsigned) r.u_char_value(); + out << (unsigned) r.u_8_value(); break; case NdbDictionary::Column::Bigint: out << r.int64_value(); @@ -287,7 +287,7 @@ ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r, out << r.short_value(); break; case NdbDictionary::Column::Tinyint: - out << (int) r.char_value(); + out << (int) r.int8_value(); break; case NdbDictionary::Column::Binary: if (!f.hex_format) @@ -413,7 +413,7 @@ ndbrecattr_print_formatted(NdbOut& out, const NdbRecAttr &r, break; case NdbDictionary::Column::Year: { - uint year = 1900 + r.u_char_value(); + uint year = 1900 + r.u_8_value(); char buf[40]; sprintf(buf, "%04d", year); out << buf; From ef1fdd301748d3f7eb03d1097470af1005db5716 Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Wed, 9 May 2007 15:03:01 +0200 Subject: [PATCH 2/2] enable setting api reg req frequency to be higher than heartbeat setting to ensure we have reasonably up-to-date info from ndb nodes + do this for management server --- ndb/src/mgmsrv/MgmtSrvr.cpp | 10 ++++++++++ ndb/src/ndbapi/ClusterMgr.cpp | 13 ++++--------- ndb/src/ndbapi/ClusterMgr.hpp | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 3d7eb5bd4f1..409694fead1 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -627,6 +627,16 @@ MgmtSrvr::start(BaseString &error_string) ndbout_c("This is probably a bug."); } + /* + set api reg req frequency quite high: + + 100 ms interval to make sure we have fairly up-to-date + info from the nodes. This to make sure that this info + is not dependent on heart beat settings in the + configuration + */ + theFacade->theClusterMgr->set_max_api_reg_req_interval(100); + TransporterRegistry *reg = theFacade->get_registry(); for(unsigned int i=0;im_transporter_interface.size();i++) { BaseString msg; diff --git a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp index 7ab3ee07197..d3946dddfb7 100644 --- a/ndb/src/ndbapi/ClusterMgr.cpp +++ b/ndb/src/ndbapi/ClusterMgr.cpp @@ -68,6 +68,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade): clusterMgrThreadMutex = NdbMutex_Create(); waitForHBCond= NdbCondition_Create(); waitingForHB= false; + m_max_api_reg_req_interval= 0xFFFFFFFF; // MAX_INT noOfAliveNodes= 0; noOfConnectedNodes= 0; theClusterMgrThread= 0; @@ -251,7 +252,7 @@ ClusterMgr::threadMain( ){ * Start of Secure area for use of Transporter */ theFacade.lock_mutex(); - for (int i = 1; i < MAX_NODES; i++){ + for (int i = 1; i < MAX_NDB_NODES; i++){ /** * Send register request (heartbeat) to all available nodes * at specified timing intervals @@ -272,7 +273,8 @@ ClusterMgr::threadMain( ){ } theNode.hbCounter += timeSlept; - if (theNode.hbCounter >= theNode.hbFrequency) { + if (theNode.hbCounter >= m_max_api_reg_req_interval || + theNode.hbCounter >= theNode.hbFrequency) { /** * It is now time to send a new Heartbeat */ @@ -281,13 +283,6 @@ ClusterMgr::threadMain( ){ theNode.hbCounter = 0; } - /** - * If the node is of type REP, - * then the receiver of the signal should be API_CLUSTERMGR - */ - if (theNode.m_info.m_type == NodeInfo::REP) { - signal.theReceiversBlockNumber = API_CLUSTERMGR; - } #ifdef DEBUG_REG ndbout_c("ClusterMgr: Sending API_REGREQ to node %d", (int)nodeId); #endif diff --git a/ndb/src/ndbapi/ClusterMgr.hpp b/ndb/src/ndbapi/ClusterMgr.hpp index f5d84fee01d..467b18f2330 100644 --- a/ndb/src/ndbapi/ClusterMgr.hpp +++ b/ndb/src/ndbapi/ClusterMgr.hpp @@ -50,6 +50,7 @@ public: void startThread(); void forceHB(); + void set_max_api_reg_req_interval(unsigned int millisec) { m_max_api_reg_req_interval = millisec; } private: void threadMain(); @@ -83,6 +84,7 @@ public: Uint32 m_connect_count; private: + Uint32 m_max_api_reg_req_interval; Uint32 noOfAliveNodes; Uint32 noOfConnectedNodes; Node theNodes[MAX_NODES];