MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:knielsen Date:December 12 2007 10:53am
Subject:bk commit into 5.1 tree (knielsen:1.2633)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of knielsen. When knielsen 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-12-12 11:53:06+01:00, knielsen@ymer.(none) +7 -0
  WL#1498: Multi-threaded ndbd.
  
  Fixes in preparation for benchmark.

  storage/ndb/include/kernel/signaldata/GCP.hpp@stripped, 2007-12-12 11:53:02+01:00, knielsen@ymer.(none) +6 -1
    Fix last cross-thread EXECUTE_DIRECT.

  storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp@stripped, 2007-12-12 11:53:02+01:00, knielsen@ymer.(none) +16 -1
    Fix last cross-thread EXECUTE_DIRECT.

  storage/ndb/src/kernel/blocks/suma/Suma.cpp@stripped, 2007-12-12 11:53:02+01:00, knielsen@ymer.(none) +9 -16
    Fix last cross-thread EXECUTE_DIRECT.

  storage/ndb/src/kernel/blocks/suma/Suma.hpp@stripped, 2007-12-12 11:53:02+01:00, knielsen@ymer.(none) +2 -2
    Fix last cross-thread EXECUTE_DIRECT.

  storage/ndb/src/kernel/blocks/suma/SumaInit.cpp@stripped, 2007-12-12 11:53:02+01:00, knielsen@ymer.(none) +3 -1
    Fix last cross-thread EXECUTE_DIRECT.

  storage/ndb/src/kernel/vm/WatchDog.cpp@stripped, 2007-12-12 11:53:03+01:00, knielsen@ymer.(none) +3 -2
    Watchdog also warns how long thread has been stuck.

  storage/ndb/src/kernel/vm/mt/mt.cpp@stripped, 2007-12-12 11:53:03+01:00, knielsen@ymer.(none) +21 -2
    Fix locking bug.
    Fix signal alignment.

diff -Nrup a/storage/ndb/include/kernel/signaldata/GCP.hpp b/storage/ndb/include/kernel/signaldata/GCP.hpp
--- a/storage/ndb/include/kernel/signaldata/GCP.hpp	2007-09-05 15:19:56 +02:00
+++ b/storage/ndb/include/kernel/signaldata/GCP.hpp	2007-12-12 11:53:02 +01:00
@@ -18,7 +18,12 @@
 
 #include "SignalData.hpp"
 
