List:Commits« Previous MessageNext Message »
From:jonas Date:December 28 2005 11:56am
Subject:bk commit into 5.1 tree (jonas:1.1980)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas 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.1980 05/12/28 12:55:52 jonas@eel.(none) +8 -0
  ndb - opt nr
    fix handling of nr_delete wrt to disk part

  storage/ndb/src/kernel/blocks/tsman.cpp
    1.4 05/12/28 12:55:45 jonas@eel.(none) +3 -1
    Fix initial node restart

  storage/ndb/src/kernel/blocks/pgman.hpp
    1.3 05/12/28 12:55:45 jonas@eel.(none) +1 -0
    Move CORR_REQ to TUP (from pgman)

  storage/ndb/src/kernel/blocks/pgman.cpp
    1.3 05/12/28 12:55:45 jonas@eel.(none) +0 -5
    Move CORR_REQ to TUP (from pgman)

  storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
    1.36 05/12/28 12:55:45 jonas@eel.(none) +143 -4
    Fix handling of disk delete during NR

  storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
    1.12 05/12/28 12:55:45 jonas@eel.(none) +6 -1
    Move CORR_REQ to TUP (from pgman)

  storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp
    1.34 05/12/28 12:55:45 jonas@eel.(none) +4 -1
    Fix handling of disk delete during NR

  storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
    1.96 05/12/28 12:55:45 jonas@eel.(none) +117 -1
    Fix handling of disk delete during NR

  storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp
    1.48 05/12/28 12:55:45 jonas@eel.(none) +18 -1
    Fix handling of disk delete during NR

# 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:	jonas
# Host:	eel.(none)
# Root:	/home/jonas/src/51-ndb

--- 1.2/storage/ndb/src/kernel/blocks/pgman.cpp	2005-11-10 12:04:37 +01:00
+++ 1.3/storage/ndb/src/kernel/blocks/pgman.cpp	2005-12-28 12:55:45 +01:00
@@ -1479,11 +1479,6 @@
   {
     busy_count = true;
     state |= Page_entry::BUSY;
-    /*
-     * Consider commit to be correlated.  Otherwise pk op + commit makes
-     * the page hot.   XXX move to TUP which knows better.
-     */
-    req_flags |= Page_request::CORR_REQ;
   }
   else if ((req_flags & Page_request::OP_MASK) != ZREAD)
   {

--- 1.2/storage/ndb/src/kernel/blocks/pgman.hpp	2005-11-09 18:36:05 +01:00
+++ 1.3/storage/ndb/src/kernel/blocks/pgman.hpp	2005-12-28 12:55:45 +01:00
@@ -518,6 +518,7 @@
     ,DIRTY_REQ = Pgman::Page_request::DIRTY_REQ
     ,NO_HOOK = Pgman::Page_request::NO_HOOK
     ,UNLOCK_PAGE = Pgman::Page_request::UNLOCK_PAGE
+    ,CORR_REQ = Pgman::Page_request::CORR_REQ
   };
   
   /**

--- 1.3/storage/ndb/src/kernel/blocks/tsman.cpp	2005-12-26 09:49:43 +01:00
+++ 1.4/storage/ndb/src/kernel/blocks/tsman.cpp	2005-12-28 12:55:45 +01:00
@@ -1084,7 +1084,9 @@
 
   Ptr<Tablespace> ts_ptr;
   m_tablespace_pool.getPtr(ts_ptr, ptr.p->m_tablespace_ptr_i);
-  if (getNodeState().startLevel >= NodeState::SL_STARTED)
+  if (getNodeState().startLevel >= NodeState::SL_STARTED ||
+      (getNodeState().getNodeRestartInProgress() &&
+       getNodeState().starting.restartType == NodeState::ST_INITIAL_NODE_RESTART))
   {
     LocalDLList<Datafile> free(m_file_pool, ts_ptr.p->m_free_files);
     LocalDLList<Datafile> meta(m_file_pool, ts_ptr.p->m_meta_files);

--- 1.47/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2005-12-23 08:34:19 +01:00
+++ 1.48/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2005-12-28 12:55:45 +01:00
@@ -2035,6 +2035,12 @@
     Uint8 m_dealloc;
     Uint32 m_log_part_ptr_i;
     Local_key m_row_id;
+
+    struct {
+      Uint32 m_cnt;
+      Uint32 m_page_id[2];
+      Local_key m_disk_ref[2];
+    } m_nr_delete;
   }; /* p2c: size = 280 bytes */
   
   typedef Ptr<TcConnectionrec> TcConnectionrecPtr;
