diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp index 938f4c19071..6c32255e921 100644 --- a/ndb/include/mgmcommon/ConfigRetriever.hpp +++ b/ndb/include/mgmcommon/ConfigRetriever.hpp @@ -31,16 +31,10 @@ public: ConfigRetriever(LocalConfig &local_config, Uint32 version, Uint32 nodeType); ~ConfigRetriever(); - /** - * Read local config - * @return Own node id, -1 means fail - */ - int init(); - int do_connect(int exit_on_connect_failure= false); /** - * Get configuration for current (nodeId given in local config file) node. + * Get configuration for current node. * * Configuration is fetched from one MGM server configured in local config * file. The method loops over all the configured MGM servers and tries diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index c4957ffdbf1..b4f2d0b9897 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -52,6 +52,7 @@ ConfigRetriever::ConfigRetriever(LocalConfig &local_config, m_handle= 0; m_version = version; m_node_type = node_type; + _ownNodeId = _localConfig._ownNodeId; } ConfigRetriever::~ConfigRetriever(){ @@ -66,11 +67,6 @@ ConfigRetriever::~ConfigRetriever(){ //**************************************************************************** //**************************************************************************** -int -ConfigRetriever::init() { - return _ownNodeId = _localConfig._ownNodeId; -} - int ConfigRetriever::do_connect(int exit_on_connect_failure){ @@ -93,12 +89,18 @@ ConfigRetriever::do_connect(int exit_on_connect_failure){ BaseString tmp; for (unsigned int i = 0; i<_localConfig.ids.size(); i++){ MgmtSrvrId * m = &_localConfig.ids[i]; + DBUG_PRINT("info",("trying %s:%d", + m->name.c_str(), + m->port)); switch(m->type){ case MgmId_TCP: tmp.assfmt("%s:%d", m->name.c_str(), m->port); if (ndb_mgm_connect(m_handle, tmp.c_str()) == 0) { m_mgmd_port= m->port; m_mgmd_host= m->name.c_str(); + DBUG_PRINT("info",("connected to ndb_mgmd at %s:%d", + m_mgmd_host, + m_mgmd_port)); return 0; } setError(CR_RETRY, ndb_mgm_get_latest_error_desc(m_handle)); @@ -106,9 +108,10 @@ ConfigRetriever::do_connect(int exit_on_connect_failure){ break; } } - if (exit_on_connect_failure) - return 1; if(latestErrorType == CR_RETRY){ + DBUG_PRINT("info",("CR_RETRY")); + if (exit_on_connect_failure) + return 1; REPORT_WARNING("Failed to retrieve cluster configuration"); ndbout << "(Cause of failure: " << getErrorString() << ")" << endl; ndbout << "Attempt " << retry << " of " << retry_max << ". " diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 600e6f67910..fd5d79b92e7 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -196,13 +196,10 @@ Configuration::fetch_configuration(LocalConfig &local_config){ m_mgmd_port= 0; m_mgmd_host= 0; m_config_retriever= new ConfigRetriever(local_config, NDB_VERSION, NODE_TYPE_DB); - if(m_config_retriever->init() == -1 || - m_config_retriever->do_connect() == -1){ - + if(m_config_retriever->do_connect() == -1){ const char * s = m_config_retriever->getErrorString(); if(s == 0) s = "No error given!"; - /* Set stop on error to true otherwise NDB will go into an restart loop... */ diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index 688445125f3..5be4f0f9f91 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -60,6 +60,7 @@ void Ndb_cluster_connection::connect_thread() DBUG_ENTER("Ndb_cluster_connection::connect_thread"); int r; do { + NdbSleep_SecSleep(1); if ((r = connect(1)) == 0) break; if (r == -1) { @@ -80,6 +81,7 @@ int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void)) m_connect_callback= connect_callback; if ((r = connect(1)) == 1) { + DBUG_PRINT("info",("starting thread")); m_connect_thread= NdbThread_Create(run_ndb_cluster_connection_connect_thread, (void**)this, 32768, @@ -114,8 +116,6 @@ int Ndb_cluster_connection::connect(int reconnect) } } m_config_retriever= new ConfigRetriever(*m_local_config, NDB_VERSION, NODE_TYPE_API); - if(m_config_retriever->init() == -1) - break; } else if (reconnect == 0) @@ -131,6 +131,7 @@ int Ndb_cluster_connection::connect(int reconnect) else if(m_config_retriever->do_connect() == -1) break; + Uint32 nodeId = m_config_retriever->allocNodeId(); for(Uint32 i = 0; nodeId == 0 && i<5; i++){ NdbSleep_SecSleep(3); diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 2c330fae84d..07a1ade912a 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3746,12 +3746,14 @@ bool ndbcluster_init() { g_ndb->waitUntilReady(10); } - else if(res == 1 && g_ndb_cluster_connection->start_connect_thread()) + else if(res == 1) { - DBUG_PRINT("error", ("g_ndb_cluster_connection->start_connect_thread()")); - DBUG_RETURN(TRUE); + if (g_ndb_cluster_connection->start_connect_thread()) { + DBUG_PRINT("error", ("g_ndb_cluster_connection->start_connect_thread()")); + DBUG_RETURN(TRUE); + } } - else + else { DBUG_ASSERT(res == -1); DBUG_PRINT("error", ("permanent error")); @@ -3764,7 +3766,7 @@ bool ndbcluster_init() ndbcluster_inited= 1; #ifdef USE_DISCOVER_ON_STARTUP - if (ndb_discover_tables() != 0) + if (res == 0 && ndb_discover_tables() != 0) DBUG_RETURN(TRUE); #endif DBUG_RETURN(false);