summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-10-03 21:39:04 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-10-03 21:39:04 +0000
commit6b1895b86400e8531dd99b89421bc44984568ed8 (patch)
treeaba1618cac773466e58a7ff45f66bb205fe52130 /ndb
parent3a15d0884d0b9a248d2f3b0f66a05c35b942badc (diff)
parent25bcfeef6093dfdfcd84323dc1ed4723ea71f7fc (diff)
downloadmariadb-git-6b1895b86400e8531dd99b89421bc44984568ed8.tar.gz
Merge
BitKeeper/etc/logging_ok: auto-union sql/ha_ndbcluster.h: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/mysql_priv.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged mysql-test/mysql-test-run.sh: SCCS merged sql/ha_ndbcluster.cc: SCCS merged
Diffstat (limited to 'ndb')
-rw-r--r--ndb/include/ndbapi/Ndb.hpp5
-rw-r--r--ndb/src/mgmsrv/ConfigInfo.cpp108
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.cpp10
-rw-r--r--ndb/src/ndbapi/TransporterFacade.cpp10
-rw-r--r--ndb/src/ndbapi/ndb_cluster_connection.cpp3
5 files changed, 124 insertions, 12 deletions
diff --git a/ndb/include/ndbapi/Ndb.hpp b/ndb/include/ndbapi/Ndb.hpp
index 9d0e9714eef..550d0c0931a 100644
--- a/ndb/include/ndbapi/Ndb.hpp
+++ b/ndb/include/ndbapi/Ndb.hpp
@@ -1087,8 +1087,6 @@ public:
int waitUntilReady(int timeout = 60);
- void connected(Uint32 block_reference);
-
/** @} *********************************************************************/
/**
@@ -1447,6 +1445,9 @@ private:
void setup(Ndb_cluster_connection *ndb_cluster_connection,
const char* aCatalogName, const char* aSchemaName);
+ void connected(Uint32 block_reference);
+
+
NdbConnection* startTransactionLocal(Uint32 aPrio, Uint32 aFragmentId);
// Connect the connection object to the Database.
diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp
index 0b7c664dfd3..e8f768d1968 100644
--- a/ndb/src/mgmsrv/ConfigInfo.cpp
+++ b/ndb/src/mgmsrv/ConfigInfo.cpp
@@ -3479,8 +3479,9 @@ check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx,
const char * rule_data)
{
- Uint32 db_nodes = 0;
- Uint32 replicas = 0;
+ Uint32 db_nodes= 0;
+ Uint32 replicas= 0;
+ Uint32 db_host_count= 0;
ctx.m_userProperties.get(DB_TOKEN, &db_nodes);
ctx.m_userProperties.get("NoOfReplicas", &replicas);
if((db_nodes % replicas) != 0){
@@ -3488,7 +3489,108 @@ check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections,
"No of nodes must be dividable with no or replicas");
return false;
}
-
+ // check that node groups and arbitrators are ok
+ // just issue warning if not
+ if(replicas > 1){
+ Properties * props= ctx.m_config;
+ Properties p_db_hosts(true); // store hosts which db nodes run on
+ Properties p_arbitrators(true); // store hosts which arbitrators run on
+ // arbitrator should not run together with db node on same host
+ Uint32 i, n, group= 0, i_group= 0;
+ Uint32 n_nodes;
+ BaseString node_group_warning, arbitration_warning;
+ const char *arbit_warn_fmt=
+ "\n arbitrator with id %d and db node with id %d on same host %s";
+
+ ctx.m_userProperties.get("NoOfNodes", &n_nodes);
+ for (i= 0, n= 0; n < n_nodes; i++){
+ const Properties * tmp;
+ if(!props->get("Node", i, &tmp)) continue;
+ n++;
+
+ const char * type;
+ if(!tmp->get("Type", &type)) continue;
+
+ const char* host= 0;
+ tmp->get("HostName", &host);
+
+ if (strcmp(type,DB_TOKEN) == 0)
+ {
+ {
+ Uint32 ii;
+ if (!p_db_hosts.get(host,&ii))
+ db_host_count++;
+ p_db_hosts.put(host,i);
+ if (p_arbitrators.get(host,&ii))
+ {
+ arbitration_warning.appfmt(arbit_warn_fmt, ii, i, host);
+ p_arbitrators.remove(host); // only one warning per db node
+ }
+ }
+ {
+ unsigned j;
+ BaseString str, str2;
+ str.assfmt("#group%d_",group);
+ p_db_hosts.put(str.c_str(),i_group,host);
+ str2.assfmt("##group%d_",group);
+ p_db_hosts.put(str2.c_str(),i_group,i);
+ for (j= 0; j < i_group; j++)
+ {
+ const char *other_host;
+ p_db_hosts.get(str.c_str(),j,&other_host);
+ if (strcmp(host,other_host) == 0) {
+ unsigned int other_i, c= 0;
+ p_db_hosts.get(str2.c_str(),j,&other_i);
+ p_db_hosts.get(str.c_str(),&c);
+ if (c == 0) // first warning in this node group
+ node_group_warning.appfmt(" Node group %d", group);
+ c|= 1 << j;
+ p_db_hosts.put(str.c_str(),c);
+
+ node_group_warning.appfmt(",\n db node with id %d and id %d "
+ "on same host %s", other_i, i, host);
+ }
+ }
+ i_group++;
+ DBUG_ASSERT(i_group <= replicas);
+ if (i_group == replicas)
+ {
+ unsigned c= 0;
+ p_db_hosts.get(str.c_str(),&c);
+ if (c+1 == (1 << (replicas-1))) // all nodes on same machine
+ node_group_warning.append(".\n Host failure will "
+ "cause complete cluster shutdown.");
+ else if (c > 0)
+ node_group_warning.append(".\n Host failure may "
+ "cause complete cluster shutdown.");
+ group++;
+ i_group= 0;
+ }
+ }
+ }
+ else if (strcmp(type,API_TOKEN) == 0 ||
+ strcmp(type,MGM_TOKEN) == 0)
+ {
+ Uint32 rank;
+ if(tmp->get("ArbitrationRank", &rank) && rank > 0)
+ {
+ if(host && host[0] != 0)
+ {
+ Uint32 ii;
+ p_arbitrators.put(host,i);
+ if (p_db_hosts.get(host,&ii))
+ {
+ arbitration_warning.appfmt(arbit_warn_fmt, i, ii, host);
+ }
+ }
+ }
+ }
+ }
+ if (db_host_count > 1 && node_group_warning.length() > 0)
+ ndbout_c("Cluster configuration warning:\n%s",node_group_warning.c_str());
+ if (db_host_count > 1 && arbitration_warning.length() > 0)
+ ndbout_c("Cluster configuration warning:%s",arbitration_warning.c_str());
+ }
return true;
}
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index 9abe52fb030..b9b932663f6 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -868,6 +868,8 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal,
const int noerrcodes,
const int temporaryMask)
{
+ DBUG_ENTER("NdbDictInterface::dictSignal");
+ DBUG_PRINT("enter", ("useMasterNodeId: %d", useMasterNodeId));
for(Uint32 i = 0; i<RETRIES; i++){
//if (useMasterNodeId == 0)
m_buffer.clear();
@@ -887,7 +889,7 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal,
if(aNodeId == 0){
m_error.code = 4009;
m_transporter->unlock_mutex();
- return -1;
+ DBUG_RETURN(-1);
}
{
int r;
@@ -923,7 +925,7 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal,
if(m_waiter.m_state == NO_WAIT && m_error.code == 0){
// Normal return
- return 0;
+ DBUG_RETURN(0);
}
/**
@@ -946,9 +948,9 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal,
continue;
}
- return -1;
+ DBUG_RETURN(-1);
}
- return -1;
+ DBUG_RETURN(-1);
}
/*****************************************************************
diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp
index f0b0bfe2de4..bc24110ea14 100644
--- a/ndb/src/ndbapi/TransporterFacade.cpp
+++ b/ndb/src/ndbapi/TransporterFacade.cpp
@@ -942,6 +942,8 @@ TransporterFacade::isConnected(NodeId aNodeId){
NodeId
TransporterFacade::get_an_alive_node()
{
+ DBUG_ENTER("TransporterFacade::get_an_alive_node");
+ DBUG_PRINT("enter", ("theStartNodeId: %d", theStartNodeId));
#ifdef VM_TRACE
const char* p = NdbEnv_GetEnv("NDB_ALIVE_NODE_ID", (char*)0, 0);
if (p != 0 && *p != 0)
@@ -950,17 +952,19 @@ TransporterFacade::get_an_alive_node()
NodeId i;
for (i = theStartNodeId; i < MAX_NDB_NODES; i++) {
if (get_node_alive(i)){
+ DBUG_PRINT("info", ("Node %d is alive", i));
theStartNodeId = ((i + 1) % MAX_NDB_NODES);
- return i;
+ DBUG_RETURN(i);
}
}
for (i = 1; i < theStartNodeId; i++) {
if (get_node_alive(i)){
+ DBUG_PRINT("info", ("Node %d is alive", i));
theStartNodeId = ((i + 1) % MAX_NDB_NODES);
- return i;
+ DBUG_RETURN(i);
}
}
- return (NodeId)0;
+ DBUG_RETURN((NodeId)0);
}
TransporterFacade::ThreadData::ThreadData(Uint32 size){
diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp
index 5be4f0f9f91..358dfa74785 100644
--- a/ndb/src/ndbapi/ndb_cluster_connection.cpp
+++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp
@@ -67,6 +67,9 @@ void Ndb_cluster_connection::connect_thread()
printf("Ndb_cluster_connection::connect_thread error\n");
DBUG_ASSERT(false);
g_run_connect_thread= 0;
+ } else {
+ // Wait before making a new connect attempt
+ NdbSleep_SecSleep(1);
}
} while (g_run_connect_thread);
if (m_connect_callback)