@@ -2567,10 +2573,21 @@
   void exec_acckeyreq(Signal*, Ptr<TcConnectionrec>);
   int compare_key(const TcConnectionrec*, const Uint32 * ptr, Uint32 len);
   void nr_copy_delete_row(Signal*, Ptr<TcConnectionrec>, Local_key*, Uint32);
+public:
+  struct Nr_op_info
+  {
+    Uint32 m_ptr_i;
+    Uint32 m_tup_frag_ptr_i;
+    Uint32 m_gci;
+    Uint32 m_page_id;
+    Local_key m_disk_ref;
+  };
+  void get_nr_op_info(Nr_op_info*, Uint32 page_id = RNIL);
+  void nr_delete_complete(Signal*, Nr_op_info*);
   
 public:
   void acckeyconf_load_diskpage_callback(Signal*, Uint32, Uint32);
-
+  
 private:
   void next_scanconf_load_diskpage(Signal* signal, 
 				   ScanRecordPtr scanPtr,

--- 1.95/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2005-12-26 09:49:43 +01:00
+++ 1.96/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2005-12-28 12:55:45 +01:00
@@ -3823,6 +3823,7 @@
     return;
   }
 
+  regTcPtr.p->m_nr_delete.m_cnt = 1; // Wait for real op aswell
   Uint32* dst = signal->theData+24;
   bool uncommitted;
   const int len = c_tup->nr_read_pk(fragPtr, &regTcPtr.p->m_row_id, dst, 
@@ -4082,9 +4083,23 @@
   jamEntry();
 
   ndbrequire(regTcPtr.p->m_dealloc == 1);  
-  c_tup->nr_delete(signal, fragPtr.p->tupFragptr, &regTcPtr.p->m_row_id);
+  int ret = c_tup->nr_delete(signal, regTcPtr.i, 
+			     fragPtr.p->tupFragptr, &regTcPtr.p->m_row_id, 
+			     regTcPtr.p->gci);
   jamEntry();
 
+  if (ret)
+  {
+    ndbassert(ret == 1);
+    Uint32 pos = regTcPtr.p->m_nr_delete.m_cnt - 1;
+    memcpy(regTcPtr.p->m_nr_delete.m_disk_ref + pos, 
+	   signal->theData, sizeof(Local_key));
+    regTcPtr.p->m_nr_delete.m_page_id[pos] = RNIL;
+    regTcPtr.p->m_nr_delete.m_cnt = pos + 2;
+    ndbout << "PENDING DISK DELETE: " << 
+      regTcPtr.p->m_nr_delete.m_disk_ref[pos] << endl;
+  }
+  
   TRACENR("DELETED: " << regTcPtr.p->m_row_id << endl);
 
   regTcPtr.p->m_dealloc = 0;
@@ -4093,6 +4108,88 @@
   tcConnectptr = regTcPtr;
 }
 
