From: Date: August 10 2007 9:14am Subject: bk commit into 5.1 tree (Justin.He:1.2562) BUG#29485 List-Archive: http://lists.mysql.com/commits/32345 X-Bug: 29485 Message-Id: <200708100714.l7A7EDZn020092@dev3-240.dev.cn.tlan> Below is the list of changes that have just been committed into a local 5.1 repository of justin.he. When justin.he does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-08-10 15:14:05+08:00, Justin.He@stripped +1 -0 Bug#29485, No output from REPORT MEMORY for NON-DN storage/ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2007-08-10 15:14:01+08:00, Justin.He@stripped +88 -27 add a new function checkNodeState() to confirm whether node id is valid; in executeReport(), add check node id and node type; in executeStatus(), use common checkNodeState() to check node id, meantime remove duplicate part. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: Justin.He # Host: dev3-240.dev.cn.tlan # Root: /home/justin.he/mysql/mysql-5.1/bug29485-5.1-telco --- 1.98/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2007-08-10 15:14:13 +08:00 +++ 1.99/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2007-08-10 15:14:13 +08:00 @@ -131,6 +131,7 @@ int executeRep(char* parameters); void executeCpc(char * parameters); + int checkNodeState(int processId, struct ndb_mgm_node_state* node_state=NULL); public: bool connect(bool interactive); @@ -2255,6 +2256,37 @@ if (found >= 0) { + struct ndb_mgm_node_state node_state; + node_state.node_type = NDB_MGM_NODE_TYPE_UNKNOWN; + node_state.node_status = NDB_MGM_NODE_STATUS_UNKNOWN; + if (checkNodeState(processId, &node_state)) + return -1; + + if (node_state.node_type != NDB_MGM_NODE_TYPE_NDB) + { + ndbout_c("Node %d: is not a data node.", processId); + return -1; + } + + int res = 0; + switch (node_state.node_status) + { + case NDB_MGM_NODE_STATUS_STARTED: + // fall through + case NDB_MGM_NODE_STATUS_SINGLEUSER: + res = 1; + break; + default: + break; + } + + if (res == 0) + { + ndbout_c("Node %d: %s, (not ready for report)", + processId, status_string(node_state.node_status)); + return -1; + } + struct st_report_cmd &cmd = report_cmds[found]; if (cmd.dump_cmd) { @@ -2297,39 +2329,25 @@ ndb_mgm_node_status status; Uint32 startPhase, version, mysql_version; - struct ndb_mgm_cluster_state *cl; - cl = ndb_mgm_get_status(m_mgmsrv); - if(cl == NULL) { - ndbout_c("Cannot get status of node %d.", processId); - printError(); - return -1; - } - NdbAutoPtr ap1((char*)cl); - - int i = 0; - while((i < cl->no_of_nodes) && cl->node_states[i].node_id != processId) - i++; - if(cl->node_states[i].node_id != processId) { - ndbout << processId << ": Node not found" << endl; - return -1; - } - if (cl->node_states[i].node_type != NDB_MGM_NODE_TYPE_NDB){ - if (cl->node_states[i].version != 0){ - version = cl->node_states[i].version; - ndbout << "Node "<< cl->node_states[i].node_id <<": connected" ; + struct ndb_mgm_node_state node_state; + if (checkNodeState(processId, &node_state)){ + return -1; + } + else if (node_state.node_type !=NDB_MGM_NODE_TYPE_NDB){ + if (node_state.version != 0){ + version = node_state.version; + ndbout << "Node "<< node_state.node_id <<": connected" ; ndbout_c(" (Version %d.%d.%d)", getMajor(version) , getMinor(version), getBuild(version)); - - }else - ndbout << "Node "<< cl->node_states[i].node_id <<": not connected" << endl; + } return 0; } - status = cl->node_states[i].node_status; - startPhase = cl->node_states[i].start_phase; - version = cl->node_states[i].version; - mysql_version = cl->node_states[i].mysql_version; + status = node_state.node_status; + startPhase = node_state.start_phase; + version = node_state.version; + mysql_version = node_state.mysql_version; ndbout << "Node " << processId << ": " << status_string(status); switch(status){ @@ -2864,6 +2882,49 @@ executeAbortBackupError1: ndbout << "Invalid arguments: expected " << endl; return -1; +} + +int +CommandInterpreter::checkNodeState(int processId, + struct ndb_mgm_node_state* node_state) +{ + struct ndb_mgm_cluster_state *cl; + cl = ndb_mgm_get_status(m_mgmsrv); + if(cl == NULL) { + ndbout_c("Cannot get status of node %d.", processId); + printError(); + return -1; + } + NdbAutoPtr ap1((char*)cl); + + int i = 0; + while((i < cl->no_of_nodes) && cl->node_states[i].node_id != processId) + i++; + if(cl->node_states[i].node_id != processId) { + ndbout << processId << ": Node not found" << endl; + return -1; + } + if(cl->node_states[i].node_type != NDB_MGM_NODE_TYPE_NDB) { + if(cl->node_states[i].version == 0) { + ndbout << "Node "<< cl->node_states[i].node_id <<": not connected" << endl; + return -1; + } + } + + if(node_state) { + node_state->node_id = cl->node_states[i].node_id; + node_state->node_type = cl->node_states[i].node_type; + node_state->node_status = cl->node_states[i].node_status; + node_state->start_phase= cl->node_states[i].start_phase; + node_state->dynamic_id = cl->node_states[i].dynamic_id; + node_state->node_group = cl->node_states[i].node_group; + node_state->version = cl->node_states[i].version; + node_state->connect_count = cl->node_states[i].connect_count; + sprintf(node_state->connect_address, "%s", cl->node_states[i].connect_address); + node_state->mysql_version = cl->node_states[i].mysql_version; + } + + return 0; } template class Vector;