-struct GCPPrepare // Distr. DIH-DIH
+/**
+ * Sent as a distributed signal DIH-DIH.
+ *
+ * Also sent locally from DIH to SUMA.
+ */
+struct GCPPrepare
 {
   STATIC_CONST( SignalLength = 3 );
 
diff -Nrup a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2007-11-21 21:32:32 +01:00
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2007-12-12 11:53:02 +01:00
@@ -8496,6 +8496,16 @@ void Dbdih::execGCP_PREPARE(Signal* sign
 #endif
 
 reply:
+  /**
+   * Send the new gci to Suma.
+   *
+   * To get correct signal order and avoid races, this signal is sent on the
+   * same prio as the SUB_GCP_COMPLETE_REP signal sent to SUMA in
+   * execSUB_GCP_COMPLETE_REP().
+   */
+  sendSignal(SUMA_REF, GSN_GCP_PREPARE, signal, signal->length(), JBB);
+
+  /* Send reply. */
   conf->nodeId = cownNodeId;
   conf->gci_hi = gci_hi;
   conf->gci_lo = gci_lo;
@@ -8641,7 +8651,12 @@ Dbdih::execSUB_GCP_COMPLETE_REP(Signal* 
 
   ndbrequire(m_micro_gcp.m_state == MicroGcp::M_GCP_COMMITTED);
   m_micro_gcp.m_state = MicroGcp::M_GCP_IDLE;
-  sendSignal(SUMA_REF, GSN_SUB_GCP_COMPLETE_REP, signal, signal->length(), JBA);
+  /**
+   * To get correct signal order and avoid races, this signal to SUMA is sent
+   * on the same prio as the GCP_PREPARE signal sent to SUMA in
+   * execGPC_PREPARE
+   */
+  sendSignal(SUMA_REF, GSN_SUB_GCP_COMPLETE_REP, signal, signal->length(), JBB);
 }
 
 /*****************************************************************************/
diff -Nrup a/storage/ndb/src/kernel/blocks/suma/Suma.cpp b/storage/ndb/src/kernel/blocks/suma/Suma.cpp
--- a/storage/ndb/src/kernel/blocks/suma/Suma.cpp	2007-11-21 08:32:57 +01:00
+++ b/storage/ndb/src/kernel/blocks/suma/Suma.cpp	2007-12-12 11:53:02 +01:00
@@ -44,6 +44,7 @@
 #include <signaldata/AlterTab.hpp>
 #include <signaldata/DihFragCount.hpp>
 #include <signaldata/SystemError.hpp>
+#include <signaldata/GCP.hpp>
 
 #include <ndbapi/NdbDictionary.hpp>
 
@@ -2732,7 +2733,7 @@ Suma::sendSubStopComplete(Signal* signal
 
   // let subscriber know that subscrber is stopped
   {
-    const Uint64 gci = get_current_gci(signal);
+    const Uint64 gci = m_current_gci;
     SubTableData * data  = (SubTableData*)signal->getDataPtrSend();
     data->gci_hi         = Uint32(gci >> 32);
     data->gci_lo         = Uint32(gci);
@@ -2773,7 +2774,7 @@ Suma::reportAllSubscribers(Signal *signa
                            SubscriptionPtr subPtr,
                            SubscriberPtr subbPtr)
 {
-  const Uint64 gci = get_current_gci(signal);
+  const Uint64 gci = m_current_gci;
   SubTableData * data  = (SubTableData*)signal->getDataPtrSend();
 
   if (table_event == NdbDictionary::Event::_TE_SUBSCRIBE &&
@@ -3738,7 +3739,7 @@ Suma::execDROP_TAB_CONF(Signal *signal)
   }
   // dict coordinator sends info to API
   
-  const Uint64 gci = get_current_gci(signal);
+  const Uint64 gci = m_current_gci;
   SubTableData * data = (SubTableData*)signal->getDataPtrSend();
   data->gci_hi         = Uint32(gci >> 32);
   data->gci_lo         = Uint32(gci);
@@ -3823,7 +3824,7 @@ Suma::execALTER_TAB_REQ(Signal *signal)
   ptr[0].p = b_dti_buf;
   ptr[0].sz = tabInfoPtr.sz;
 
-  const Uint64 gci = get_current_gci(signal);
+  const Uint64 gci = m_current_gci;
   SubTableData * data = (SubTableData*)signal->getDataPtrSend();
   data->gci_hi         = Uint32(gci >> 32);
   data->gci_lo         = Uint32(gci);
@@ -5158,20 +5159,12 @@ next:
     sendSignalWithDelay(SUMA_REF, GSN_CONTINUEB, signal, 10, 7);
 }
 
-Uint64
-Suma::get_current_gci(Signal* signal)
+void
+Suma::execGCP_PREPARE(Signal *signal)
 {
-  signal->theData[0] = 0; // user ptr
-  signal->theData[1] = 0; // Execute direct
-  signal->theData[2] = 1; // Current
-  EXECUTE_DIRECT(DBDIH, GSN_GETGCIREQ, signal, 3);
-
   jamEntry();
-  Uint32 gci_hi = signal->theData[1];
-  Uint32 gci_lo = signal->theData[2];
-
-  Uint64 gci = gci_lo | (Uint64(gci_hi) << 32);
-  return gci;
+  const GCPPrepare *prep = (const GCPPrepare *)signal->getDataPtr();
+  m_current_gci = prep->gci_lo | (Uint64(prep->gci_hi) << 32);
 }
 
 template void append(DataBuffer<11>&,SegmentedSectionPtr,SectionSegmentPool&);
diff -Nrup a/storage/ndb/src/kernel/blocks/suma/Suma.hpp b/storage/ndb/src/kernel/blocks/suma/Suma.hpp
--- a/storage/ndb/src/kernel/blocks/suma/Suma.hpp	2007-11-21 08:32:57 +01:00
+++ b/storage/ndb/src/kernel/blocks/suma/Suma.hpp	2007-12-12 11:53:02 +01:00
@@ -96,6 +96,7 @@ public:
   void execDIGETPRIMREF(Signal* signal);
   void execDIGETPRIMCONF(Signal* signal);
   void execCHECKNODEGROUPSCONF(Signal *signal);
+  void execGCP_PREPARE(Signal *signal);
 
   /**
    * Trigger administration
@@ -601,8 +602,6 @@ private:
 		     Uint32 page_pos, Uint64 last_gci);
   void release_gci(Signal*, Uint32 bucket, Uint64 gci);
 
-  Uint64 get_current_gci(Signal*);
-
   Uint64 m_max_seen_gci;      // FIRE_TRIG_ORD
   Uint64 m_max_sent_gci;      // FIRE_TRIG_ORD -> send
   Uint64 m_last_complete_gci; // SUB_GCP_COMPLETE_REP
@@ -644,6 +643,7 @@ private:
   /* Buffer used in Suma::execALTER_TAB_REQ(). */
   Uint32 b_dti_buf[MAX_WORDS_META_FILE];
 
+  Uint64 m_current_gci;
 };
 
 #endif
diff -Nrup a/storage/ndb/src/kernel/blocks/suma/SumaInit.cpp b/storage/ndb/src/kernel/blocks/suma/SumaInit.cpp
--- a/storage/ndb/src/kernel/blocks/suma/SumaInit.cpp	2007-11-21 08:32:57 +01:00
+++ b/storage/ndb/src/kernel/blocks/suma/SumaInit.cpp	2007-12-12 11:53:02 +01:00
@@ -25,7 +25,8 @@ Suma::Suma(Block_context& ctx) :
   c_tables(c_tablePool),
   c_subscriptions(c_subscriptionPool),
   Restart(*this),
-  c_gcp_list(c_gcp_pool)
+  c_gcp_list(c_gcp_pool),
+  m_current_gci(~(Uint64)0)
 {
   // Add received signals
   addRecSignal(GSN_READ_CONFIG_REQ, &Suma::execREAD_CONFIG_REQ);
@@ -94,6 +95,7 @@ Suma::Suma(Block_context& ctx) :
   addRecSignal(GSN_DI_FCOUNTREF, &Suma::execDI_FCOUNTREF);
   addRecSignal(GSN_DIGETPRIMCONF, &Suma::execDIGETPRIMCONF);
   addRecSignal(GSN_CHECKNODEGROUPSCONF, &Suma::execCHECKNODEGROUPSCONF);
+  addRecSignal(GSN_GCP_PREPARE, &Suma::execGCP_PREPARE);
 
   /**
    * Scan interface
diff -Nrup a/storage/ndb/src/kernel/vm/WatchDog.cpp b/storage/ndb/src/kernel/vm/WatchDog.cpp
--- a/storage/ndb/src/kernel/vm/WatchDog.cpp	2007-10-12 13:25:02 +02:00
+++ b/storage/ndb/src/kernel/vm/WatchDog.cpp	2007-12-12 11:53:03 +01:00
@@ -264,8 +264,9 @@ WatchDog::run()
       if (oldCounterValue[i] != 9 || elapsed[i] >= theIntervalCheck[i])
       {
         const char *last_stuck_action = get_action(oldCounterValue[i]);
-        g_eventLogger.warning("Ndb kernel thread %u is stuck in: %s",
-                              threadId[i], last_stuck_action);
+        g_eventLogger.warning("Ndb kernel thread %u is stuck in: %s "
+                              "elapsed=%u",
+                              threadId[i], last_stuck_action, elapsed[i]);
         {
           struct tms my_tms;
           times(&my_tms);
diff -Nrup a/storage/ndb/src/kernel/vm/mt/mt.cpp b/storage/ndb/src/kernel/vm/mt/mt.cpp
--- a/storage/ndb/src/kernel/vm/mt/mt.cpp	2007-12-04 08:59:09 +01:00
+++ b/storage/ndb/src/kernel/vm/mt/mt.cpp	2007-12-12 11:53:03 +01:00
@@ -225,8 +225,12 @@ inline
 void
 unlock(struct thr_spin_lock* sl)
 {
-  sl->m_lock = 0;
+  /**
+   * Memory barrier here, to make sure all of our stores are visible before
+   * the lock release is.
+   */
   mb();
+  sl->m_lock = 0;
 }
 
 static
@@ -872,7 +876,12 @@ do_send(struct thr_repository* rep, stru
       lock(&rep->m_send_locks[nodeId]);
     else if (trylock(&rep->m_send_locks[nodeId]) != 0)
     {
-      /* Not doing this node now, re-add to pending list. */
+      /**
+       * Not doing this node now, re-add to pending list.
+       *
+       * As we only add from the start of an empty list, we are safe from
+       * overwriting the list while we are iterating over it.
+       */
       register_pending_send(selfptr, nodeId);
       continue;
     }
@@ -935,8 +944,10 @@ insert_signal(thr_job_queue *q, thr_jb_w
     w->m_write_buffer->m_data[write_pos++] = *p++;
   w->m_pending_signals++;
 
+#if SIZEOF_CHARP == 8
   /* Align to 8-byte boundary, to ensure aligned copies. */
   write_pos= (write_pos+1) & ~((Uint32)1);
+#endif
 
   /*
    * We make sure that there is always room for at least one signal in the
@@ -1084,8 +1095,10 @@ execute_signals(thr_data *selfptr, thr_j
     sig->m_sectionPtrI[2] = read_buffer->m_data[read_pos + siglen + 2];
 
     read_pos += siglen + seccnt;
+#if SIZEOF_CHARP == 8
     /* Handle 8-byte alignment. */
     read_pos = (read_pos + 1) & ~((Uint32)1);
+#endif
 
     /* Update just before execute so signal dump can know how far we are. */
     r->m_read_pos = read_pos;
@@ -2142,6 +2155,10 @@ FastScheduler::dumpSignalMemory(Uint32 t
     signalSequence[seq_end].prioa = jbs[idx_min].m_jb->m_prioa;
     Uint32 siglen =
       (sizeof(SignalHeader)>>2) + s_min->m_noOfSections + s_min->theLength;
+#if SIZEOF_CHARP == 8
+    /* Align to 8-byte boundary, to ensure aligned copies. */
+    siglen= (siglen+1) & ~((Uint32)1);
+#endif
     jbs[idx_min].m_pos += siglen;
     if (jbs[idx_min].m_pos >= jbs[idx_min].m_max)
     {
@@ -2171,6 +2188,8 @@ FastScheduler::dumpSignalMemory(Uint32 t
     Signal signal;
     const SignalHeader *s = signalSequence[seq_end].ptr;
     unsigned siglen = (sizeof(*s)>>2) + s->theLength;
+    if (siglen > 25)
+      siglen = 25;              // Sanity check
     memcpy(&signal.header, s, 4*siglen);
 
     const Uint32 *posptr = reinterpret_cast<const Uint32 *>(s);
Thread
bk commit into 5.1 tree (knielsen:1.2633)knielsen12 Dec