+void
+Dblqh::get_nr_op_info(Nr_op_info* op, Uint32 page_id)
+{
+  Ptr<TcConnectionrec> tcPtr;
+  tcPtr.i = op->m_ptr_i;
+  ptrCheckGuard(tcPtr, ctcConnectrecFileSize, tcConnectionrec);
+  
+  Ptr<Fragrecord> fragPtr;
+  c_fragment_pool.getPtr(fragPtr, tcPtr.p->fragmentptr);  
+
+  op->m_gci = tcPtr.p->gci;
+  op->m_tup_frag_ptr_i = fragPtr.p->tupFragptr;
+
+  ndbrequire(tcPtr.p->transactionState == TcConnectionrec::WAIT_TUP_COMMIT);
+  ndbrequire(tcPtr.p->activeCreat == Fragrecord::AC_NR_COPY);
+  ndbrequire(tcPtr.p->m_nr_delete.m_cnt);
+  
+  
+  if (page_id == RNIL)
+  {
+    // get log buffer callback
+    for (Uint32 i = 0; i<2; i++)
+    {
+      if (tcPtr.p->m_nr_delete.m_page_id[i] != RNIL)
+      {
+	op->m_page_id = tcPtr.p->m_nr_delete.m_page_id[i];
+	op->m_disk_ref = tcPtr.p->m_nr_delete.m_disk_ref[i];
+	return;
+      }
+    }
+  }
+  else
+  {
+    // get page callback
+    for (Uint32 i = 0; i<2; i++)
+    {
+      Local_key key = tcPtr.p->m_nr_delete.m_disk_ref[i];
+      if (op->m_disk_ref.m_page_no == key.m_page_no &&
+	  op->m_disk_ref.m_file_no == key.m_file_no &&
+	  tcPtr.p->m_nr_delete.m_page_id[i] == RNIL)
+      {
+	op->m_disk_ref = key;
+	tcPtr.p->m_nr_delete.m_page_id[i] = page_id;
+	return;
+      }
+    }
+  }
+  ndbrequire(false);
+}
+
+void 
+Dblqh::nr_delete_complete(Signal* signal, Nr_op_info* op)
+{
+  jamEntry();
+  Ptr<TcConnectionrec> tcPtr;
+  tcPtr.i = op->m_ptr_i;
+  ptrCheckGuard(tcPtr, ctcConnectrecFileSize, tcConnectionrec);
+
+  ndbrequire(tcPtr.p->transactionState == TcConnectionrec::WAIT_TUP_COMMIT);
+  ndbrequire(tcPtr.p->activeCreat == Fragrecord::AC_NR_COPY);
+  ndbrequire(tcPtr.p->m_nr_delete.m_cnt);
+  
+  tcPtr.p->m_nr_delete.m_cnt--;
+  if (tcPtr.p->m_nr_delete.m_cnt == 0)
+  {
+    tcConnectptr = tcPtr;
+    c_fragment_pool.getPtr(fragptr, tcPtr.p->fragmentptr);
+    packLqhkeyreqLab(signal);
+    return;
+  }
+
+  if (memcmp(&tcPtr.p->m_nr_delete.m_disk_ref[0], 
+	     &op->m_disk_ref, sizeof(Local_key)) == 0)
+  {
+    jam();
+    ndbassert(tcPtr.p->m_nr_delete.m_page_id[0] != RNIL);
+    tcPtr.p->m_nr_delete.m_page_id[0] = tcPtr.p->m_nr_delete.m_page_id[1];
+    tcPtr.p->m_nr_delete.m_disk_ref[0] = tcPtr.p->m_nr_delete.m_disk_ref[1];
+  }
+}
+
+
 /* =*======================================================================= */
 /* =======                 SEND KEYINFO TO ACC                       ======= */
 /*                                                                           */
@@ -6129,6 +6226,8 @@
   EXECUTE_DIRECT(acc, GSN_ACC_COMMITREQ, signal, 1);
   jamEntry();
 
+  tcConnectptr.i = tcPtrI;
+  tcConnectptr.p = tcPtr;
   tupcommit_conf(signal, tcPtr, regFragptr.p);
 }
 
