List:Internals« Previous MessageNext Message »
From:jonas Date:August 26 2005 11:27am
Subject:bk commit into 5.1 tree (jonas:1.1973)
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.1973 05/08/26 13:26:53 jonas@eel.(none) +12 -0
  ndb diskdata
    fix failing create_file (data/undo)
    by doing 2-phase commit

  storage/ndb/src/kernel/blocks/tsman.hpp
    1.25 05/08/26 13:26:49 jonas@eel.(none) +6 -0
    Add two phase commit of create file
      enables failing creat_file

  storage/ndb/src/kernel/blocks/tsman.cpp
    1.43 05/08/26 13:26:48 jonas@eel.(none) +128 -27
    Add two phase commit of create file
      enables failing creat_file

  storage/ndb/src/kernel/blocks/pgman.hpp
    1.30 05/08/26 13:26:48 jonas@eel.(none) +12 -0
    Add two phase commit of create file
      enables failing creat_file

  storage/ndb/src/kernel/blocks/pgman.cpp
    1.34 05/08/26 13:26:48 jonas@eel.(none) +24 -0
    Add two phase commit of create file
      enables failing creat_file

  storage/ndb/src/kernel/blocks/lgman.hpp
    1.36 05/08/26 13:26:48 jonas@eel.(none) +10 -14
    Add two phase commit of create file
      enables failing creat_file

  storage/ndb/src/kernel/blocks/lgman.cpp
    1.51 05/08/26 13:26:48 jonas@eel.(none) +142 -36
    Add two phase commit of create file
      enables failing creat_file

  storage/ndb/src/kernel/blocks/diskpage.hpp
    1.25 05/08/26 13:26:48 jonas@eel.(none) +1 -1
    Changed to m_file_id to better reflect usage

  storage/ndb/src/kernel/blocks/diskpage.cpp
    1.6 05/08/26 13:26:48 jonas@eel.(none) +1 -1
    Changed to m_file_id to better reflect usage

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
    1.37 05/08/26 13:26:48 jonas@eel.(none) +5 -7
    Impl 2-phase commit for create_object (file)

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
    1.91 05/08/26 13:26:48 jonas@eel.(none) +236 -85
    Impl 2-phase commit for create_object (file)

  storage/ndb/include/kernel/signaldata/FsCloseReq.hpp
    1.7 05/08/26 13:26:48 jonas@eel.(none) +2 -0
    Allow tsman/lgman to close files

  storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp
    1.8 05/08/26 13:26:48 jonas@eel.(none) +5 -1
    Commit/Abort for CREATE_FILE_REQ

# 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/mysql-5.1-ndb-dd

--- 1.7/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp	2005-04-30 13:43:01 +02:00
+++ 1.8/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp	2005-08-26 13:26:48 +02:00
@@ -112,12 +112,16 @@
   
   STATIC_CONST( DatafileLength = 9 );
   STATIC_CONST( UndofileLength = 8 );
+  STATIC_CONST( CommitLength = 6 );
+  STATIC_CONST( AbortLength = 6 );
   SECTION( FILENAME = 0 );
   
   enum RequestInfo {
     Create = 0x1,
     CreateForce = 0x2,
-    Open = 0x4
+    Open = 0x4,
+    Commit = 0x8,
+    Abort = 0x10
   };
   
   Uint32 senderData;

--- 1.5/storage/ndb/src/kernel/blocks/diskpage.cpp	2005-08-24 08:49:49 +02:00
+++ 1.6/storage/ndb/src/kernel/blocks/diskpage.cpp	2005-08-26 13:26:48 +02:00
@@ -65,7 +65,7 @@
 operator<<(NdbOut& out, const File_formats::Undofile::Zero_page& obj)
 {
   out << obj.m_page_header << endl;
-  out << "m_file_no: " << obj.m_file_no << endl;
+  out << "m_file_id: " << obj.m_file_id << endl;
   out << "m_logfile_group_id: " << obj.m_logfile_group_id << endl;
   out << "m_logfile_group_version: " << obj.m_logfile_group_version << endl;
   out << "m_undo_pages: " << obj.m_undo_pages << endl;

--- 1.24/storage/ndb/src/kernel/blocks/diskpage.hpp	2005-08-24 08:49:49 +02:00
+++ 1.25/storage/ndb/src/kernel/blocks/diskpage.hpp	2005-08-26 13:26:48 +02:00
@@ -119,7 +119,7 @@
     struct Zero_page
     {
       struct Zero_page_header m_page_header;
-      Uint32 m_file_no;
+      Uint32 m_file_id;
       Uint32 m_logfile_group_id;
       Uint32 m_logfile_group_version;
       Uint32 m_undo_pages;

--- 1.50/storage/ndb/src/kernel/blocks/lgman.cpp	2005-08-24 08:49:49 +02:00
+++ 1.51/storage/ndb/src/kernel/blocks/lgman.cpp	2005-08-26 13:26:48 +02:00
@@ -19,6 +19,7 @@
 #include <signaldata/FsRef.hpp>
 #include <signaldata/FsConf.hpp>
 #include <signaldata/FsOpenReq.hpp>
+#include <signaldata/FsCloseReq.hpp>
 #include <signaldata/CreateFilegroupImpl.hpp>
 #include <signaldata/FsReadWriteReq.hpp>
 #include <signaldata/LCP.hpp>
@@ -49,7 +50,6 @@
 
 Lgman::Lgman(const Configuration & conf) :
   SimulatedBlock(LGMAN, conf),
-  m_file_hash(m_file_pool),
   m_logfile_group_list(m_logfile_group_pool),
   m_logfile_group_hash(m_logfile_group_pool)
 {
@@ -73,6 +73,8 @@
   addRecSignal(GSN_FSOPENREF, &Lgman::execFSOPENREF);
   addRecSignal(GSN_FSOPENCONF, &Lgman::execFSOPENCONF);
 
+  addRecSignal(GSN_FSCLOSECONF, &Lgman::execFSCLOSECONF);
+  
   addRecSignal(GSN_FSREADREF, &Lgman::execFSREADREF);
   addRecSignal(GSN_FSREADCONF, &Lgman::execFSREADCONF);
 
@@ -87,7 +89,6 @@
   m_logfile_group_pool.setSize(10);
   m_logfile_group_hash.setSize(10);
   m_file_pool.setSize(10);
-  m_file_hash.setSize(10);
   m_data_buffer_pool.setSize(10);
   m_log_waiter_pool.setSize(10000);
 }
@@ -296,6 +297,7 @@
   
   Uint32 senderRef = req->senderRef;
   Uint32 senderData = req->senderData;
+  Uint32 requestInfo = req->requestInfo;
   
   Ptr<Logfile_group> ptr;
   CreateFileImplRef::ErrorCode err = CreateFileImplRef::NoError;
@@ -315,15 +317,45 @@
     }
 
     Ptr<Undofile> file_ptr;
-    Undofile key;
-    key.m_file_no = req->file_id;
-    key.m_logfile_group_ptr_i = ptr.i;
-    if (m_file_hash.find(file_ptr, key))
+    switch(requestInfo){
+    case CreateFileImplReq::Commit:
     {
-      jam();
-      err = CreateFileImplRef::FileNoAlreadyExists;
+      ndbout_c("Create undofile %d commit", req->file_id);
+
+      ndbrequire(find_file_by_id(file_ptr, ptr.p->m_meta_files, req->file_id));
+      file_ptr.p->m_create.m_senderRef = req->senderRef;
+      file_ptr.p->m_create.m_senderData = req->senderData;
+      create_file_commit(signal, ptr, file_ptr);
+      return;
+    }
+    case CreateFileImplReq::Abort:
+    {
+      ndbout_c("Create undofile %d abort", req->file_id);
+      Uint32 senderRef = req->senderRef;
+      Uint32 senderData = req->senderData;
+      if (find_file_by_id(file_ptr, ptr.p->m_meta_files, req->file_id))
+      {
+	ndbout_c("Create undofile %d abort", req->file_id);
+	file_ptr.p->m_create.m_senderRef = senderRef;
+	file_ptr.p->m_create.m_senderData = senderData;
+	create_file_abort(signal, ptr, file_ptr);
+      }
+      else
+      {
+	ndbout_c("Create undofile %d nofile", req->file_id);	
+	CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
+	conf->senderData = senderData;
+	conf->senderRef = reference();
+	sendSignal(senderRef, GSN_CREATE_FILE_CONF, signal, 
+		   CreateFileImplConf::SignalLength, JBB);
+	return;
+      }
+      return;
+    }
+    default: // prepare
       break;
     }
+    ndbout_c("Create undofile %d prepare", req->file_id);
     
     if (!m_file_pool.seize(file_ptr))
     {
@@ -333,7 +365,6 @@
     }
     
     new (file_ptr.p) Undofile(req, ptr.i);
-    m_file_hash.add(file_ptr);
     LocalDLFifoList<Undofile> tmp(m_file_pool, ptr.p->m_meta_files);
     tmp.add(file_ptr);
     
@@ -362,6 +393,7 @@
   req->fileFlags = 0;
   req->fileFlags |= FsOpenReq::OM_READWRITE;
   req->fileFlags |= FsOpenReq::OM_DIRECT;
+  req->fileFlags |= FsOpenReq::OM_SYNC;
   switch(requestInfo){
   case CreateFileImplReq::Create:
     req->fileFlags |= FsOpenReq::OM_CREATE_IF_NONE;
@@ -381,7 +413,6 @@
     ndbrequire(false);
   }
 
-  req->fileFlags |= FsOpenReq::OM_SYNC;
   req->page_size = File_formats::NDB_PAGE_SIZE;
   Uint64 size = (Uint64)ptr.p->m_file_size * (Uint64)File_formats::NDB_PAGE_SIZE;
   req->file_size_hi = size >> 32;
@@ -411,7 +442,7 @@
 			     getOwnNodeId(),
 			     ndbGetOwnVersion(),
 			     time(0));
