MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Stewart Smith Date:May 23 2006 8:16am
Subject:bk commit into 5.0 tree (stewart:1.2137) BUG#13985
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of stewart. When stewart 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
  1.2137 06/05/23 18:16:26 stewart@stripped +1 -0
  BUG#13985 Cluster: ndb_mgm "status" command can return incorrect data node status
  
  partial fix for this bug. more info on what the other half of the fix involves
  is in the bug report.

  ndb/src/mgmclient/CommandInterpreter.cpp
    1.59 06/05/23 18:16:20 stewart@stripped +24 -4
    partial fix for bug13985
    
    hold a mutex around printing out events
    hold the mutex also around printing out put of 'status' commands.
    
    this means we don't get
    1 started
    2 started
    2 starting
    
    output.
    
    we'll instead get the event before/after the entire status output.
    Due to the nature of the event arriving before status being updated,
    we'll pretty much always see started AFTER starting.

# 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:	stewart
# Host:	willster.(none)
# Root:	/home/stewart/Documents/MySQL/5.0/bug13985

--- 1.58/ndb/src/mgmclient/CommandInterpreter.cpp	2006-04-19 17:14:30 +10:00
+++ 1.59/ndb/src/mgmclient/CommandInterpreter.cpp	2006-05-23 18:16:20 +10:00
@@ -172,8 +172,15 @@
   bool rep_connected;
 #endif
   struct NdbThread* m_event_thread;
+  NdbMutex *m_print_mutex;
 };
 
+struct event_thread_param {
+  NdbMgmHandle *m;
+  NdbMutex **p;
+};
+
+NdbMutex* print_mutex;
 
 /*
  * Facade object for CommandInterpreter
@@ -409,6 +416,7 @@
   m_connected= false;
   m_event_thread= 0;
   try_reconnect = 0;
+  m_print_mutex= NdbMutex_Create();
 #ifdef HAVE_GLOBAL_REPLICATION
   rep_host = NULL;
   m_repserver = NULL;
@@ -422,6 +430,7 @@
 CommandInterpreter::~CommandInterpreter() 
 {
   disconnect();
+  NdbMutex_Destroy(m_print_mutex);
   ndb_mgm_destroy_handle(&m_mgmsrv);
   ndb_mgm_destroy_handle(&m_mgmsrv2);
 }
@@ -461,11 +470,13 @@
 
 static int do_event_thread;
 static void*
-event_thread_run(void* m)
+event_thread_run(void* p)
 {
   DBUG_ENTER("event_thread_run");
 
-  NdbMgmHandle handle= *(NdbMgmHandle*)m;
+  struct event_thread_param param= *(struct event_thread_param*)p;
+  NdbMgmHandle handle= *(param.m);
+  NdbMutex* printmutex= *(param.p);
 
   int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP,
 		   1, NDB_MGM_EVENT_CATEGORY_STARTUP,
@@ -483,7 +494,11 @@
       {
 	const char ping_token[]= "<PING>";
 	if (memcmp(ping_token,tmp,sizeof(ping_token)-1))
-	  ndbout << tmp;
+	  if(tmp && strlen(tmp))
+          {
+            Guard g(printmutex);
+            ndbout << tmp;
+          }
       }
     } while(do_event_thread);
     NDB_CLOSE_SOCKET(fd);
@@ -516,8 +531,11 @@
 	assert(m_event_thread == 0);
 	assert(do_event_thread == 0);
 	do_event_thread= 0;
+        struct event_thread_param p;
+        p.m= &m_mgmsrv2;
+        p.p= &m_print_mutex;
 	m_event_thread = NdbThread_Create(event_thread_run,
-					  (void**)&m_mgmsrv2,
+					  (void**)&p,
 					  32768,
 					  "CommandInterpreted_event_thread",
 					  NDB_THREAD_PRIO_LOW);
@@ -607,6 +625,7 @@
   int result= execute_impl(_line);
   if (error)
     *error= m_error;
+
   return result;
 }
 
@@ -920,6 +939,7 @@
     ndbout_c("Trying to start all nodes of system.");
     ndbout_c("Use ALL STATUS to see the system start-up phases.");
   } else {
+    Guard g(m_print_mutex);
     struct ndb_mgm_cluster_state *cl= ndb_mgm_get_status(m_mgmsrv);
     if(cl == 0){
       ndbout_c("Unable get status from management server");
Thread
bk commit into 5.0 tree (stewart:1.2137) BUG#13985Stewart Smith23 May