@@ -6175,6 +6274,23 @@
 /* ------------------------------------------------------------------------- */
     if (tcPtrP->abortState == TcConnectionrec::ABORT_IDLE) {
       jam();
+      if (activeCreat == Fragrecord::AC_NR_COPY && 
+	  tcPtrP->m_nr_delete.m_cnt > 1)
+      {
+	jam();
+	/**
+	 * Nr delete waiting for disk delete to complete...
+	 */
+#ifdef VM_TRACE
+	TablerecPtr tablePtr;
+	tablePtr.i = tcPtrP->tableref;
+	ptrCheckGuard(tablePtr, ctabrecFileSize, tablerec);
+	ndbrequire(tablePtr.p->m_disk_table);
+#endif
+	tcPtrP->m_nr_delete.m_cnt--;
+	tcPtrP->transactionState = TcConnectionrec::WAIT_TUP_COMMIT;
+	return;
+      }
       packLqhkeyreqLab(signal);
     } else {
       ndbrequire(tcPtrP->abortState != TcConnectionrec::NEW_FROM_TC);

--- 1.33/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	2005-12-23 10:50:13 +01:00
+++ 1.34/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	2005-12-28 12:55:45 +01:00
@@ -1389,7 +1389,10 @@
 
   int nr_read_pk(Uint32 fragPtr, const Local_key*, Uint32* dataOut, bool&copy);
   int nr_update_gci(Uint32 fragPtr, const Local_key*, Uint32 gci);
-  int nr_delete(Signal*, Uint32 fragPtr, const Local_key*);
+  int nr_delete(Signal*, Uint32, Uint32 fragPtr, const Local_key*, Uint32 gci);
+
+  void nr_delete_page_callback(Signal*, Uint32 op, Uint32 page);
+  void nr_delete_logbuffer_callback(Signal*, Uint32 op, Uint32 page);
 private:
   BLOCK_DEFINES(Dbtup);
 

--- 1.11/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp	2005-12-23 10:50:13 +01:00
+++ 1.12/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp	2005-12-28 12:55:45 +01:00
@@ -475,8 +475,13 @@
     req.m_callback.m_callbackFunction = 
       safe_cast(&Dbtup::disk_page_commit_callback);
 
+    /*
+     * Consider commit to be correlated.  Otherwise pk op + commit makes
+     * the page hot.   XXX move to TUP which knows better.
+     */
     int flags= regOperPtr.p->op_struct.op_type |
-      Page_cache_client::COMMIT_REQ | Page_cache_client::STRICT_ORDER;
+      Page_cache_client::COMMIT_REQ | Page_cache_client::STRICT_ORDER |
+      Page_cache_client::CORR_REQ;
     int res= m_pgman.get_page(signal, req, flags);
     switch(res){
     case 0:

--- 1.35/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	2005-12-23 10:50:13 +01:00
+++ 1.36/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	2005-12-28 12:55:45 +01:00
@@ -3040,7 +3040,8 @@
 #include <signaldata/TuxMaint.hpp>
 
 int
-Dbtup::nr_delete(Signal* signal, Uint32 fragPtrI, const Local_key* key)
+Dbtup::nr_delete(Signal* signal, Uint32 senderData,
+		 Uint32 fragPtrI, const Local_key* key, Uint32 gci)
 {
   FragrecordPtr fragPtr;
   fragPtr.i= fragPtrI;
@@ -3068,9 +3069,8 @@
     removeTuxEntries(signal, tablePtr.p);
   }
   
-  Uint32 *disk_ref_ptr = ptr->get_disk_ref_ptr(tablePtr.p); 
-  signal->theData[0] = disk_ref_ptr[0];
-  signal->theData[1] = disk_ref_ptr[1];
+  Local_key disk;
+  memcpy(&disk, ptr->get_disk_ref_ptr(tablePtr.p), sizeof(disk));
   
   if (tablePtr.p->m_attributes[MM].m_no_of_varsize)
   {
@@ -3080,4 +3080,143 @@
     jam();
     free_fix_rec(fragPtr.p, tablePtr.p, &tmp, (Fix_page*)pagePtr.p);
   }
+
+  if (tablePtr.p->m_no_of_disk_attributes)
+  {
+    jam();
+
+    Uint32 sz = (sizeof(Dbtup::Disk_undo::Free) >> 2) + 
+      tablePtr.p->m_offsets[DD].m_fix_header_size - 1;
+    
+    int res = c_lgman->alloc_log_space(fragPtr.p->m_logfile_group_id, sz);
+    ndbrequire(res == 0);
+    
+    /**
+     * 1) alloc log buffer
+     * 2) get page
+     * 3) get log buffer
+     * 4) delete tuple
+     */
+    Page_cache_client::Request preq;
+    preq.m_page = disk;
+    preq.m_callback.m_callbackData = senderData;
+    preq.m_callback.m_callbackFunction =
+      safe_cast(&Dbtup::nr_delete_page_callback);
+    int flags = Page_cache_client::COMMIT_REQ | 
+      Page_cache_client::STRICT_ORDER;
+    res = m_pgman.get_page(signal, preq, flags);
+    if (res == 0)
+    {
+      goto timeslice;
+    }
+    else if (unlikely(res == -1))
+    {
+      return -1;
+    }
+
+    PagePtr disk_page = *(PagePtr*)&m_pgman.m_ptr;
+
+    preq.m_callback.m_callbackFunction =
+      safe_cast(&Dbtup::nr_delete_logbuffer_callback);      
+    Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id);
+    res= lgman.get_log_buffer(signal, sz, &preq.m_callback);
+    switch(res){
+    case 0:
+      signal->theData[2] = disk_page.i;
+      goto timeslice;
+    case -1:
+      ndbrequire("NOT YET IMPLEMENTED" == 0);
+      break;
+    }
+
+    ndbout << "DIRECT DISK DELETE: " << disk << endl;
+    disk_page_free(signal, tablePtr.p, fragPtr.p,
+		   &disk, *(PagePtr*)&disk_page, gci);
+    return 0;
+  }
+  
+  return 0;
+
+timeslice:
+  memcpy(signal->theData, &disk, sizeof(disk));
+  return 1;
+}
+
+void
+Dbtup::nr_delete_page_callback(Signal* signal, 
+			       Uint32 userpointer, Uint32 page_id)
+{
+  Ptr<GlobalPage> gpage;
+  m_global_page_pool.getPtr(gpage, page_id);
+  PagePtr pagePtr= *(PagePtr*)&gpage;
+
+  Dblqh::Nr_op_info op;
+  op.m_ptr_i = userpointer;
+  op.m_disk_ref.m_page_no = pagePtr.p->m_page_no;
+  op.m_disk_ref.m_file_no = pagePtr.p->m_file_no;
+  c_lqh->get_nr_op_info(&op, page_id);
+
+  Ptr<Fragrecord> fragPtr;
+  fragPtr.i= op.m_tup_frag_ptr_i;
+  ptrCheckGuard(fragPtr, cnoOfFragrec, fragrecord);
+
+  Ptr<Tablerec> tablePtr;
+  tablePtr.i = fragPtr.p->fragTableId;
+  ptrCheckGuard(tablePtr, cnoOfTablerec, tablerec);
+  
+  Uint32 sz = (sizeof(Dbtup::Disk_undo::Free) >> 2) + 
+    tablePtr.p->m_offsets[DD].m_fix_header_size - 1;
+  
+  Callback cb;
+  cb.m_callbackData = userpointer;
+  cb.m_callbackFunction =
+    safe_cast(&Dbtup::nr_delete_logbuffer_callback);      
+  Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id);
+  int res= lgman.get_log_buffer(signal, sz, &cb);
+  switch(res){
+  case 0:
+    return;
+  case -1:
+    ndbrequire("NOT YET IMPLEMENTED" == 0);
+    break;
+  }
+    
+  ndbout << "PAGE CALLBACK DISK DELETE: " << op.m_disk_ref << endl;
+  disk_page_free(signal, tablePtr.p, fragPtr.p,
+		 &op.m_disk_ref, pagePtr, op.m_gci);
+  
+  c_lqh->nr_delete_complete(signal, &op);
+  return;
+}
+
+void
+Dbtup::nr_delete_logbuffer_callback(Signal* signal, 
+				    Uint32 userpointer, 
+				    Uint32 unused)
+{
+  Dblqh::Nr_op_info op;
+  op.m_ptr_i = userpointer;
+  c_lqh->get_nr_op_info(&op, RNIL);
+  
+  Ptr<Fragrecord> fragPtr;
+  fragPtr.i= op.m_tup_frag_ptr_i;
+  ptrCheckGuard(fragPtr, cnoOfFragrec, fragrecord);
+
+  Ptr<Tablerec> tablePtr;
+  tablePtr.i = fragPtr.p->fragTableId;
+  ptrCheckGuard(tablePtr, cnoOfTablerec, tablerec);
+
+  Ptr<GlobalPage> gpage;
+  m_global_page_pool.getPtr(gpage, op.m_page_id);
+  PagePtr pagePtr= *(PagePtr*)&gpage;
+
+  /**
+   * reset page no
+   */
+  ndbout << "LOGBUFFER CALLBACK DISK DELETE: " << op.m_disk_ref << endl;
+  
+  disk_page_free(signal, tablePtr.p, fragPtr.p,
+		 &op.m_disk_ref, pagePtr, op.m_gci);
+  
+  c_lqh->nr_delete_complete(signal, &op);
 }
Thread
bk commit into 5.1 tree (jonas:1.1980)jonas30 Dec