-    page->m_file_no = ptr.p->m_file_no;
+    page->m_file_id = ptr.p->m_file_id;
     page->m_logfile_group_id = ptr.p->m_create.m_logfile_group_id;
     page->m_logfile_group_version = ptr.p->m_create.m_logfile_group_version;
     page->m_undo_pages = ptr.p->m_file_size - 1; // minus zero page
@@ -466,14 +497,42 @@
 {
   jamEntry();
   Ptr<Undofile> ptr;  
-  Ptr<Logfile_group> lg_ptr;
 
   FsConf* conf = (FsConf*)signal->getDataPtr();
   
   Uint32 fd = conf->filePointer;
   m_file_pool.getPtr(ptr, conf->userPointer);
-  m_logfile_group_pool.getPtr(lg_ptr, ptr.p->m_logfile_group_ptr_i);
 
+  ptr.p->m_fd = fd;
+
+  {
+    Uint32 senderRef = ptr.p->m_create.m_senderRef;
+    Uint32 senderData = ptr.p->m_create.m_senderData;
+    
+    CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
+    conf->senderData = senderData;
+    conf->senderRef = reference();
+    sendSignal(senderRef, GSN_CREATE_FILE_CONF, signal, 
+	       CreateFileImplConf::SignalLength, JBB);
+  }
+}
+
+bool 
+Lgman::find_file_by_id(Ptr<Undofile>& ptr, 
+		       DLFifoList<Undofile>::Head& head, Uint32 id)
+{
+  LocalDLFifoList<Undofile> list(m_file_pool, head);
+  for(list.first(ptr); !ptr.isNull(); list.next(ptr))
+    if(ptr.p->m_file_id == id)
+      return true;
+  return false;
+}
+
+void
+Lgman::create_file_commit(Signal* signal, 
+			  Ptr<Logfile_group> lg_ptr, 
+			  Ptr<Undofile> ptr)
+{
   Uint32 senderRef = ptr.p->m_create.m_senderRef;
   Uint32 senderData = ptr.p->m_create.m_senderData;
 
@@ -516,17 +575,8 @@
     ptr.p->m_state = Undofile::FS_SORTING;
   }
   
-  ptr.p->m_online.m_fd = fd;
   ptr.p->m_online.m_outstanding = 0;
   
-  {
-    CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
-    conf->senderData = senderData;
-    conf->senderRef = reference();
-    sendSignal(senderRef, GSN_CREATE_FILE_CONF, signal, 
-	       CreateFileImplConf::SignalLength, JBB);
-  }
-
   Uint64 add= ptr.p->m_file_size - 1;
   lg_ptr.p->m_free_file_words += add * File_formats::UNDO_PAGE_WORDS;
 
@@ -545,6 +595,61 @@
     lg_ptr.p->m_tail_pos[2] = tmp;
     lg_ptr.p->m_next_reply_ptr_i = ptr.i;
   }
+
+  CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
+  conf->senderData = senderData;
+  conf->senderRef = reference();
+  sendSignal(senderRef, GSN_CREATE_FILE_CONF, signal, 
+	     CreateFileImplConf::SignalLength, JBB);
+}
+
+void
+Lgman::create_file_abort(Signal* signal, 
+			 Ptr<Logfile_group> lg_ptr, 
+			 Ptr<Undofile> ptr)
+{
+  if (ptr.p->m_fd == RNIL)
+  {
+    ((FsConf*)signal->getDataPtr())->userPointer = ptr.i;
+    execFSCLOSECONF(signal);
+    return;
+  }
+
+  ndbout_c("removing file");
+  FsCloseReq *req= (FsCloseReq*)signal->getDataPtrSend();
+  req->filePointer = ptr.p->m_fd;
+  req->userReference = reference();
+  req->userPointer = ptr.i;
+  req->fileFlag = 0;
+  FsCloseReq::setRemoveFileFlag(req->fileFlag, true);
+  
+  sendSignal(NDBFS_REF, GSN_FSCLOSEREQ, signal, 
+	     FsCloseReq::SignalLength, JBB);
+}
+
+void
+Lgman::execFSCLOSECONF(Signal* signal)
+{
+  Ptr<Undofile> ptr;
+  Ptr<Logfile_group> lg_ptr;
+  Uint32 ptrI = ((FsConf*)signal->getDataPtr())->userPointer;
+  m_file_pool.getPtr(ptr, ptrI);
+  
+  Uint32 senderRef = ptr.p->m_create.m_senderRef;
+  Uint32 senderData = ptr.p->m_create.m_senderData;
+  
+  m_logfile_group_pool.getPtr(lg_ptr, ptr.p->m_logfile_group_ptr_i);
+ 
+  LocalDLFifoList<Undofile> list(m_file_pool, lg_ptr.p->m_meta_files);
+  list.remove(ptr);
+  
+  ndbout_c("releaseing file");
+
+  CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
+  conf->senderData = senderData;
+  conf->senderRef = reference();
+  sendSignal(senderRef, GSN_CREATE_FILE_CONF, signal, 
+	     CreateFileImplConf::SignalLength, JBB);
 }
 
 void
