List:Commits« Previous MessageNext Message »
From:justin.he Date:April 11 2007 8:19am
Subject:bk commit into 5.0 tree (Justin.He:1.2479) BUG#27640
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 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-04-11 14:19:44+08:00, Justin.He@stripped +4 -0
  Bug#27640, backup id not displayed in the output of "ndb_mgm start backup wait
completed"
  this patch is only valid for 5.0 because 5.1 already fixed the issue

  ndb/src/mgmapi/mgmapi.cpp@stripped, 2007-04-11 14:19:42+08:00,
Justin.He@stripped +27 -26
    change CHECK_REPLY definition

  ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2007-04-11 14:19:42+08:00,
Justin.He@stripped +54 -44
    correct something related mgmclient event listener 

  ndb/src/mgmsrv/MgmtSrvr.cpp@stripped, 2007-04-11 14:19:42+08:00,
Justin.He@stripped +3 -1
    correct print info and update master node id

  ndb/src/mgmsrv/Services.cpp@stripped, 2007-04-11 14:19:42+08:00,
Justin.He@stripped +36 -25
    improve event listener service 

# 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.0/bug27640-5.0-ndb-bj

--- 1.72/ndb/src/mgmapi/mgmapi.cpp	2007-04-11 14:19:50 +08:00
+++ 1.73/ndb/src/mgmapi/mgmapi.cpp	2007-04-11 14:19:50 +08:00
@@ -137,9 +137,10 @@
     return ret; \
   }
 
-#define CHECK_REPLY(reply, ret) \
+#define CHECK_REPLY(handle, reply, ret) \
   if(reply == NULL) { \
-    SET_ERROR(handle, NDB_MGM_ILLEGAL_SERVER_REPLY, ""); \
+    if(!handle->last_error) \
+      SET_ERROR(handle, NDB_MGM_ILLEGAL_SERVER_REPLY, ""); \
     return ret; \
   }
 
@@ -885,7 +886,7 @@
   args.put("nodeId", nodeId);
   const Properties *reply;
   reply = ndb_mgm_call(handle, enter_single_reply, "enter single user", &args);
-  CHECK_REPLY(reply, -1);
+  CHECK_REPLY(handle, reply, -1);
 
   BaseString result;
   reply->get("result", result);
@@ -916,7 +917,7 @@
 
   const Properties *reply;
   reply = ndb_mgm_call(handle, exit_single_reply, "exit single user", 0);
-  CHECK_REPLY(reply, -1);
+  CHECK_REPLY(handle, reply, -1);
 
   const char * buf;
   reply->get("result", &buf);
@@ -1013,7 +1014,7 @@
       reply = ndb_mgm_call(handle, stop_reply_v2, "stop all", &args);
     else
       reply = ndb_mgm_call(handle, stop_reply_v1, "stop all", &args);
