Loading storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +49 −4 Original line number Diff line number Diff line Loading @@ -79,18 +79,26 @@ is_ndb_blob_table(const NdbTableImpl* t) NdbColumnImpl::NdbColumnImpl() : NdbDictionary::Column(* this), m_attrId(-1), m_facade(this) { DBUG_ENTER("NdbColumnImpl::NdbColumnImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbColumnImpl::NdbColumnImpl(NdbDictionary::Column & f) : NdbDictionary::Column(* this), m_attrId(-1), m_facade(&f) { DBUG_ENTER("NdbColumnImpl::NdbColumnImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbColumnImpl& NdbColumnImpl::operator=(const NdbColumnImpl& col) { DBUG_ENTER("NdbColumnImpl::operator="); DBUG_PRINT("info", ("this: %p &col: %p", this, &col)); m_attrId = col.m_attrId; m_name = col.m_name; m_type = col.m_type; Loading @@ -112,13 +120,14 @@ NdbColumnImpl::operator=(const NdbColumnImpl& col) if (col.m_blobTable == NULL) m_blobTable = NULL; else { if (m_blobTable == NULL) m_blobTable = new NdbTableImpl(); m_blobTable->assign(*col.m_blobTable); } m_column_no = col.m_column_no; // Do not copy m_facade !! return *this; DBUG_RETURN(*this); } void Loading Loading @@ -261,15 +270,19 @@ NdbColumnImpl::init(Type t) NdbColumnImpl::~NdbColumnImpl() { DBUG_ENTER("NdbColumnImpl::~NdbColumnImpl"); DBUG_PRINT("info", ("this: %p", this)); if (m_blobTable != NULL) delete m_blobTable; m_blobTable = NULL; DBUG_VOID_RETURN; } bool NdbColumnImpl::equal(const NdbColumnImpl& col) const { DBUG_ENTER("NdbColumnImpl::equal"); DBUG_PRINT("info", ("this: %p &col: %p", this, &col)); if(strcmp(m_name.c_str(), col.m_name.c_str()) != 0){ DBUG_RETURN(false); } Loading Loading @@ -377,24 +390,33 @@ NdbTableImpl::NdbTableImpl() : NdbDictionary::Table(* this), NdbDictObjectImpl(NdbDictionary::Object::UserTable), m_facade(this) { DBUG_ENTER("NdbTableImpl::NdbTableImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbTableImpl::NdbTableImpl(NdbDictionary::Table & f) : NdbDictionary::Table(* this), NdbDictObjectImpl(NdbDictionary::Object::UserTable), m_facade(&f) { DBUG_ENTER("NdbTableImpl::NdbTableImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbTableImpl::~NdbTableImpl() { DBUG_ENTER("NdbTableImpl::~NdbTableImpl"); DBUG_PRINT("info", ("this: %p", this)); if (m_index != 0) { delete m_index; m_index = 0; } for (unsigned i = 0; i < m_columns.size(); i++) delete m_columns[i]; DBUG_VOID_RETURN; } void Loading Loading @@ -636,6 +658,8 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const void NdbTableImpl::assign(const NdbTableImpl& org) { DBUG_ENTER("NdbColumnImpl::assign"); DBUG_PRINT("info", ("this: %p &org: %p", this, &org)); /* m_changeMask intentionally not copied */ m_primaryTableId = org.m_primaryTableId; m_internalName.assign(org.m_internalName); Loading @@ -662,7 +686,14 @@ NdbTableImpl::assign(const NdbTableImpl& org) m_columnHashMask, m_columnHash, m_hashValueMask, m_hashpointerValue is state calculated by computeAggregates and buildColumnHash */ for(unsigned i = 0; i<org.m_columns.size(); i++){ unsigned i; for(i = 0; i < m_columns.size(); i++) { delete m_columns[i]; } m_columns.clear(); for(i = 0; i < org.m_columns.size(); i++) { NdbColumnImpl * col = new NdbColumnImpl(); const NdbColumnImpl * iorg = org.m_columns[i]; (* col) = (* iorg); Loading Loading @@ -702,6 +733,7 @@ NdbTableImpl::assign(const NdbTableImpl& org) m_tablespace_name = org.m_tablespace_name; m_tablespace_id= org.m_tablespace_id; m_tablespace_version = org.m_tablespace_version; DBUG_VOID_RETURN; } void NdbTableImpl::setName(const char * name) Loading Loading @@ -1085,14 +1117,20 @@ NdbEventImpl::NdbEventImpl() : NdbDictionary::Event(* this), NdbDictObjectImpl(NdbDictionary::Object::TypeUndefined), m_facade(this) { DBUG_ENTER("NdbEventImpl::NdbEventImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbEventImpl::NdbEventImpl(NdbDictionary::Event & f) : NdbDictionary::Event(* this), NdbDictObjectImpl(NdbDictionary::Object::TypeUndefined), m_facade(&f) { DBUG_ENTER("NdbEventImpl::NdbEventImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } void NdbEventImpl::init() Loading @@ -1108,10 +1146,13 @@ void NdbEventImpl::init() NdbEventImpl::~NdbEventImpl() { DBUG_ENTER("NdbEventImpl::~NdbEventImpl"); DBUG_PRINT("info", ("this: %p", this)); for (unsigned i = 0; i < m_columns.size(); i++) delete m_columns[i]; if (m_tableImpl) delete m_tableImpl; DBUG_VOID_RETURN; } void NdbEventImpl::setName(const char * name) Loading @@ -1134,11 +1175,14 @@ NdbEventImpl::setTable(const NdbDictionary::Table& table) void NdbEventImpl::setTable(NdbTableImpl *tableImpl) { DBUG_ENTER("NdbEventImpl::setTable"); DBUG_PRINT("info", ("this: %p tableImpl: %p", this, tableImpl)); DBUG_ASSERT(tableImpl->m_status != NdbDictionary::Object::Invalid); if (!m_tableImpl) m_tableImpl = new NdbTableImpl(); // Copy table, since event might be accessed from different threads m_tableImpl->assign(*tableImpl); DBUG_VOID_RETURN; } const NdbDictionary::Table * Loading Loading @@ -3944,6 +3988,7 @@ NdbDictionaryImpl::dropBlobEvents(const NdbEventImpl& evnt) if (blob_evnt == NULL) continue; (void)dropEvent(*blob_evnt); delete blob_evnt; } } else { // loop over MAX_ATTRIBUTES_IN_TABLE ... Loading storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +58 −57 Original line number Diff line number Diff line Loading @@ -70,21 +70,6 @@ print_std(const SubTableData * sdata, LinearSectionPtr ptr[3]) * */ //#define EVENT_DEBUG #ifdef EVENT_DEBUG #define DBUG_ENTER_EVENT(A) DBUG_ENTER(A) #define DBUG_RETURN_EVENT(A) DBUG_RETURN(A) #define DBUG_VOID_RETURN_EVENT DBUG_VOID_RETURN #define DBUG_PRINT_EVENT(A,B) DBUG_PRINT(A,B) #define DBUG_DUMP_EVENT(A,B,C) DBUG_DUMP(A,B,C) #else #define DBUG_ENTER_EVENT(A) #define DBUG_RETURN_EVENT(A) return(A) #define DBUG_VOID_RETURN_EVENT return #define DBUG_PRINT_EVENT(A,B) #define DBUG_DUMP_EVENT(A,B,C) #endif // todo handle several ndb objects // todo free allocated data when closing NdbEventBuffer Loading Loading @@ -189,6 +174,17 @@ NdbEventOperationImpl::~NdbEventOperationImpl() // m_bufferHandle->dropSubscribeEvent(m_bufferId); ; // ToDo? We should send stop signal here if (theMainOp == NULL) { NdbEventOperationImpl* tBlobOp = theBlobOpList; while (tBlobOp != NULL) { NdbEventOperationImpl *op = tBlobOp; tBlobOp = tBlobOp->m_next; delete op; } } m_ndb->theImpl->theNdbObjectIdMap.unmap(m_oid, this); DBUG_PRINT("exit",("this: %p/%p oid: %u main: %p", this, m_facade, m_oid, theMainOp)); Loading Loading @@ -973,7 +969,15 @@ NdbEventBuffer::~NdbEventBuffer() delete op->m_facade; } for (unsigned j= 0; j < m_allocated_data.size(); j++) unsigned j; Uint32 sz= m_active_gci.size(); Gci_container* array = (Gci_container*)m_active_gci.getBase(); for(j = 0; j < sz; j++) { array[j].~Gci_container(); } for (j= 0; j < m_allocated_data.size(); j++) { unsigned sz= m_allocated_data[j]->sz; EventBufData *data= m_allocated_data[j]->data; Loading Loading @@ -1476,6 +1480,7 @@ NdbEventBuffer::report_node_failure(Uint32 node_id) data.req_nodeid = (Uint8)node_id; data.ndbd_nodeid = (Uint8)node_id; data.logType = SubTableData::LOG; data.gci = m_latestGCI + 1; /** * Insert this event for each operation */ Loading @@ -1492,8 +1497,11 @@ NdbEventBuffer::report_node_failure(Uint32 node_id) void NdbEventBuffer::completeClusterFailed() { DBUG_ENTER("NdbEventBuffer::completeClusterFailed"); NdbEventOperation* op= m_ndb->getEventOperation(0); if (op == 0) return; DBUG_ENTER("NdbEventBuffer::completeClusterFailed"); SubTableData data; LinearSectionPtr ptr[3]; bzero(&data, sizeof(data)); Loading @@ -1502,15 +1510,27 @@ NdbEventBuffer::completeClusterFailed() data.tableId = ~0; data.operation = NdbDictionary::Event::_TE_CLUSTER_FAILURE; data.logType = SubTableData::LOG; data.gci = m_latestGCI + 1; /** * Insert this event for each operation */ do { NdbEventOperationImpl* impl= &op->m_impl; data.senderData = impl->m_oid; insertDataL(impl, &data, ptr); } while((op = m_ndb->getEventOperation(op))); /** * Find min not completed GCI */ Uint32 i; Uint32 sz= m_active_gci.size(); Uint64 gci= ~0; Gci_container* bucket = 0; Gci_container* array = (Gci_container*)m_active_gci.getBase(); for(Uint32 i = 0; i<sz; i++) for(i = 0; i < sz; i++) { if(array[i].m_gcp_complete_rep_count && array[i].m_gci < gci) { Loading @@ -1519,57 +1539,28 @@ NdbEventBuffer::completeClusterFailed() } } if(bucket == 0) { /** * Did not find any not completed GCI's * lets fake one... */ gci = m_latestGCI + 1; bucket = array + ( gci & ACTIVE_GCI_MASK ); bucket->m_gcp_complete_rep_count = 1; } const Uint32 cnt= bucket->m_gcp_complete_rep_count = 1; /** * Release all GCI's * Release all GCI's with m_gci > gci */ for(Uint32 i = 0; i<sz; i++) for(i = 0; i < sz; i++) { Gci_container* tmp = array + i; if (tmp->m_gci > gci) { if(!tmp->m_data.is_empty()) { free_list(tmp->m_data); #if 0 m_free_data_count++; EventBufData* loop= tmp->m_head; while(loop != tmp->m_tail) { m_free_data_count++; loop = loop->m_next; } #endif } tmp->~Gci_container(); bzero(tmp, sizeof(Gci_container)); } } assert(bucket != 0 && data.gci == gci); const Uint32 cnt= bucket->m_gcp_complete_rep_count = 1; bucket->m_gci = gci; bucket->m_gcp_complete_rep_count = cnt; data.gci = gci; /** * Insert this event for each operation */ NdbEventOperation* op= 0; while((op = m_ndb->getEventOperation(op))) { NdbEventOperationImpl* impl= &op->m_impl; data.senderData = impl->m_oid; insertDataL(impl, &data, ptr); } /** * And finally complete this GCI */ Loading Loading @@ -2262,8 +2253,12 @@ EventBufData_list::add_gci_op(Gci_op g, bool del) if (m_gci_op_alloc != 0) { Uint32 bytes = m_gci_op_alloc * sizeof(Gci_op); memcpy(m_gci_op_list, old_list, bytes); DBUG_PRINT_EVENT("info", ("this: %p delete m_gci_op_list: %p", this, old_list)); delete [] old_list; } DBUG_PRINT_EVENT("info", ("this: %p new m_gci_op_list: %p", this, m_gci_op_list)); m_gci_op_alloc = n; } assert(m_gci_op_count < m_gci_op_alloc); Loading @@ -2275,6 +2270,9 @@ EventBufData_list::add_gci_op(Gci_op g, bool del) void EventBufData_list::move_gci_ops(EventBufData_list *list, Uint64 gci) { DBUG_ENTER_EVENT("EventBufData_list::move_gci_ops"); DBUG_PRINT_EVENT("info", ("this: %p list: %p gci: %llu", this, list, gci)); assert(!m_is_not_multi_list); if (!list->m_is_not_multi_list) { Loading @@ -2290,6 +2288,8 @@ EventBufData_list::move_gci_ops(EventBufData_list *list, Uint64 gci) } { Gci_ops *new_gci_ops = new Gci_ops; DBUG_PRINT_EVENT("info", ("this: %p m_gci_op_list: %p", new_gci_ops, list->m_gci_op_list)); if (m_gci_ops_list_tail) m_gci_ops_list_tail->m_next = new_gci_ops; else Loading @@ -2308,6 +2308,7 @@ EventBufData_list::move_gci_ops(EventBufData_list *list, Uint64 gci) list->m_gci_op_list = 0; list->m_gci_ops_list_tail = 0; list->m_gci_op_alloc = 0; DBUG_VOID_RETURN_EVENT; } NdbEventOperation* Loading storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp +28 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,20 @@ #include <UtilBuffer.hpp> #define NDB_EVENT_OP_MAGIC_NUMBER 0xA9F301B4 //#define EVENT_DEBUG #ifdef EVENT_DEBUG #define DBUG_ENTER_EVENT(A) DBUG_ENTER(A) #define DBUG_RETURN_EVENT(A) DBUG_RETURN(A) #define DBUG_VOID_RETURN_EVENT DBUG_VOID_RETURN #define DBUG_PRINT_EVENT(A,B) DBUG_PRINT(A,B) #define DBUG_DUMP_EVENT(A,B,C) DBUG_DUMP(A,B,C) #else #define DBUG_ENTER_EVENT(A) #define DBUG_RETURN_EVENT(A) return(A) #define DBUG_VOID_RETURN_EVENT return #define DBUG_PRINT_EVENT(A,B) #define DBUG_DUMP_EVENT(A,B,C) #endif class NdbEventOperationImpl; Loading Loading @@ -149,19 +163,29 @@ EventBufData_list::EventBufData_list() m_gci_ops_list_tail(0), m_gci_op_alloc(0) { DBUG_ENTER_EVENT("EventBufData_list::EventBufData_list"); DBUG_PRINT_EVENT("info", ("this: %p", this)); DBUG_VOID_RETURN_EVENT; } inline EventBufData_list::~EventBufData_list() { DBUG_ENTER_EVENT("EventBufData_list::~EventBufData_list"); DBUG_PRINT_EVENT("info", ("this: %p m_is_not_multi_list: %u", this, m_is_not_multi_list)); if (m_is_not_multi_list) { DBUG_PRINT_EVENT("info", ("delete m_gci_op_list: %p", m_gci_op_list)); delete [] m_gci_op_list; } else { Gci_ops *op = first_gci_ops(); while (op) op = next_gci_ops(); } DBUG_VOID_RETURN_EVENT; } inline Loading Loading @@ -223,7 +247,11 @@ EventBufData_list::next_gci_ops() Gci_ops *first = m_gci_ops_list; m_gci_ops_list = first->m_next; if (first->m_gci_op_list) { DBUG_PRINT_EVENT("info", ("this: %p delete m_gci_op_list: %p", this, first->m_gci_op_list)); delete [] first->m_gci_op_list; } delete first; if (m_gci_ops_list == 0) m_gci_ops_list_tail = 0; Loading Loading
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +49 −4 Original line number Diff line number Diff line Loading @@ -79,18 +79,26 @@ is_ndb_blob_table(const NdbTableImpl* t) NdbColumnImpl::NdbColumnImpl() : NdbDictionary::Column(* this), m_attrId(-1), m_facade(this) { DBUG_ENTER("NdbColumnImpl::NdbColumnImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbColumnImpl::NdbColumnImpl(NdbDictionary::Column & f) : NdbDictionary::Column(* this), m_attrId(-1), m_facade(&f) { DBUG_ENTER("NdbColumnImpl::NdbColumnImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbColumnImpl& NdbColumnImpl::operator=(const NdbColumnImpl& col) { DBUG_ENTER("NdbColumnImpl::operator="); DBUG_PRINT("info", ("this: %p &col: %p", this, &col)); m_attrId = col.m_attrId; m_name = col.m_name; m_type = col.m_type; Loading @@ -112,13 +120,14 @@ NdbColumnImpl::operator=(const NdbColumnImpl& col) if (col.m_blobTable == NULL) m_blobTable = NULL; else { if (m_blobTable == NULL) m_blobTable = new NdbTableImpl(); m_blobTable->assign(*col.m_blobTable); } m_column_no = col.m_column_no; // Do not copy m_facade !! return *this; DBUG_RETURN(*this); } void Loading Loading @@ -261,15 +270,19 @@ NdbColumnImpl::init(Type t) NdbColumnImpl::~NdbColumnImpl() { DBUG_ENTER("NdbColumnImpl::~NdbColumnImpl"); DBUG_PRINT("info", ("this: %p", this)); if (m_blobTable != NULL) delete m_blobTable; m_blobTable = NULL; DBUG_VOID_RETURN; } bool NdbColumnImpl::equal(const NdbColumnImpl& col) const { DBUG_ENTER("NdbColumnImpl::equal"); DBUG_PRINT("info", ("this: %p &col: %p", this, &col)); if(strcmp(m_name.c_str(), col.m_name.c_str()) != 0){ DBUG_RETURN(false); } Loading Loading @@ -377,24 +390,33 @@ NdbTableImpl::NdbTableImpl() : NdbDictionary::Table(* this), NdbDictObjectImpl(NdbDictionary::Object::UserTable), m_facade(this) { DBUG_ENTER("NdbTableImpl::NdbTableImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbTableImpl::NdbTableImpl(NdbDictionary::Table & f) : NdbDictionary::Table(* this), NdbDictObjectImpl(NdbDictionary::Object::UserTable), m_facade(&f) { DBUG_ENTER("NdbTableImpl::NdbTableImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbTableImpl::~NdbTableImpl() { DBUG_ENTER("NdbTableImpl::~NdbTableImpl"); DBUG_PRINT("info", ("this: %p", this)); if (m_index != 0) { delete m_index; m_index = 0; } for (unsigned i = 0; i < m_columns.size(); i++) delete m_columns[i]; DBUG_VOID_RETURN; } void Loading Loading @@ -636,6 +658,8 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const void NdbTableImpl::assign(const NdbTableImpl& org) { DBUG_ENTER("NdbColumnImpl::assign"); DBUG_PRINT("info", ("this: %p &org: %p", this, &org)); /* m_changeMask intentionally not copied */ m_primaryTableId = org.m_primaryTableId; m_internalName.assign(org.m_internalName); Loading @@ -662,7 +686,14 @@ NdbTableImpl::assign(const NdbTableImpl& org) m_columnHashMask, m_columnHash, m_hashValueMask, m_hashpointerValue is state calculated by computeAggregates and buildColumnHash */ for(unsigned i = 0; i<org.m_columns.size(); i++){ unsigned i; for(i = 0; i < m_columns.size(); i++) { delete m_columns[i]; } m_columns.clear(); for(i = 0; i < org.m_columns.size(); i++) { NdbColumnImpl * col = new NdbColumnImpl(); const NdbColumnImpl * iorg = org.m_columns[i]; (* col) = (* iorg); Loading Loading @@ -702,6 +733,7 @@ NdbTableImpl::assign(const NdbTableImpl& org) m_tablespace_name = org.m_tablespace_name; m_tablespace_id= org.m_tablespace_id; m_tablespace_version = org.m_tablespace_version; DBUG_VOID_RETURN; } void NdbTableImpl::setName(const char * name) Loading Loading @@ -1085,14 +1117,20 @@ NdbEventImpl::NdbEventImpl() : NdbDictionary::Event(* this), NdbDictObjectImpl(NdbDictionary::Object::TypeUndefined), m_facade(this) { DBUG_ENTER("NdbEventImpl::NdbEventImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } NdbEventImpl::NdbEventImpl(NdbDictionary::Event & f) : NdbDictionary::Event(* this), NdbDictObjectImpl(NdbDictionary::Object::TypeUndefined), m_facade(&f) { DBUG_ENTER("NdbEventImpl::NdbEventImpl"); DBUG_PRINT("info", ("this: %p", this)); init(); DBUG_VOID_RETURN; } void NdbEventImpl::init() Loading @@ -1108,10 +1146,13 @@ void NdbEventImpl::init() NdbEventImpl::~NdbEventImpl() { DBUG_ENTER("NdbEventImpl::~NdbEventImpl"); DBUG_PRINT("info", ("this: %p", this)); for (unsigned i = 0; i < m_columns.size(); i++) delete m_columns[i]; if (m_tableImpl) delete m_tableImpl; DBUG_VOID_RETURN; } void NdbEventImpl::setName(const char * name) Loading @@ -1134,11 +1175,14 @@ NdbEventImpl::setTable(const NdbDictionary::Table& table) void NdbEventImpl::setTable(NdbTableImpl *tableImpl) { DBUG_ENTER("NdbEventImpl::setTable"); DBUG_PRINT("info", ("this: %p tableImpl: %p", this, tableImpl)); DBUG_ASSERT(tableImpl->m_status != NdbDictionary::Object::Invalid); if (!m_tableImpl) m_tableImpl = new NdbTableImpl(); // Copy table, since event might be accessed from different threads m_tableImpl->assign(*tableImpl); DBUG_VOID_RETURN; } const NdbDictionary::Table * Loading Loading @@ -3944,6 +3988,7 @@ NdbDictionaryImpl::dropBlobEvents(const NdbEventImpl& evnt) if (blob_evnt == NULL) continue; (void)dropEvent(*blob_evnt); delete blob_evnt; } } else { // loop over MAX_ATTRIBUTES_IN_TABLE ... Loading
storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp +58 −57 Original line number Diff line number Diff line Loading @@ -70,21 +70,6 @@ print_std(const SubTableData * sdata, LinearSectionPtr ptr[3]) * */ //#define EVENT_DEBUG #ifdef EVENT_DEBUG #define DBUG_ENTER_EVENT(A) DBUG_ENTER(A) #define DBUG_RETURN_EVENT(A) DBUG_RETURN(A) #define DBUG_VOID_RETURN_EVENT DBUG_VOID_RETURN #define DBUG_PRINT_EVENT(A,B) DBUG_PRINT(A,B) #define DBUG_DUMP_EVENT(A,B,C) DBUG_DUMP(A,B,C) #else #define DBUG_ENTER_EVENT(A) #define DBUG_RETURN_EVENT(A) return(A) #define DBUG_VOID_RETURN_EVENT return #define DBUG_PRINT_EVENT(A,B) #define DBUG_DUMP_EVENT(A,B,C) #endif // todo handle several ndb objects // todo free allocated data when closing NdbEventBuffer Loading Loading @@ -189,6 +174,17 @@ NdbEventOperationImpl::~NdbEventOperationImpl() // m_bufferHandle->dropSubscribeEvent(m_bufferId); ; // ToDo? We should send stop signal here if (theMainOp == NULL) { NdbEventOperationImpl* tBlobOp = theBlobOpList; while (tBlobOp != NULL) { NdbEventOperationImpl *op = tBlobOp; tBlobOp = tBlobOp->m_next; delete op; } } m_ndb->theImpl->theNdbObjectIdMap.unmap(m_oid, this); DBUG_PRINT("exit",("this: %p/%p oid: %u main: %p", this, m_facade, m_oid, theMainOp)); Loading Loading @@ -973,7 +969,15 @@ NdbEventBuffer::~NdbEventBuffer() delete op->m_facade; } for (unsigned j= 0; j < m_allocated_data.size(); j++) unsigned j; Uint32 sz= m_active_gci.size(); Gci_container* array = (Gci_container*)m_active_gci.getBase(); for(j = 0; j < sz; j++) { array[j].~Gci_container(); } for (j= 0; j < m_allocated_data.size(); j++) { unsigned sz= m_allocated_data[j]->sz; EventBufData *data= m_allocated_data[j]->data; Loading Loading @@ -1476,6 +1480,7 @@ NdbEventBuffer::report_node_failure(Uint32 node_id) data.req_nodeid = (Uint8)node_id; data.ndbd_nodeid = (Uint8)node_id; data.logType = SubTableData::LOG; data.gci = m_latestGCI + 1; /** * Insert this event for each operation */ Loading @@ -1492,8 +1497,11 @@ NdbEventBuffer::report_node_failure(Uint32 node_id) void NdbEventBuffer::completeClusterFailed() { DBUG_ENTER("NdbEventBuffer::completeClusterFailed"); NdbEventOperation* op= m_ndb->getEventOperation(0); if (op == 0) return; DBUG_ENTER("NdbEventBuffer::completeClusterFailed"); SubTableData data; LinearSectionPtr ptr[3]; bzero(&data, sizeof(data)); Loading @@ -1502,15 +1510,27 @@ NdbEventBuffer::completeClusterFailed() data.tableId = ~0; data.operation = NdbDictionary::Event::_TE_CLUSTER_FAILURE; data.logType = SubTableData::LOG; data.gci = m_latestGCI + 1; /** * Insert this event for each operation */ do { NdbEventOperationImpl* impl= &op->m_impl; data.senderData = impl->m_oid; insertDataL(impl, &data, ptr); } while((op = m_ndb->getEventOperation(op))); /** * Find min not completed GCI */ Uint32 i; Uint32 sz= m_active_gci.size(); Uint64 gci= ~0; Gci_container* bucket = 0; Gci_container* array = (Gci_container*)m_active_gci.getBase(); for(Uint32 i = 0; i<sz; i++) for(i = 0; i < sz; i++) { if(array[i].m_gcp_complete_rep_count && array[i].m_gci < gci) { Loading @@ -1519,57 +1539,28 @@ NdbEventBuffer::completeClusterFailed() } } if(bucket == 0) { /** * Did not find any not completed GCI's * lets fake one... */ gci = m_latestGCI + 1; bucket = array + ( gci & ACTIVE_GCI_MASK ); bucket->m_gcp_complete_rep_count = 1; } const Uint32 cnt= bucket->m_gcp_complete_rep_count = 1; /** * Release all GCI's * Release all GCI's with m_gci > gci */ for(Uint32 i = 0; i<sz; i++) for(i = 0; i < sz; i++) { Gci_container* tmp = array + i; if (tmp->m_gci > gci) { if(!tmp->m_data.is_empty()) { free_list(tmp->m_data); #if 0 m_free_data_count++; EventBufData* loop= tmp->m_head; while(loop != tmp->m_tail) { m_free_data_count++; loop = loop->m_next; } #endif } tmp->~Gci_container(); bzero(tmp, sizeof(Gci_container)); } } assert(bucket != 0 && data.gci == gci); const Uint32 cnt= bucket->m_gcp_complete_rep_count = 1; bucket->m_gci = gci; bucket->m_gcp_complete_rep_count = cnt; data.gci = gci; /** * Insert this event for each operation */ NdbEventOperation* op= 0; while((op = m_ndb->getEventOperation(op))) { NdbEventOperationImpl* impl= &op->m_impl; data.senderData = impl->m_oid; insertDataL(impl, &data, ptr); } /** * And finally complete this GCI */ Loading Loading @@ -2262,8 +2253,12 @@ EventBufData_list::add_gci_op(Gci_op g, bool del) if (m_gci_op_alloc != 0) { Uint32 bytes = m_gci_op_alloc * sizeof(Gci_op); memcpy(m_gci_op_list, old_list, bytes); DBUG_PRINT_EVENT("info", ("this: %p delete m_gci_op_list: %p", this, old_list)); delete [] old_list; } DBUG_PRINT_EVENT("info", ("this: %p new m_gci_op_list: %p", this, m_gci_op_list)); m_gci_op_alloc = n; } assert(m_gci_op_count < m_gci_op_alloc); Loading @@ -2275,6 +2270,9 @@ EventBufData_list::add_gci_op(Gci_op g, bool del) void EventBufData_list::move_gci_ops(EventBufData_list *list, Uint64 gci) { DBUG_ENTER_EVENT("EventBufData_list::move_gci_ops"); DBUG_PRINT_EVENT("info", ("this: %p list: %p gci: %llu", this, list, gci)); assert(!m_is_not_multi_list); if (!list->m_is_not_multi_list) { Loading @@ -2290,6 +2288,8 @@ EventBufData_list::move_gci_ops(EventBufData_list *list, Uint64 gci) } { Gci_ops *new_gci_ops = new Gci_ops; DBUG_PRINT_EVENT("info", ("this: %p m_gci_op_list: %p", new_gci_ops, list->m_gci_op_list)); if (m_gci_ops_list_tail) m_gci_ops_list_tail->m_next = new_gci_ops; else Loading @@ -2308,6 +2308,7 @@ EventBufData_list::move_gci_ops(EventBufData_list *list, Uint64 gci) list->m_gci_op_list = 0; list->m_gci_ops_list_tail = 0; list->m_gci_op_alloc = 0; DBUG_VOID_RETURN_EVENT; } NdbEventOperation* Loading
storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp +28 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,20 @@ #include <UtilBuffer.hpp> #define NDB_EVENT_OP_MAGIC_NUMBER 0xA9F301B4 //#define EVENT_DEBUG #ifdef EVENT_DEBUG #define DBUG_ENTER_EVENT(A) DBUG_ENTER(A) #define DBUG_RETURN_EVENT(A) DBUG_RETURN(A) #define DBUG_VOID_RETURN_EVENT DBUG_VOID_RETURN #define DBUG_PRINT_EVENT(A,B) DBUG_PRINT(A,B) #define DBUG_DUMP_EVENT(A,B,C) DBUG_DUMP(A,B,C) #else #define DBUG_ENTER_EVENT(A) #define DBUG_RETURN_EVENT(A) return(A) #define DBUG_VOID_RETURN_EVENT return #define DBUG_PRINT_EVENT(A,B) #define DBUG_DUMP_EVENT(A,B,C) #endif class NdbEventOperationImpl; Loading Loading @@ -149,19 +163,29 @@ EventBufData_list::EventBufData_list() m_gci_ops_list_tail(0), m_gci_op_alloc(0) { DBUG_ENTER_EVENT("EventBufData_list::EventBufData_list"); DBUG_PRINT_EVENT("info", ("this: %p", this)); DBUG_VOID_RETURN_EVENT; } inline EventBufData_list::~EventBufData_list() { DBUG_ENTER_EVENT("EventBufData_list::~EventBufData_list"); DBUG_PRINT_EVENT("info", ("this: %p m_is_not_multi_list: %u", this, m_is_not_multi_list)); if (m_is_not_multi_list) { DBUG_PRINT_EVENT("info", ("delete m_gci_op_list: %p", m_gci_op_list)); delete [] m_gci_op_list; } else { Gci_ops *op = first_gci_ops(); while (op) op = next_gci_ops(); } DBUG_VOID_RETURN_EVENT; } inline Loading Loading @@ -223,7 +247,11 @@ EventBufData_list::next_gci_ops() Gci_ops *first = m_gci_ops_list; m_gci_ops_list = first->m_next; if (first->m_gci_op_list) { DBUG_PRINT_EVENT("info", ("this: %p delete m_gci_op_list: %p", this, first->m_gci_op_list)); delete [] first->m_gci_op_list; } delete first; if (m_gci_ops_list == 0) m_gci_ops_list_tail = 0; Loading