@@ -698,7 +803,8 @@
 
 Lgman::Undofile::Undofile(const struct CreateFileImplReq* req, Uint32 ptrI)
 {
-  m_file_no = req->file_id;
+  m_fd = RNIL;
+  m_file_id = req->file_id;
   m_logfile_group_ptr_i= ptrI;
   
   Uint64 pages = req->file_size_hi;
@@ -1172,7 +1278,7 @@
   }
 
   FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtrSend();
-  req->filePointer = filePtr.p->m_online.m_fd;
+  req->filePointer = filePtr.p->m_fd;
   req->userReference = reference();
   req->userPointer = filePtr.i;
   req->varIndex = 1+head.m_idx; // skip zero page
@@ -1647,7 +1753,7 @@
     file_ptr.p->m_online.m_outstanding= page_id;
     
     FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtrSend();
-    req->filePointer = file_ptr.p->m_online.m_fd;
+    req->filePointer = file_ptr.p->m_fd;
     req->userReference = reference();
     req->userPointer = file_ptr.i;
     req->varIndex = 1; // skip zero page
@@ -1688,7 +1794,7 @@
     file_ptr.p->m_online.m_outstanding= page_id;
 
     FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtrSend();
-    req->filePointer = file_ptr.p->m_online.m_fd;
+    req->filePointer = file_ptr.p->m_fd;
     req->userReference = reference();
     req->userPointer = file_ptr.i;
     req->varIndex = ptr.p->m_file_pos[HEAD].m_ptr_i;
@@ -1877,7 +1983,7 @@
     file_ptr.p->m_online.m_outstanding= page_id;
     
     FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtrSend();
-    req->filePointer = file_ptr.p->m_online.m_fd;
+    req->filePointer = file_ptr.p->m_fd;
     req->userReference = reference();
     req->userPointer = file_ptr.i;
     req->varIndex = curr;
@@ -1936,20 +2042,20 @@
     
     SimulatedBlock* fs = globalData.getBlock(NDBFS);
     infoEvent("Undo head - %s page: %d lsn: %lld",
-	      fs->get_filename(file_ptr.p->m_online.m_fd), 
+	      fs->get_filename(file_ptr.p->m_fd), 
 	      tail, file_ptr.p->m_online.m_lsn);
     g_eventLogger.info("Undo head - %s page: %d lsn: %lld",
-		       fs->get_filename(file_ptr.p->m_online.m_fd), 
+		       fs->get_filename(file_ptr.p->m_fd), 
 		       tail, file_ptr.p->m_online.m_lsn);
     
     for(files.prev(file_ptr); !file_ptr.isNull(); files.prev(file_ptr))
     {
       infoEvent("   - next - %s(%lld)", 
-		fs->get_filename(file_ptr.p->m_online.m_fd), 
+		fs->get_filename(file_ptr.p->m_fd), 
 		file_ptr.p->m_online.m_lsn);
 
       g_eventLogger.info("   - next - %s(%lld)", 
-			 fs->get_filename(file_ptr.p->m_online.m_fd), 
+			 fs->get_filename(file_ptr.p->m_fd), 
 			 file_ptr.p->m_online.m_lsn);
     }
   }
@@ -2125,7 +2231,7 @@
   Uint32 max= tail.m_idx;
 
   FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtrSend();
-  req->filePointer = filePtr.p->m_online.m_fd;
+  req->filePointer = filePtr.p->m_fd;
   req->userReference = reference();
   req->userPointer = filePtr.i;
   req->operationFlag = 0;
@@ -2470,15 +2576,15 @@
 	infoEvent("Logfile group: %d ", ptr.p->m_logfile_group_id);
 	g_eventLogger.info("Logfile group: %d ", ptr.p->m_logfile_group_id);
 	infoEvent("  head: %s page: %d",
-		  fs->get_filename(hf.p->m_online.m_fd), 
+		  fs->get_filename(hf.p->m_fd), 
 		  ptr.p->m_file_pos[HEAD].m_idx);
 	g_eventLogger.info("  head: %s page: %d",
-			   fs->get_filename(hf.p->m_online.m_fd), 
+			   fs->get_filename(hf.p->m_fd), 
 			   ptr.p->m_file_pos[HEAD].m_idx);
 	infoEvent("  tail: %s page: %d",
-		  fs->get_filename(tf.p->m_online.m_fd), tail.m_idx);
+		  fs->get_filename(tf.p->m_fd), tail.m_idx);
 	g_eventLogger.info("  tail: %s page: %d",
-			   fs->get_filename(tf.p->m_online.m_fd), tail.m_idx);
+			   fs->get_filename(tf.p->m_fd), tail.m_idx);
       }
     }
     

--- 1.35/storage/ndb/src/kernel/blocks/lgman.hpp	2005-07-12 08:31:19 +02:00
+++ 1.36/storage/ndb/src/kernel/blocks/lgman.hpp	2005-08-26 13:26:48 +02:00
@@ -53,6 +53,9 @@
   void execFSOPENREF(Signal*);
   void execFSOPENCONF(Signal*);
 
+  void execFSCLOSEREF(Signal*);
+  void execFSCLOSECONF(Signal*);
+
   void execFSREADREF(Signal*);
   void execFSREADCONF(Signal*);
 
@@ -83,12 +86,13 @@
     Undofile(){}
     Undofile(const struct CreateFileImplReq*, Uint32 lg_ptr_i);
     
-    Uint32 m_file_no; // Unique within logfile_group
+    Uint32 m_file_id; // Dict obj id
     Uint32 m_logfile_group_ptr_i;
 
     Uint32 m_file_size;
     Uint32 m_state;
-
+    Uint32 m_fd; // When speaking to NDBFS
+    
     enum FileState 
     {
       FS_CREATING     = 0x1   // File is being created
@@ -104,7 +108,6 @@
     
     union {
       struct {
-	Uint32 m_fd;          // When speaking to NDBFS
 	Uint32 m_outstanding; // Outstaning pages
 	Uint64 m_lsn;         // Used when finding log head
       } m_online;
@@ -116,21 +119,11 @@
       } m_create;
     };
     