-    CHECK_REPLY(reply, -1);
+    CHECK_REPLY(handle, reply, -1);
 
     if(!reply->get("stopped", &stoppedNoOfNodes)){
       SET_ERROR(handle, NDB_MGM_STOP_FAILED, 
@@ -1055,7 +1056,7 @@
   else
     reply = ndb_mgm_call(handle, stop_reply_v1, "stop", &args);
 
-  CHECK_REPLY(reply, stoppedNoOfNodes);
+  CHECK_REPLY(handle, reply, stoppedNoOfNodes);
   if(!reply->get("stopped", &stoppedNoOfNodes)){
     SET_ERROR(handle, NDB_MGM_STOP_FAILED, 
 	      "Could not get number of stopped nodes from mgm server");
@@ -1158,7 +1159,7 @@
     handle->read_timeout= 5*60*1000; // 5 minutes
     reply = ndb_mgm_call(handle, restart_reply_v1, "restart all", &args);
     handle->read_timeout= timeout;
-    CHECK_REPLY(reply, -1);
+    CHECK_REPLY(handle, reply, -1);
 
     BaseString result;
     reply->get("result", result);
@@ -1285,7 +1286,7 @@
   Properties args;
   const Properties *reply;
   reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args);
-  CHECK_REPLY(reply, NULL);
+  CHECK_REPLY(handle, reply, NULL);
   
   for(int i=0; i < (int)NDB_MGM_EVENT_SEVERITY_ALL; i++) {
     reply->get(clusterlog_severity_names[i], &enabled[i]);
@@ -1317,7 +1318,7 @@
   
   const Properties *reply;
   reply = ndb_mgm_call(handle, filter_reply, "set logfilter", &args);
-  CHECK_REPLY(reply, retval);
+  CHECK_REPLY(handle, reply, retval);
 
   BaseString result;
   reply->get("result", result);
@@ -1410,7 +1411,7 @@
   Properties args;
   const Properties *reply;
   reply = ndb_mgm_call(handle, getloglevel_reply, "get cluster loglevel", &args);
-  CHECK_REPLY(reply, NULL);
+  CHECK_REPLY(handle, reply, NULL);
 
   for(int i=0; i < loglevel_count; i++) {
     reply->get(clusterlog_names[i], &loglevel[i]);
@@ -1443,7 +1444,7 @@
   const Properties *reply;
   reply = ndb_mgm_call(handle, clusterlog_reply, 
 		       "set cluster loglevel", &args);
-  CHECK_REPLY(reply, -1);
+  CHECK_REPLY(handle, reply, -1);
   
   DBUG_ENTER("ndb_mgm_set_clusterlog_loglevel");
   DBUG_PRINT("enter",("node=%d, category=%d, level=%d", nodeId, cat, level));
@@ -1481,7 +1482,7 @@
   args.put("level", level);
   const Properties *reply;
   reply = ndb_mgm_call(handle, loglevel_reply, "set loglevel", &args);
-  CHECK_REPLY(reply, -1);
+  CHECK_REPLY(handle, reply, -1);
 
   BaseString result;
   reply->get("result", result);
@@ -1540,7 +1541,7 @@
 
   if(reply == NULL) {
     close(sockfd);
-    CHECK_REPLY(reply, -1);
+    CHECK_REPLY(handle, reply, -1);
   }
   delete reply;
   return sockfd;
@@ -1571,7 +1572,7 @@
   Properties args;
   const Properties *reply;
   reply = ndb_mgm_call(handle, stat_reply, "get statport", &args);
-  CHECK_REPLY(reply, -1);
+  CHECK_REPLY(handle, reply, -1);
 
   Uint32 port;
   reply->get("tcpport", &port);
@@ -1611,7 +1612,7 @@
 
   const Properties *prop;
   prop = ndb_mgm_call(handle, dump_state_reply, "dump state", &args);
-  CHECK_REPLY(prop, -1);
+  CHECK_REPLY(handle, prop, -1);
 
   BaseString result;
   prop->get("result", result);
@@ -1862,7 +1863,7 @@
     Properties args;
     const Properties *reply;
     reply = ndb_mgm_call(handle, start_reply, "start all", &args);
-    CHECK_REPLY(reply, -1);
+    CHECK_REPLY(handle, reply, -1);
 
     Uint32 count = 0;
     if(!reply->get("started", &count)){
@@ -1928,7 +1929,7 @@
     reply = ndb_mgm_call(handle, start_backup_reply, "start backup", &args);
     handle->read_timeout= old_timeout;
   }
-  CHECK_REPLY(reply, -1);
+  CHECK_REPLY(handle, reply, -1);
 
   BaseString result;
   reply->get("result", result);
@@ -1962,7 +1963,7 @@
 
   const Properties *prop;
   prop = ndb_mgm_call(handle, stop_backup_reply, "abort backup", &args);
-  CHECK_REPLY(prop, -1);
+  CHECK_REPLY(handle, prop, -1);
 
   const char * buf;
   prop->get("result", &buf);
@@ -1997,7 +1998,7 @@
   
   const Properties *prop;
   prop = ndb_mgm_call(handle, reply, "get config", &args);
-  CHECK_REPLY(prop, 0);
+  CHECK_REPLY(handle, prop, 0);
   
   do {
     const char * buf;
@@ -2157,7 +2158,7 @@
   
   const Properties *prop;
   prop= ndb_mgm_call(handle, reply, "get nodeid", &args);
-  CHECK_REPLY(prop, -1);
+  CHECK_REPLY(handle, prop, -1);
 
   nodeid= -1;
   do {
@@ -2209,7 +2210,7 @@
   
   const Properties *prop;
   prop= ndb_mgm_call(handle, reply, "set parameter", &args);
-  CHECK_REPLY(prop, -1);
+  CHECK_REPLY(handle, prop, -1);
 
   int res= -1;
   do {
@@ -2413,7 +2414,7 @@
   
   const Properties *prop;
   prop= ndb_mgm_call(handle, reply, "set connection parameter", &args);
-  CHECK_REPLY(prop, -1);
+  CHECK_REPLY(handle, prop, -1);
 
   int res= -1;
   do {
@@ -2455,7 +2456,7 @@
   
   const Properties *prop;
   prop = ndb_mgm_call(handle, reply, "get connection parameter", &args);
-  CHECK_REPLY(prop, -3);
+  CHECK_REPLY(handle, prop, -3);
 
   int res= -1;
   do {
@@ -2517,7 +2518,7 @@
   
   const Properties *prop;
   prop = ndb_mgm_call(handle, reply, "get mgmd nodeid", &args);
-  CHECK_REPLY(prop, 0);
+  CHECK_REPLY(handle, prop, 0);
 
   if(!prop->get("nodeid",&nodeid)){
     fprintf(handle->errstream, "Unable to get value\n");
@@ -2552,7 +2553,7 @@
   
   const Properties *prop;
   prop = ndb_mgm_call(handle, reply, "report event", &args);
-  CHECK_REPLY(prop, -1);
+  CHECK_REPLY(handle, prop, -1);
 
   DBUG_RETURN(0);
 }
@@ -2596,7 +2597,7 @@
 
   const Properties *prop;
   prop = ndb_mgm_call(handle, reply, "get version", &args);
-  CHECK_REPLY(prop, 0);
+  CHECK_REPLY(handle, prop, 0);
 
   Uint32 id;
   if(!prop->get("id",&id)){

--- 1.74/ndb/src/mgmclient/CommandInterpreter.cpp	2007-04-11 14:19:50 +08:00
+++ 1.75/ndb/src/mgmclient/CommandInterpreter.cpp	2007-04-11 14:19:50 +08:00
@@ -125,7 +125,7 @@
   int  executeStatus(int processId, const char* parameters, bool all);
   int  executeEventReporting(int processId, const char* parameters, bool all);
   int  executeDumpState(int processId, const char* parameters, bool all);
-  int  executeStartBackup(char * parameters);
+  int  executeStartBackup(char * parameters, bool interactive);
   int  executeAbortBackup(char * parameters);
   int  executeStop(Vector<BaseString> &command_list, unsigned command_pos,
                    int *node_ids, int no_of_nodes);
@@ -1054,7 +1054,7 @@
   else if(strcasecmp(firstToken, "START") == 0 &&
 	  allAfterFirstToken != NULL &&
 	  strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){
-    m_error= executeStartBackup(allAfterFirstToken);
+    m_error= executeStartBackup(allAfterFirstToken, interactive);
     DBUG_RETURN(true);
   }
   else if(strcasecmp(firstToken, "ABORT") == 0 &&
@@ -2531,20 +2531,12 @@
  * Backup
  *****************************************************************************/
 int
-CommandInterpreter::executeStartBackup(char* parameters)
+CommandInterpreter::executeStartBackup(char* parameters, bool interactive)
 {
   struct ndb_mgm_reply reply;
   unsigned int backupId;
-#if 0
-  int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
-  int fd = ndb_mgm_listen_event(m_mgmsrv, filter);
-  if (fd < 0)
-  {
-    ndbout << "Initializing start of backup failed" << endl;
-    printError();
-    return fd;
-  }
-#endif
+  int fd = -1;
+
   Vector<BaseString> args;
   {
     BaseString(parameters).split(args);
@@ -2557,25 +2549,26 @@
   int sz= args.size();
 
   int result;
+  int flags = 2;
   if (sz == 2 &&
       args[1] == "NOWAIT")
   {
-    result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply);
+    flags = 0;
   }
   else if (sz == 1 ||
 	   (sz == 3 &&
 	    args[1] == "WAIT" &&
 	    args[2] == "COMPLETED"))
   {
+    flags = 2;
     ndbout_c("Waiting for completed, this may take several minutes");
-    result = ndb_mgm_start_backup(m_mgmsrv, 2, &backupId, &reply);
   }
   else if (sz == 3 &&
 	   args[1] == "WAIT" &&
 	   args[2] == "STARTED")
   {
+    flags = 1;
     ndbout_c("Waiting for started, this may take several minutes");
-    result = ndb_mgm_start_backup(m_mgmsrv, 1, &backupId, &reply);
   }
   else
   {
@@ -2583,45 +2576,62 @@
     return -1;
   }
 
+  /**
+   * If interactive...event listener thread is already running
+   * If not interactive and wait completed, we should issue an event listener
+   */
+  if (flags == 2 && !interactive)
+  {
+    int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0, 0 };
+    fd = ndb_mgm_listen_event(m_mgmsrv, filter);
+    if (fd < 0)
+    {
+      ndbout << "Initializing event listener to mgmsrv failed" << endl;
+      printError();
+      return fd;
+    }
+  }
+  
+  result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply);
+
   if (result != 0) {
     ndbout << "Backup failed" << endl;
     printError();
-#if 0
-    close(fd);
-#endif
+    if (fd >= 0) 
+      close(fd);
     return result;
   }
-#if 0
-  ndbout_c("Waiting for completed, this may take several minutes");
-  char *tmp;
-  char buf[1024];
+  if (fd >= 0)
   {
-    SocketInputStream in(fd);
-    int count = 0;
+    char *tmp;
+    char buf[1024];
+    {
+      SocketInputStream in(fd);
+      int count = 0;
+      do {
+        tmp = in.gets(buf, 1024);
+        if(tmp)
+        { 
+          ndbout << tmp; 
+          unsigned int id; 
+          if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){ 
+            count++; 
+          }
+        }
+      } while(count < 2);
+    }
+
+    SocketInputStream in(fd, 10);
     do {
       tmp = in.gets(buf, 1024);
-      if(tmp)
+      if(tmp && tmp[0] != 0)
       {
-	ndbout << tmp;
-	unsigned int id;
-	if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){
-	  count++;
-	}
+        ndbout << tmp;
       }
-    } while(count < 2);
-  }
-
-  SocketInputStream in(fd, 10);
-  do {
-    tmp = in.gets(buf, 1024);
-    if(tmp && tmp[0] != 0)
-    {
-      ndbout << tmp;
-    }
-  } while(tmp && tmp[0] != 0);
+    } while(tmp && tmp[0] != 0);
 
-  close(fd);
-#endif  
+    close(fd);
+  }
   return 0;
 }
 

--- 1.115/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-04-11 14:19:50 +08:00
+++ 1.116/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-04-11 14:19:50 +08:00
@@ -2463,7 +2463,7 @@
       const BackupCompleteRep * const rep = 
 	CAST_CONSTPTR(BackupCompleteRep, signal->getDataPtr());
 #ifdef VM_TRACE
-      ndbout_c("Backup(%d) completed %d", rep->backupId);
+      ndbout_c("Backup(%d) completed", rep->backupId);
 #endif
       event.Event = BackupEvent::BackupCompleted;
       event.Completed.BackupId = rep->backupId;
@@ -2494,6 +2494,8 @@
 	ndbout_c("I'm not master resending to %d", nodeId);
 #endif
 	do_send = 1; // try again
+	if (!theFacade->get_node_alive(nodeId))
+	  m_master_node = nodeId = 0;
 	continue;
       }
       event.Event = BackupEvent::BackupFailedToStart;

--- 1.77/ndb/src/mgmsrv/Services.cpp	2007-04-11 14:19:50 +08:00
+++ 1.78/ndb/src/mgmsrv/Services.cpp	2007-04-11 14:19:50 +08:00
@@ -1286,20 +1286,27 @@
   {
     if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat))
     {
-      NDB_SOCKET_TYPE fd= m_clients[i].m_socket;
-      if(fd != NDB_INVALID_SOCKET)
+      if(m_clients[i].m_socket==NDB_INVALID_SOCKET)
       {
-	int r;
-	if (m_clients[i].m_parsable)
-	  r= println_socket(fd,
-			    MAX_WRITE_TIMEOUT, str.c_str());
-	else
-	  r= println_socket(fd,
-			    MAX_WRITE_TIMEOUT, m_text);
-	if (r == -1) {
-	  copy.push_back(fd);
-	  m_clients.erase(i, false);
-	}
+        continue;
+      }
+
+      SocketOutputStream out(m_clients[i].m_socket);
+
+      int r;
+      if (m_clients[i].m_parsable)
+      {
+        r= out.println(str.c_str());
+      }
+      else
+      {
+        r= out.println(m_text);
+      }
+
+      if (r<0)
+      {
+        copy.push_back(m_clients[i].m_socket);
+        m_clients.erase(i, false);
       }
     }
   }
@@ -1350,14 +1357,16 @@
   m_clients.lock();
   for(i= m_clients.size() - 1; i >= 0; i--)
   {
-    int fd= m_clients[i].m_socket;
-    DBUG_PRINT("info",("%d %d",i,fd));
-    char buf[1];
-    buf[0]=0;
-    if (fd != NDB_INVALID_SOCKET &&
-	println_socket(fd,MAX_WRITE_TIMEOUT,"<PING>") == -1)
+    if(m_clients[i].m_socket==NDB_INVALID_SOCKET)
+      continue;
+
+    SocketOutputStream out(m_clients[i].m_socket);
+
+    DBUG_PRINT("info",("%d %d",i,m_clients[i].m_socket));
+
+    if(out.println("<PING>") < 0)
     {
-      NDB_CLOSE_SOCKET(fd);
+      NDB_CLOSE_SOCKET(m_clients[i].m_socket);
       m_clients.erase(i, false);
       n=1;
     }
@@ -1522,17 +1531,19 @@
     goto done;
   }
   
-  m_mgmsrv.m_event_listner.add_listener(le);
-  
-  m_stop = true;
-  m_socket = NDB_INVALID_SOCKET;
-
 done:
   m_output->println("listen event");
   m_output->println("result: %d", result);
   if(result != 0)
     m_output->println("msg: %s", msg.c_str());
   m_output->println("");
+
+  if(result==0)
+  {
+    m_mgmsrv.m_event_listner.add_listener(le);
+    m_stop = true;
+    m_socket = NDB_INVALID_SOCKET;
+  }
 }
 
 void
Thread
bk commit into 5.0 tree (Justin.He:1.2479) BUG#27640justin.he11 Apr