-    Uint32 nextHash;
-    Uint32 prevHash;
     Uint32 nextList;
     union {
       Uint32 prevList;
       Uint32 nextPool;
     };
-
-    Uint32 hashValue() const {
-      return m_file_no ^ m_logfile_group_ptr_i;
-    }
-    bool equal(const Undofile& rec) const {
-      return m_file_no == rec.m_file_no && 
-	m_logfile_group_ptr_i  == rec.m_logfile_group_ptr_i;
-    }
   };
 
   typedef LocalDataBuffer<15> Page_map;
@@ -227,7 +220,6 @@
 
   Uint64 m_last_lsn;
   Uint32 m_latest_lcp;
-  DLHashTable<Undofile> m_file_hash;
   DLFifoList<Logfile_group> m_logfile_group_list;
   KeyTable<Logfile_group> m_logfile_group_hash;
 
@@ -261,6 +253,10 @@
   const Uint32* get_next_undo_record(Uint64* lsn);
   void stop_run_undo_log(Signal* signal);
   void init_tail_ptr(Signal* signal, Ptr<Logfile_group> ptr);
+
+  bool find_file_by_id(Ptr<Undofile>&, DLFifoList<Undofile>::Head&, Uint32 id);
+  void create_file_commit(Signal* signal, Ptr<Logfile_group>, Ptr<Undofile>);
+  void create_file_abort(Signal* signal, Ptr<Logfile_group>, Ptr<Undofile>);
 };
 
 class Logfile_client {

--- 1.33/storage/ndb/src/kernel/blocks/pgman.cpp	2005-08-25 07:41:15 +02:00
+++ 1.34/storage/ndb/src/kernel/blocks/pgman.cpp	2005-08-26 13:26:48 +02:00
@@ -1381,6 +1381,19 @@
 Uint32
 Pgman::create_data_file()
 {
+  File_map::DataBufferIterator it;
+  if(m_file_map.first(it))
+  {
+    do 
+    {
+      if(*it.data == RNIL)
+      {
+	*it.data = (1u << 31) | it.pos;
+	return it.pos;
+      }
+    } while(m_file_map.next(it));
+  }
+
   Uint32 file_no = m_file_map.getSize();
   Uint32 fd = (1u << 31) | file_no;
 
@@ -1425,6 +1438,17 @@
 
   assert(*it.data == ((1u << 31) | file_no));
   *it.data = fd;
+}
+
+void
+Pgman::free_data_file(Uint32 file_no)
+{
+  File_map::DataBufferIterator it;
+  m_file_map.first(it);
+  m_file_map.next(it, file_no);
+  
+  assert(*it.data == ((1u << 31) | file_no));
+  *it.data = RNIL;
 }
 
 // debug

--- 1.29/storage/ndb/src/kernel/blocks/pgman.hpp	2005-08-25 07:41:15 +02:00
+++ 1.30/storage/ndb/src/kernel/blocks/pgman.hpp	2005-08-26 13:26:48 +02:00
@@ -297,6 +297,7 @@
   Uint32 create_data_file();
   Uint32 alloc_data_file(Uint32 file_no);
   void map_file_no(Uint32 file_no, Uint32 fd);
+  void free_data_file(Uint32 file_no);
 
   void drop_page(Ptr<Page_entry>);
   
@@ -363,6 +364,11 @@
    * Map file_no to m_fd
    */
   void map_file_no(Uint32 m_file_no, Uint32 m_fd);
+
+  /**
+   * Free file
+   */
+  void free_data_file(Uint32 file_no);
 };
 
 inline int
@@ -437,6 +443,12 @@
 Page_cache_client::map_file_no(Uint32 file_no, Uint32 fd)
 {
   m_pgman->map_file_no(file_no, fd);
+}
+
+inline void
+Page_cache_client::free_data_file(Uint32 file_no)
+{
+  m_pgman->free_data_file(file_no);
 }
 
 #endif

--- 1.42/storage/ndb/src/kernel/blocks/tsman.cpp	2005-08-25 09:29:04 +02:00
+++ 1.43/storage/ndb/src/kernel/blocks/tsman.cpp	2005-08-26 13:26:48 +02:00
@@ -20,6 +20,7 @@
 #include <signaldata/FsRef.hpp>
 #include <signaldata/FsConf.hpp>
 #include <signaldata/FsOpenReq.hpp>
+#include <signaldata/FsCloseReq.hpp>
 #include <signaldata/CreateFilegroupImpl.hpp>
 #include <signaldata/FsReadWriteReq.hpp>
 #include <signaldata/Extent.hpp>
@@ -52,6 +53,9 @@
 
   addRecSignal(GSN_FSOPENREF, &Tsman::execFSOPENREF);
   addRecSignal(GSN_FSOPENCONF, &Tsman::execFSOPENCONF);
+
+  //addRecSignal(GSN_FSCLOSEREF, &Tsman::execFSCLOSEREF);
+  addRecSignal(GSN_FSCLOSECONF, &Tsman::execFSCLOSECONF);
   addRecSignal(GSN_FSREADCONF, &Tsman::execFSREADCONF);
 
   addRecSignal(GSN_ALLOC_EXTENT_REQ, &Tsman::execALLOC_EXTENT_REQ);
@@ -298,6 +302,17 @@
   jamEntry();
 }
 
+bool 
+Tsman::find_file_by_id(Ptr<Datafile>& ptr, 
+		       DLList<Datafile>::Head& head, Uint32 id)
+{
+  LocalDLList<Datafile> list(m_file_pool, head);
+  for(list.first(ptr); !ptr.isNull(); list.next(ptr))
+    if(ptr.p->m_file_id == id)
+      return true;
+  return false;
+}
+
 void
 Tsman::execCREATE_FILE_REQ(Signal* signal){
   jamEntry();
@@ -324,6 +339,50 @@
     }
 
     Ptr<Datafile> file_ptr;
+    switch(req->requestInfo){
+    case CreateFileImplReq::Commit:
+    {
+      ndbout_c("Create file commit");
+      ndbrequire(find_file_by_id(file_ptr, ptr.p->m_meta_files, req->file_id));
+      file_ptr.p->m_create.m_senderRef = req->senderRef;
+      file_ptr.p->m_create.m_senderData = req->senderData;
+      file_ptr.p->m_create.m_requestInfo = req->requestInfo;
+      
+      m_page_cache_client.map_file_no(file_ptr.p->m_file_no, file_ptr.p->m_fd);
+      file_ptr.p->m_create.m_loading_extent_page = 1;
+      load_extent_pages(signal, file_ptr);
+      return;
+    }
+    case CreateFileImplReq::Abort:
+    {
+      Uint32 senderRef = req->senderRef;
+      Uint32 senderData = req->senderData;
+      if(find_file_by_id(file_ptr, ptr.p->m_meta_files, req->file_id))
+      {
+	ndbout_c("Create file abort");
+	file_ptr.p->m_create.m_senderRef = senderRef;
+	file_ptr.p->m_create.m_senderData = senderData;
+	file_ptr.p->m_create.m_requestInfo = req->requestInfo;
+	create_file_abort(signal, file_ptr);
+	return;
+      }
+      else
+      {
+	ndbout_c("Create file abort nofile");
+	CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
+	conf->senderData = senderData;
+	conf->senderRef = reference();
+	sendSignal(senderRef, GSN_CREATE_FILE_CONF, signal, 
+		   CreateFileImplConf::SignalLength, JBB);
+	return;
+      }
+    }
+    default:
+      ndbout_c("Create file prepare");
+      // Prepare
+      break;
+    }
+    
     if (!m_file_pool.seize(file_ptr))
     {
       jam();
@@ -353,6 +412,54 @@
 
 static inline Uint64 DIV(Uint64 a, Uint64 b){ return (a + b - 1) / b;}
 
+void
+Tsman::create_file_abort(Signal* signal, Ptr<Datafile> ptr)
+{
+  if (ptr.p->m_fd == RNIL)
+  {
+    ((FsConf*)signal->getDataPtr())->userPointer = ptr.i;
+    execFSCLOSECONF(signal);
+    return;
+  }
+
+  ndbout_c("removing file");
+  FsCloseReq *req= (FsCloseReq*)signal->getDataPtrSend();
+  req->filePointer = ptr.p->m_fd;
+  req->userReference = reference();
+  req->userPointer = ptr.i;
+  req->fileFlag = 0;
+  FsCloseReq::setRemoveFileFlag(req->fileFlag, true);
+  
+  sendSignal(NDBFS_REF, GSN_FSCLOSEREQ, signal, 
+	     FsCloseReq::SignalLength, JBB);
+}
+
+void
+Tsman::execFSCLOSECONF(Signal* signal)
+{
+  Ptr<Datafile> ptr;
+  Ptr<Tablespace> lg_ptr;
+  Uint32 ptrI = ((FsConf*)signal->getDataPtr())->userPointer;
+  m_file_pool.getPtr(ptr, ptrI);
+  
+  Uint32 senderRef = ptr.p->m_create.m_senderRef;
+  Uint32 senderData = ptr.p->m_create.m_senderData;
+  
+  m_page_cache_client.free_data_file(ptr.p->m_file_no);
+  
+  {
+    m_tablespace_pool.getPtr(lg_ptr, ptr.p->m_tablespace_ptr_i);
+    LocalDLList<Datafile> list(m_file_pool, lg_ptr.p->m_meta_files);
+    list.remove(ptr);
+  }
+  ndbout_c("releaseing file");
+  
+  CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
+  conf->senderData = senderData;
+  conf->senderRef = reference();
+  sendSignal(senderRef, GSN_CREATE_FILE_CONF, signal, 
+	     CreateFileImplConf::SignalLength, JBB);
+}
 
 int
 Tsman::open_file(Signal* signal, 
@@ -579,14 +686,11 @@
   {
     jam();
     
-    LocalDLList<Datafile> free(m_file_pool, lg_ptr.p->m_free_files);
-    LocalDLList<Datafile> meta(m_file_pool, lg_ptr.p->m_meta_files);
-    meta.remove(ptr);
-    free.add(ptr);
-    m_file_hash.add(ptr);
-    m_page_cache_client.map_file_no(ptr.p->m_file_no, fd);
-    ptr.p->m_create.m_loading_extent_page = 1;
-    load_extent_pages(signal, ptr);
+    CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
+    conf->senderData = ptr.p->m_create.m_senderData;
+    conf->senderRef = reference();
+    sendSignal(ptr.p->m_create.m_senderRef, GSN_CREATE_FILE_CONF, signal, 
+	       CreateFileImplConf::SignalLength, JBB);
     return;
   }
   case CreateFileImplReq::Open:
@@ -608,7 +712,7 @@
     ptr.p->m_create.m_page_ptr_i = page_ptr.i;
 
     FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtrSend();
-    req->filePointer = ptr.p->m_fd;
+    req->filePointer = fd;
     req->userReference = reference();
     req->userPointer = ptr.i;
     req->varIndex = 0;
@@ -713,11 +817,13 @@
     /**
      *
      */
-    m_file_hash.add(ptr);
     m_global_page_pool.release(page_ptr);
-    m_page_cache_client.map_file_no(ptr.p->m_file_no, ptr.p->m_fd);
-    ptr.p->m_create.m_loading_extent_page = 1;
-    load_extent_pages(signal, ptr);
+
+    CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
+    conf->senderData = ptr.p->m_create.m_senderData;
+    conf->senderRef = reference();
+    sendSignal(ptr.p->m_create.m_senderRef, GSN_CREATE_FILE_CONF, signal, 
+	       CreateFileImplConf::SignalLength, JBB);    
     return;
   } while(0);
 
@@ -790,6 +896,7 @@
   Uint32 extent_pages = ptr.p->m_create.m_extent_pages;
   Uint32 requestInfo = ptr.p->m_create.m_requestInfo;
   Uint32 data_pages = ptr.p->m_create.m_data_pages;
+  ndbassert(requestInfo == CreateFileImplReq::Commit);
 
   Uint32 eh= File_formats::Datafile::extent_header_words(ptr.p->m_extent_size);
   Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh;
@@ -798,21 +905,15 @@
   ptr.p->m_online.m_first_free_extent = per_page;
   ptr.p->m_online.m_lcp_free_extent_head = RNIL;  
   ptr.p->m_online.m_lcp_free_extent_tail = RNIL;  
-  switch(requestInfo){
-  case CreateFileImplReq::Create:
-  case CreateFileImplReq::CreateForce:
-    break;
-  case CreateFileImplReq::Open:
-    /**
-     * first free is unknown, need to scan extent headers
-     */
-    ptr.p->m_online.m_first_free_extent = RNIL;
-    ptr.p->m_online.m_data_pages = data_pages;
-    break;
-  default:
-    ndbrequire(false);
-  }
 
+  Ptr<Tablespace> ts_ptr;
+  m_tablespace_pool.getPtr(ts_ptr, ptr.p->m_tablespace_ptr_i);
+  LocalDLList<Datafile> free(m_file_pool, ts_ptr.p->m_free_files);
+  LocalDLList<Datafile> meta(m_file_pool, ts_ptr.p->m_meta_files);
+  meta.remove(ptr);
+  free.add(ptr);
+  m_file_hash.add(ptr);
+  
   CreateFileImplConf* conf= (CreateFileImplConf*)signal->getDataPtr();
   conf->senderData = senderData;
   conf->senderRef = reference();

--- 1.24/storage/ndb/src/kernel/blocks/tsman.hpp	2005-08-05 01:22:06 +02:00
+++ 1.25/storage/ndb/src/kernel/blocks/tsman.hpp	2005-08-26 13:26:49 +02:00
@@ -53,6 +53,9 @@
   void execFSREADREF(Signal*);
   void execFSREADCONF(Signal*);
 
+  void execFSCLOSEREF(Signal*);
+  void execFSCLOSECONF(Signal*);
+
   void execALLOC_EXTENT_REQ(Signal*);
   void execFREE_EXTENT_REQ(Signal*);
 
@@ -180,6 +183,9 @@
   void scan_tablespace(Signal*, Uint32 ptrI);
   void scan_datafile(Signal*, Uint32, Uint32);
   void scan_extent_headers(Signal*, Ptr<Datafile>);
+
+  bool find_file_by_id(Ptr<Datafile>&, DLList<Datafile>::Head&, Uint32 id);
+  void create_file_abort(Signal* signal, Ptr<Datafile>);
 };
 
 class Tablespace_client

--- 1.6/storage/ndb/include/kernel/signaldata/FsCloseReq.hpp	2005-04-29 16:30:20 +02:00
+++ 1.7/storage/ndb/include/kernel/signaldata/FsCloseReq.hpp	2005-08-26 13:26:48 +02:00
@@ -30,6 +30,8 @@
    */
   friend class Ndbfs;         // Reciver
   friend class VoidFs;
+  friend class Lgman;
+  friend class Tsman;
 
   /**
    * Sender(s)

--- 1.90/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2005-07-26 15:15:46 +02:00
+++ 1.91/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2005-08-26 13:26:48 +02:00
@@ -109,6 +109,8 @@
   Uint32 m_gsn_conf;
   void (Dbdict::* m_trans_commit_start)(Signal*, Dbdict::SchemaTransaction*);
   void (Dbdict::* m_trans_commit_complete)(Signal*,Dbdict::SchemaTransaction*);
+  void (Dbdict::* m_trans_abort_start)(Signal*, Dbdict::SchemaTransaction*);
+  void (Dbdict::* m_trans_abort_complete)(Signal*, Dbdict::SchemaTransaction*);
 
   void (Dbdict::* m_prepare_start)(Signal*, Dbdict::SchemaOp*);
   void (Dbdict::* m_prepare_complete)(Signal*, Dbdict::SchemaOp*);
@@ -123,8 +125,7 @@
    */
   { 
     GSN_CREATE_OBJ_REQ, GSN_CREATE_OBJ_REF, GSN_CREATE_OBJ_CONF,
-    &Dbdict::create_fg_trans_commit_start, 
-    &Dbdict::create_fg_trans_commit_complete, 
+    0, 0, 0, 0,
     &Dbdict::create_fg_prepare_start, &Dbdict::create_fg_prepare_complete,
     &Dbdict::create_fg_commit_start, &Dbdict::create_fg_commit_complete,
     &Dbdict::create_fg_abort_start, &Dbdict::create_fg_abort_complete,
@@ -135,8 +136,7 @@
    */
   ,{ 
     GSN_CREATE_OBJ_REQ, GSN_CREATE_OBJ_REF, GSN_CREATE_OBJ_CONF,
-    &Dbdict::create_file_trans_commit_start, 
-    &Dbdict::create_file_trans_commit_complete, 
+    0, 0, 0, 0,
     &Dbdict::create_file_prepare_start, &Dbdict::create_file_prepare_complete,
     &Dbdict::create_file_commit_start, &Dbdict::create_file_commit_complete,
     &Dbdict::create_file_abort_start, &Dbdict::create_file_abort_complete,
@@ -996,7 +996,6 @@
   case SchemaFile::DROP_TABLE_COMMITTED:
     jam();
     ok = true;
-    ndbrequire(false);
     break;
   case SchemaFile::INIT:
     jam();
@@ -13061,23 +13060,21 @@
   switch(trans_ptr_p->m_op.m_state){
   case DictObjOp::Preparing:{
 
-    if(trans_ptr_p->m_errorCode != 0){
+    if(trans_ptr_p->m_errorCode != 0)
+    {
       jam();
       /**
        * Failed to prepare on atleast one node -> abort on all
        */
-      NodeReceiverGroup rg(DBDICT, trans_ptr_p->m_nodes);
       trans_ptr_p->m_op.m_state = DictObjOp::Aborting;
-      SafeCounter tmp(c_counterMgr, trans_ptr_p->m_counter);
-      ndbrequire(tmp.init<CreateObjRef>(rg, trans_ptr_p->key));
-      
-      CreateObjReq * const req = (CreateObjReq*)signal->getDataPtrSend();
-      req->senderRef = reference();
-      req->senderData = trans_ptr_p->key;
-      req->op_key = trans_ptr_p->m_op.m_key;
-      req->requestType = DictObjOp::Abort;
+      trans_ptr_p->m_callback.m_callbackData = trans_ptr_p->key;
+      trans_ptr_p->m_callback.m_callbackFunction= 
+	safe_cast(&Dbdict::trans_abort_start_done);
       
-      sendSignal(rg, GSN_CREATE_OBJ_REQ, signal, 4, JBB);
+      if(f_dict_op[0].m_trans_abort_start)
+	(this->*f_dict_op[0].m_trans_abort_start)(signal, trans_ptr_p);
+      else
+	execute(signal, trans_ptr_p->m_callback, 0);
       return;
     }
     
@@ -13086,7 +13083,10 @@
     trans_ptr_p->m_callback.m_callbackFunction= 
       safe_cast(&Dbdict::trans_commit_start_done);
     
-    (this->*f_dict_op[0].m_trans_commit_start)(signal, trans_ptr_p);
+    if(f_dict_op[0].m_trans_commit_start)
+      (this->*f_dict_op[0].m_trans_commit_start)(signal, trans_ptr_p);
+    else
+      execute(signal, trans_ptr_p->m_callback, 0);
     return;
   }
   case DictObjOp::Committing: {
@@ -13098,25 +13098,24 @@
     trans_ptr_p->m_callback.m_callbackFunction= 
       safe_cast(&Dbdict::trans_commit_complete_done);
     
-    (this->*f_dict_op[0].m_trans_commit_complete)(signal, trans_ptr_p);
-    
+    if(f_dict_op[0].m_trans_commit_complete)
+      (this->*f_dict_op[0].m_trans_commit_complete)(signal, trans_ptr_p);
+    else
+      execute(signal, trans_ptr_p->m_callback, 0);      
     return;
   }
   case DictObjOp::Aborting:{
     jam();
-    abort();
-#if 0
-    CreateTableRef * const ref = (CreateTableRef*)signal->getDataPtr();
-    ref->senderRef = reference();
-    ref->senderData = createTabPtr_p->m_senderData;
-    ref->errorCode = createTabPtr_p->m_errorCode;
-    
-    //@todo check api failed
-    sendSignal(createTabPtr_p->m_senderRef, GSN_CREATE_TABLE_REF, signal, 
-	       CreateTableRef::SignalLength, JBB);
-    c_opCreateTable.release(createTabPtr);
-    c_blockState = BS_IDLE;
-#endif
+
+    trans_ptr_p->m_op.m_state = DictObjOp::Committed;
+    trans_ptr_p->m_callback.m_callbackData = trans_ptr_p->key;
+    trans_ptr_p->m_callback.m_callbackFunction= 
+      safe_cast(&Dbdict::trans_abort_complete_done);
+
+    if(f_dict_op[0].m_trans_abort_complete)
+      (this->*f_dict_op[0].m_trans_abort_complete)(signal, trans_ptr_p);
+    else
+      execute(signal, trans_ptr_p->m_callback, 0);      
     return;
   }
   case DictObjOp::Defined:
@@ -13205,6 +13204,86 @@
 }
 
 void
+Dbdict::trans_abort_start_done(Signal* signal, 
+			       Uint32 callbackData,
+			       Uint32 retValue){
+  jamEntry();
+  
+  ndbrequire(retValue == 0);
+
+  Ptr<SchemaTransaction> trans_ptr;
+  ndbrequire(c_Trans.find(trans_ptr, callbackData));
+  
+  NodeReceiverGroup rg(DBDICT, trans_ptr.p->m_nodes);
+  SafeCounter tmp(c_counterMgr, trans_ptr.p->m_counter);
+  ndbrequire(tmp.init<CreateObjRef>(rg, trans_ptr.p->key));
+  
+  CreateObjReq * const req = (CreateObjReq*)signal->getDataPtrSend();
+  req->senderRef = reference();
+  req->senderData = trans_ptr.p->key;
+  req->op_key = trans_ptr.p->m_op.m_key;
+  req->requestType = DictObjOp::Abort;
+  
+  sendSignal(rg, GSN_CREATE_OBJ_REQ, signal, 4, JBB);
+}
+
+void
+Dbdict::trans_abort_complete_done(Signal* signal, 
+				  Uint32 callbackData,
+				  Uint32 retValue){
+  jamEntry();
+  
+  ndbrequire(retValue == 0);
+  
+  Ptr<SchemaTransaction> trans_ptr;
+  ndbrequire(c_Trans.find(trans_ptr, callbackData));
+
+  switch(trans_ptr.p->m_op.m_gsn){
+  case GSN_CREATE_FILEGROUP_REQ:
+  {
+    //
+    CreateFilegroupRef * ref = (CreateFilegroupRef*)signal->getDataPtr();
+    ref->senderRef = reference();
+    ref->senderData = trans_ptr.p->m_senderData;
+    ref->masterNodeId = c_masterNodeId;
+    ref->errorCode = trans_ptr.p->m_errorCode;
+    ref->errorLine = 0;
+    ref->errorKey = 0;
+    ref->status = 0;
+    
+    //@todo check api failed
+    sendSignal(trans_ptr.p->m_senderRef, GSN_CREATE_FILEGROUP_REF, signal, 
+	       CreateFilegroupRef::SignalLength, JBB);
+
+    break;
+  }
+  case GSN_CREATE_FILE_REQ:
+  {
+    CreateFileRef * ref = (CreateFileRef*)signal->getDataPtr();
+    ref->senderRef = reference();
+    ref->senderData = trans_ptr.p->m_senderData;
+    ref->masterNodeId = c_masterNodeId;
+    ref->errorCode = trans_ptr.p->m_errorCode;
+    ref->errorLine = 0;
+    ref->errorKey = 0;
+    ref->status = 0;
+    
+    //@todo check api failed
+    sendSignal(trans_ptr.p->m_senderRef, GSN_CREATE_FILE_CONF, signal, 
+	       CreateFilegroupConf::SignalLength, JBB);
+    
+    break;
+  }
+  default:
+    ndbrequire(false);
+  }
+  
+  c_Trans.release(trans_ptr);
+  c_blockState = BS_IDLE;
+  return;
+}
+
+void
 Dbdict::execCREATE_OBJ_REQ(Signal* signal){
   jamEntry();
 
@@ -13218,12 +13297,15 @@
   DictObjOp::RequestType rt = (DictObjOp::RequestType)req->requestType;
   switch(rt){
   case DictObjOp::Prepare:
+    ndbout_c("execCREATE_OBJ_REQ PREPARE");
     createObj_prepare(signal, req);
     return;
   case DictObjOp::Commit:
+    ndbout_c("execCREATE_OBJ_REQ COMMIT");
     createObj_commit(signal, req);
     return;
   case DictObjOp::Abort:
+    ndbout_c("execCREATE_OBJ_REQ ABORT");
     createObj_abort(signal, req);
     return;
   }
@@ -13477,44 +13559,61 @@
   
   CreateObjRecordPtr createObjPtr;  
   ndbrequire(c_opCreateObj.find(createObjPtr, req->op_key));
-  
-  ndbrequire(false);
-#if 0
-  DropObjRecordPtr dropObjPtr;  
-  ndbrequire(c_opDropObj.seize(dropObjPtr));
-  
-  dropObjPtr.p->key = key;
-  c_opDropObj.add(dropObjPtr);
-#endif
+
+  createObjPtr.p->m_callback.m_callbackFunction = 
+    safe_cast(&Dbdict::createObj_abort_start_done);
+  (this->*f_dict_op[createObjPtr.p->m_vt_index].m_abort_start)
+    (signal, createObjPtr.p);
 }
 
 void
-Dbdict::createObj_abortComplete(Signal* signal, 
-				Uint32 callbackData,
-				Uint32 returnCode){
+Dbdict::createObj_abort_start_done(Signal* signal, 
+				   Uint32 callbackData,
+				   Uint32 returnCode){
   jam();
   
   CreateObjRecordPtr createObjPtr;  
   ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
   
-#if 0
-  DropObjRecordPtr dropObjPtr;
-  ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
-  
-  ObjRecordPtr objPtr;
-  c_objleRecordPool.getPtr(objPtr, createObjPtr.p->m_objlePtrI);
-  objPtr.p->objState = ObjRecord::NOT_DEFINED;
-  
-  releaseObjObject(objPtr.i);
-#endif
   XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
-  SchemaFile::TableEntry * tableEntry =
-    getTableEntry(xsf, createObjPtr.p->m_obj_id);
-  tableEntry->m_tableState = SchemaFile::DROP_TABLE_COMMITTED;
+  SchemaFile::TableEntry objEntry = * getTableEntry(xsf, 
+						    createObjPtr.p->m_obj_id);
+  objEntry.m_tableState = SchemaFile::DROP_TABLE_COMMITTED;
   
-  //@todo check error
-  //@todo check master failed
+  Callback callback;
+  callback.m_callbackData = createObjPtr.p->key;
+  callback.m_callbackFunction = 
+    safe_cast(&Dbdict::createObj_abort_writeSchemaConf);
   
+  updateSchemaState(signal, createObjPtr.p->m_obj_id, &objEntry, &callback);
+}
+
+void
+Dbdict::createObj_abort_writeSchemaConf(Signal* signal, 
+					Uint32 callbackData,
+					Uint32 returnCode)
+{
+  jam();
+
+  CreateObjRecordPtr createObjPtr;  
+  ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+  createObjPtr.p->m_callback.m_callbackFunction = 
+    safe_cast(&Dbdict::createObj_abort_complete_done);
+  (this->*f_dict_op[createObjPtr.p->m_vt_index].m_abort_complete)
+    (signal, createObjPtr.p);
+}
+
+void
+Dbdict::createObj_abort_complete_done(Signal* signal, 
+				      Uint32 callbackData,
+				      Uint32 returnCode)
+{
+  jam();
+
+  CreateObjRecordPtr createObjPtr;  
+  ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
   CreateObjConf * const conf = (CreateObjConf*)signal->getDataPtr();
   conf->senderRef = reference();
   conf->senderData = createObjPtr.p->m_senderData;
@@ -13522,7 +13621,6 @@
 	     signal, CreateObjConf::SignalLength, JBB);
   
   c_opCreateObj.release(createObjPtr);
-  //c_opDropObj.release(dropObjPtr);
 }
 
 void
@@ -13787,16 +13885,6 @@
   abort();
 }
 
-void
-Dbdict::create_fg_trans_commit_start(Signal* signal, SchemaTransaction* t){
-  execute(signal, t->m_callback, 0);
-}
-
-void
-Dbdict::create_fg_trans_commit_complete(Signal* signal, SchemaTransaction* t){
-  execute(signal, t->m_callback, 0);
-}
-
 void 
 Dbdict::create_file_prepare_start(Signal* signal, SchemaOp* op){
   /**
@@ -13903,6 +13991,7 @@
   execute(signal, op->m_callback, 0);
 }
 
+
 void
 Dbdict::create_file_prepare_complete(Signal* signal, SchemaOp* op){
   /**
@@ -13991,7 +14080,39 @@
 
 void
 Dbdict::create_file_commit_start(Signal* signal, SchemaOp* op){
-  execute(signal, op->m_callback, 0);
+  /**
+   * CONTACT TSMAN LGMAN PGMAN 
+   */
+  CreateFileImplReq* req = (CreateFileImplReq*)signal->getDataPtrSend();
+
+  FilePtr f_ptr;
+  c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
+
+  FilegroupPtr fg_ptr;
+  ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+
+  req->senderData = op->key;
+  req->senderRef = reference();
+  req->requestInfo = CreateFileImplReq::Commit;
+  
+  req->file_id = f_ptr.p->key;
+  req->filegroup_id = f_ptr.p->m_filegroup_id;
+  req->filegroup_version = fg_ptr.p->m_version;
+
+  Uint32 ref= 0;
+  switch(op->m_obj_type){
+  case DictTabInfo::Datafile:
+    ref = TSMAN_REF;
+    break;
+  case DictTabInfo::Undofile:
+    ref = LGMAN_REF;
+    break;
+  default:
+    ndbrequire(false);
+  }
+  
+  sendSignal(ref, GSN_CREATE_FILE_REQ, signal, 
+	     CreateFileImplReq::CommitLength, JBB);
 }
 
 void
@@ -14000,24 +14121,54 @@
 }
 
 void
-Dbdict::create_file_abort_start(Signal* signal, SchemaOp* op){
-  execute(signal, op->m_callback, 0);
-  abort();
-}
+Dbdict::create_file_abort_start(Signal* signal, SchemaOp* op)
+{
+  CreateFileImplReq* req = (CreateFileImplReq*)signal->getDataPtrSend();
 
-void
-Dbdict::create_file_abort_complete(Signal* signal, SchemaOp* op){
-  execute(signal, op->m_callback, 0);
-  abort();
-}
+  FilePtr f_ptr;
+  c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
 
-void
-Dbdict::create_file_trans_commit_start(Signal* signal, SchemaTransaction* t){
-  execute(signal, t->m_callback, 0);
+  FilegroupPtr fg_ptr;
+  ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+
+  req->senderData = op->key;
+  req->senderRef = reference();
+  req->requestInfo = CreateFileImplReq::Abort;
+  
+  req->file_id = f_ptr.p->key;
+  req->filegroup_id = f_ptr.p->m_filegroup_id;
+  req->filegroup_version = fg_ptr.p->m_version;
+
+  Uint32 ref= 0;
+  switch(op->m_obj_type){
+  case DictTabInfo::Datafile:
+    ref = TSMAN_REF;
+    break;
+  case DictTabInfo::Undofile:
+    ref = LGMAN_REF;
+    break;
+  default:
+    ndbrequire(false);
+  }
+  
+  sendSignal(ref, GSN_CREATE_FILE_REQ, signal, 
+	     CreateFileImplReq::AbortLength, JBB);
 }
 
 void
-Dbdict::create_file_trans_commit_complete(Signal* signal, SchemaTransaction* t){
-  execute(signal, t->m_callback, 0);
+Dbdict::create_file_abort_complete(Signal* signal, SchemaOp* op)
+{
+  FilePtr f_ptr;
+  c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
+
+  FilegroupPtr fg_ptr;
+  ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+  
+  release_object(f_ptr.p->m_obj_ptr_i);
+  
+  LocalDLList<File> list(c_file_pool, fg_ptr.p->m_files);
+  list.release(f_ptr);
+
+  execute(signal, op->m_callback, 0);
 }
 

--- 1.36/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2005-07-25 10:30:28 +02:00
+++ 1.37/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2005-08-26 13:26:48 +02:00
@@ -2403,11 +2403,15 @@
   void createObj_writeSchemaConf2(Signal* signal, Uint32 callbackData, Uint32);
   void createObj_commit_complete_done(Signal*, Uint32 callbackData, Uint32);
   void createObj_abort(Signal*, struct CreateObjReq*);
-  void createObj_abortComplete(Signal*, Uint32 callbackData, Uint32);
+  void createObj_abort_start_done(Signal*, Uint32 callbackData, Uint32);
+  void createObj_abort_writeSchemaConf(Signal*, Uint32 callbackData, Uint32);
+  void createObj_abort_complete_done(Signal*, Uint32 callbackData, Uint32);  
 
   void createObj_reply(Signal* signal, SchemaTransaction *, Uint32);
   void trans_commit_start_done(Signal*, Uint32 callbackData, Uint32);
   void trans_commit_complete_done(Signal*, Uint32 callbackData, Uint32);
+  void trans_abort_start_done(Signal*, Uint32 callbackData, Uint32);
+  void trans_abort_complete_done(Signal*, Uint32 callbackData, Uint32);
 
   void execDROP_OBJ_REQ(Signal* signal);  
   void execDROP_OBJ_REF(Signal* signal);  
@@ -2439,18 +2443,12 @@
   void create_fg_abort_start(Signal* signal, SchemaOp*);
   void create_fg_abort_complete(Signal* signal, SchemaOp*);
 
-  void create_fg_trans_commit_start(Signal* signal, SchemaTransaction*);
-  void create_fg_trans_commit_complete(Signal* signal, SchemaTransaction*);
-
   void create_file_prepare_start(Signal* signal, SchemaOp*);
   void create_file_prepare_complete(Signal* signal, SchemaOp*);
   void create_file_commit_start(Signal* signal, SchemaOp*);
   void create_file_commit_complete(Signal* signal, SchemaOp*);
   void create_file_abort_start(Signal* signal, SchemaOp*);
   void create_file_abort_complete(Signal* signal, SchemaOp*);
-
-  void create_file_trans_commit_start(Signal* signal, SchemaTransaction*);
-  void create_file_trans_commit_complete(Signal* signal, SchemaTransaction*);
 };
 
 inline bool
Thread
bk commit into 5.1 tree (jonas:1.1973)jonas26 Aug