From: Jonas Oreland Date: January 23 2012 8:31am Subject: bzr push into mysql-5.1-telco-7.1 branch (jonas.oreland:4429 to 4430) List-Archive: http://lists.mysql.com/commits/142508 Message-Id: <20120123083109.4224855C278@perch.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4430 Jonas Oreland 2012-01-23 [merge] ndb - merge 70 to 71 added: storage/ndb/src/kernel/vm/CountingPool.cpp storage/ndb/src/kernel/vm/CountingPool.hpp modified: storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp storage/ndb/src/kernel/vm/CMakeLists.txt storage/ndb/src/kernel/vm/Makefile.am storage/ndb/src/kernel/vm/Pool.cpp storage/ndb/src/kernel/vm/Pool.hpp 4429 Craig L Russell 2012-01-22 Add NdbRecord support for clusterj. This implementation supports only insert. The original implementation using NdbOperation is still available by setting the variable com.mysql.clusterj.UseNdbRecord to a value other than "true" via -D option or environment. added: storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/NdbRecordBlobImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/NdbRecordImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/NdbRecordOperationImpl.java modified: storage/ndb/clusterj/clusterj-core/src/main/java/com/mysql/clusterj/core/SessionImpl.java storage/ndb/clusterj/clusterj-core/src/main/java/com/mysql/clusterj/core/store/Operation.java storage/ndb/clusterj/clusterj-tie/Makefile.am storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/BlobImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterConnectionServiceImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ClusterTransactionImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/ColumnImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/DbImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/DictionaryImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/OperationImpl.java storage/ndb/clusterj/clusterj-tie/src/main/java/com/mysql/clusterj/tie/Utility.java storage/ndb/clusterj/clusterj-tie/src/main/resources/com/mysql/clusterj/tie/Bundle.properties === modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp' --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2012-01-19 11:50:25 +0000 +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2012-01-23 08:22:03 +0000 @@ -6536,7 +6536,8 @@ Dbdict::execADD_FRAGREQ(Signal* signal) findSchemaOp(op_ptr, alterTabPtr, senderData); ndbrequire(!op_ptr.isNull()); alterTabPtr.p->m_dihAddFragPtr = dihPtr; - tabPtr = alterTabPtr.p->m_newTablePtr; + tabPtr.i = alterTabPtr.p->m_newTablePtrI; + c_tableRecordPool_.getPtr(tabPtr); } else { @@ -8060,7 +8061,6 @@ Dbdict::alterTable_parse(Signal* signal, } // save it for abort code - alterTabPtr.p->m_tablePtr = tablePtr; if (tablePtr.p->tableVersion != impl_req->tableVersion) { jam(); @@ -8069,7 +8069,7 @@ Dbdict::alterTable_parse(Signal* signal, } // parse new table definition into new table record - TableRecordPtr& newTablePtr = alterTabPtr.p->m_newTablePtr; // ref + TableRecordPtr newTablePtr; { ParseDictTabInfoRecord parseRecord; parseRecord.requestType = DictTabInfo::AlterTableFromAPI; @@ -8091,6 +8091,7 @@ Dbdict::alterTable_parse(Signal* signal, // the new temporary table record seized from pool newTablePtr = parseRecord.tablePtr; + alterTabPtr.p->m_newTablePtrI = newTablePtr.i; alterTabPtr.p->m_newTable_realObjectId = newTablePtr.p->tableId; newTablePtr.p->tableId = impl_req->tableId; // set correct table id...(not the temporary) } @@ -8370,7 +8371,7 @@ Dbdict::alterTable_parse(Signal* signal, jam(); releaseSections(handle); SimplePropertiesSectionWriter w(* this); - packTableIntoPages(w, alterTabPtr.p->m_newTablePtr); + packTableIntoPages(w, newTablePtr); SegmentedSectionPtr tabInfoPtr; w.getPtr(tabInfoPtr); @@ -9178,8 +9179,11 @@ Dbdict::alterTable_toLocal(Signal* signa { jam(); HashMapRecordPtr hm_ptr; + TableRecordPtr newTablePtr; + newTablePtr.i = alterTabPtr.p->m_newTablePtrI; + c_tableRecordPool_.getPtr(newTablePtr); ndbrequire(find_object(hm_ptr, - alterTabPtr.p->m_newTablePtr.p->hashMapObjectId)); + newTablePtr.p->hashMapObjectId)); req->new_map_ptr_i = hm_ptr.p->m_map_ptr_i; } @@ -9267,7 +9271,9 @@ Dbdict::alterTable_commit(Signal* signal tablePtr.p->tableVersion = impl_req->newTableVersion; tablePtr.p->gciTableCreated = impl_req->gci; - TableRecordPtr newTablePtr = alterTabPtr.p->m_newTablePtr; + TableRecordPtr newTablePtr; + newTablePtr.i = alterTabPtr.p->m_newTablePtrI; + c_tableRecordPool_.getPtr(newTablePtr); const Uint32 changeMask = impl_req->changeMask; @@ -9359,7 +9365,9 @@ Dbdict::alterTable_commit(Signal* signal /** * DIH is next op */ - TableRecordPtr newTablePtr = alterTabPtr.p->m_newTablePtr; + TableRecordPtr newTablePtr; + newTablePtr.i = alterTabPtr.p->m_newTablePtrI; + c_tableRecordPool_.getPtr(newTablePtr); tablePtr.p->hashMapObjectId = newTablePtr.p->hashMapObjectId; tablePtr.p->hashMapVersion = newTablePtr.p->hashMapVersion; alterTabPtr.p->m_blockNo[1] = RNIL; @@ -9575,7 +9583,7 @@ Dbdict::alterTable_fromCommitComplete(Si objEntry->m_transId = 0; } - releaseTableObject(alterTabPtr.p->m_newTablePtr.i, false); + releaseTableObject(alterTabPtr.p->m_newTablePtrI, false); sendTransConf(signal, op_ptr); } @@ -9653,8 +9661,7 @@ Dbdict::alterTable_abortParse(Signal* si return; } - TableRecordPtr& newTablePtr = alterTabPtr.p->m_newTablePtr; // ref - if (!newTablePtr.isNull()) { + if (alterTabPtr.p->m_newTablePtrI != RNIL) { jam(); // release the temporary work table @@ -9667,14 +9674,8 @@ Dbdict::alterTable_abortParse(Signal* si objEntry->m_transId = 0; } - releaseTableObject(newTablePtr.i, false); - newTablePtr.setNull(); - } - - TableRecordPtr& tablePtr = alterTabPtr.p->m_tablePtr; // ref - if (!tablePtr.isNull()) { - jam(); - tablePtr.setNull(); + releaseTableObject(alterTabPtr.p->m_newTablePtrI, false); + alterTabPtr.p->m_newTablePtrI = RNIL; } sendTransConf(signal, op_ptr); === modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp' --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2011-12-07 17:51:26 +0000 +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2012-01-23 08:00:45 +0000 @@ -2530,8 +2530,7 @@ private: MutexHandle2 m_define_backup_mutex; // current and new temporary work table - TableRecordPtr m_tablePtr; - TableRecordPtr m_newTablePtr; + TableRecordPtr::I m_newTablePtrI; Uint32 m_newTable_realObjectId; // before image @@ -2560,8 +2559,7 @@ private: AlterTableRec() : OpRec(g_opInfo, (Uint32*)&m_request) { memset(&m_request, 0, sizeof(m_request)); - m_tablePtr.setNull(); - m_newTablePtr.setNull(); + m_newTablePtrI = RNIL; m_dihAddFragPtr = RNIL; m_lqhFragPtr = RNIL; m_blockNo[0] = DBLQH; === modified file 'storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp' --- a/storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp 2011-12-23 08:29:16 +0000 +++ b/storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp 2012-01-23 08:12:19 +0000 @@ -63,8 +63,14 @@ struct Tup_fixsize_page struct File_formats::Page_header m_page_header; Uint32 m_restart_seq; Uint32 page_state; - Uint32 next_page; - Uint32 prev_page; + union { + Uint32 next_page; + Uint32 nextList; + }; + union { + Uint32 prev_page; + Uint32 prevList; + }; Uint32 first_cluster_page; Uint32 last_cluster_page; Uint32 next_cluster_page; @@ -108,8 +114,14 @@ struct Tup_varsize_page struct File_formats::Page_header m_page_header; Uint32 m_restart_seq; Uint32 page_state; - Uint32 next_page; - Uint32 prev_page; + union { + Uint32 next_page; + Uint32 nextList; + }; + union { + Uint32 prev_page; + Uint32 prevList; + }; Uint32 first_cluster_page; Uint32 last_cluster_page; Uint32 next_cluster_page; === modified file 'storage/ndb/src/kernel/vm/CMakeLists.txt' --- a/storage/ndb/src/kernel/vm/CMakeLists.txt 2011-08-30 12:00:48 +0000 +++ b/storage/ndb/src/kernel/vm/CMakeLists.txt 2012-01-23 08:20:12 +0000 @@ -17,7 +17,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/ndb/src/mgmapi) INCLUDE(${CMAKE_SOURCE_DIR}/storage/ndb/config/type_kernel.cmake) -ADD_LIBRARY(ndbkernel STATIC +ADD_CONVENIENCE_LIBRARY(ndbkernel VMSignal.cpp Emulator.cpp Configuration.cpp @@ -41,7 +41,7 @@ ADD_LIBRARY(ndbkernel STATIC mt_thr_config.cpp ) -ADD_LIBRARY(ndbsched STATIC +ADD_CONVENIENCE_LIBRARY(ndbsched TimeQueue.cpp ThreadConfig.cpp FastScheduler.cpp @@ -53,7 +53,7 @@ ADD_LIBRARY(ndbsched STATIC ) IF(NDB_BUILD_NDBMTD) - ADD_LIBRARY(ndbsched_mt STATIC + ADD_CONVENIENCE_LIBRARY(ndbsched_mt SimulatedBlock_mt.cpp TransporterCallback_mt.cpp LongSignal_mt.cpp @@ -62,3 +62,19 @@ IF(NDB_BUILD_NDBMTD) dummy_mt.cpp) ENDIF() +ADD_CONVENIENCE_LIBRARY(ndbtest + test_context.cpp + ../blocks/dbtup/tuppage.cpp +) + +ADD_EXECUTABLE(mt_thr_config-t mt_thr_config.cpp) +SET_TARGET_PROPERTIES(mt_thr_config-t + PROPERTIES COMPILE_FLAGS "-DTEST_MT_THR_CONFIG") +TARGET_LINK_LIBRARIES(mt_thr_config-t ndbgeneral) + +FOREACH(testprog IN ITEMS CountingPool DynArr256) + ADD_EXECUTABLE(${testprog}-t ${testprog}.cpp) + SET_TARGET_PROPERTIES(${testprog}-t PROPERTIES COMPILE_FLAGS "-DTAP_TEST") + TARGET_LINK_LIBRARIES(${testprog}-t ndbtest ndbkernel ndbsched ndberror + ndbtransport ndbmgmcommon ndbmgmapi ndbportlib ndbgeneral) +ENDFOREACH(testprog) === added file 'storage/ndb/src/kernel/vm/CountingPool.cpp' --- a/storage/ndb/src/kernel/vm/CountingPool.cpp 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/src/kernel/vm/CountingPool.cpp 2012-01-23 08:20:12 +0000 @@ -0,0 +1,29 @@ +#ifdef TAP_TEST + +#include +#include "CountingPool.hpp" +#include "Pool.hpp" +#include "RWPool.hpp" +#include "test_context.hpp" +#include "WOPool.hpp" + +struct record +{ + int dummy; +}; + +template class CountingPool >; +template class CountingPool >; + +TAPTEST(CountingPool) +{ + Pool_context pc = test_context(100); + + // Only compile test. See template instantiations above. + + OK(true); + + return 1; +} + +#endif === added file 'storage/ndb/src/kernel/vm/CountingPool.hpp' --- a/storage/ndb/src/kernel/vm/CountingPool.hpp 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/src/kernel/vm/CountingPool.hpp 2012-01-23 08:20:12 +0000 @@ -0,0 +1,118 @@ +#ifndef COUNTINGPOOL_HPP +#define COUNTINGPOOL_HPP + +#include +#include "blocks/diskpage.hpp" +#include "blocks/dbtup/tuppage.hpp" +#include "ndbd_malloc_impl.hpp" +#include "DLList.hpp" +#include "Pool.hpp" + +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +// Implementation CountingPool + +template +class CountingPool : public P +{ + Uint32 m_inuse; + Uint32 m_inuse_high; + Uint32 m_max_allowed; +protected: +public: + CountingPool() :m_inuse(0), m_inuse_high(0), m_max_allowed(UINT32_MAX) + {} + + bool seize(Ptr& ptr) + { + if (m_inuse >= m_max_allowed) + { + return false; + } + bool ok = P::seize(ptr); + if (!ok) + { + return false; + } + m_inuse++; + if (m_inuse_high < m_inuse) + { + m_inuse_high++; + } + return true; + } + + void release(Ptr ptr) + { + P::release(ptr); + m_inuse--; + } + + void release(Uint32 i) + { + Ptr p; + getPtr(p, i); + release(p); + } + + T* getPtr(Uint32 i) + { + return P::getPtr(i); + } + + void getPtr(Ptr& p, Uint32 i) + { + p.i = i; + p.p = getPtr(i); + } + + void getPtr(Ptr& p) + { + p.p = getPtr(p.i); + } + + bool seize(Uint32& i) + { + Ptr p; + p.i = i; + bool ok = seize(p); + i = p.i; + return ok; + } + +public: + // Extra methods + void setSize(Uint32 size) + { + m_max_allowed = size; + } + + Uint32 getSize() const + { + return m_max_allowed /*m_seized*/; + } + + Uint32 getEntrySize() const + { + return 8 * ((sizeof(T) + 7) / 8); // Assuming alignment every 8 byte + } + + Uint32 getNoOfFree() const + { + return getSize() - getUsed(); + } + + Uint32 getUsed() const + { + return m_inuse; + } + + Uint32 getUsedHi() const + { + return m_inuse_high; + } +}; + +#endif === modified file 'storage/ndb/src/kernel/vm/Makefile.am' --- a/storage/ndb/src/kernel/vm/Makefile.am 2011-12-23 08:28:23 +0000 +++ b/storage/ndb/src/kernel/vm/Makefile.am 2012-01-23 08:20:12 +0000 @@ -58,7 +58,8 @@ libsched_mt_a_SOURCES = SimulatedBlock_m mt.cpp \ dummy_mt.cpp -libtest_a_SOURCES = test_context.cpp +libtest_a_SOURCES = test_context.cpp \ + ../blocks/dbtup/tuppage.cpp EXTRA_DIST=SimulatedBlock.cpp TransporterCallback.cpp CMakeLists.txt LongSignal.cpp SimplePropertiesSection.cpp @@ -90,33 +91,32 @@ bench_pool_LDADD = libkernel.a ../error/ $(top_builddir)/dbug/libdbuglt.la \ $(top_builddir)/strings/libmystringslt.la -testDynArr256_CXXFLAGS = -DUNIT_TEST -testDynArr256_SOURCES = DynArr256.cpp -testDynArr256_LDFLAGS = @ndb_bin_am_ldflags@ -testDynArr256_LDADD = libtest.a \ +test_ldadd = libtest.a \ libkernel.a libsched.a ../error/liberror.a \ $(top_builddir)/storage/ndb/src/libndbclient.la \ $(top_builddir)/mysys/libmysyslt.la \ $(top_builddir)/dbug/libdbuglt.la \ $(top_builddir)/strings/libmystringslt.la +testDynArr256_CXXFLAGS = -DUNIT_TEST +testDynArr256_SOURCES = DynArr256.cpp +testDynArr256_LDFLAGS = @ndb_bin_am_ldflags@ +testDynArr256_LDADD = $(test_ldadd) + +CountingPool_t_CXXFLAGS = -DTAP_TEST +CountingPool_t_SOURCES = CountingPool.cpp +CountingPool_t_LDFLAGS = @ndb_bin_am_ldflags@ +CountingPool_t_LDADD = $(test_ldadd) + DynArr256_t_CXXFLAGS = -DTAP_TEST DynArr256_t_SOURCES = DynArr256.cpp DynArr256_t_LDFLAGS = @ndb_bin_am_ldflags@ -DynArr256_t_LDADD = libtest.a \ - libkernel.a libsched.a ../error/liberror.a \ - $(top_builddir)/storage/ndb/src/libndbclient.la \ - $(top_builddir)/mysys/libmysyslt.la \ - $(top_builddir)/dbug/libdbuglt.la \ - $(top_builddir)/strings/libmystringslt.la +DynArr256_t_LDADD = $(test_ldadd) testSectionReader_CXXFLAGS = -DUNIT_TEST testSectionReader_SOURCES = SectionReader.cpp testSectionReader_LDFLAGS = @ndb_bin_am_ldflags@ -testSectionReader_LDADD = $(top_builddir)/storage/ndb/src/libndbclient.la \ - $(top_builddir)/mysys/libmysyslt.la \ - $(top_builddir)/dbug/libdbuglt.la \ - $(top_builddir)/strings/libmystringslt.la +testSectionReader_LDADD = $(test_ldadd) testLongSignals_CXXFLAGS = -DUNIT_TEST testLongSignals_SOURCES = testLongSig/testLongSig.cpp @@ -143,4 +143,4 @@ mt_thr_config_t_LDADD = \ $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \ $(top_builddir)/mysys/libmysyslt.la -noinst_PROGRAMS = mt_thr_config-t DynArr256-t +noinst_PROGRAMS = mt_thr_config-t CountingPool-t DynArr256-t === modified file 'storage/ndb/src/kernel/vm/Pool.cpp' --- a/storage/ndb/src/kernel/vm/Pool.cpp 2011-06-30 15:59:25 +0000 +++ b/storage/ndb/src/kernel/vm/Pool.cpp 2012-01-23 07:55:02 +0000 @@ -34,13 +34,13 @@ Pool_context::release_page(Uint32 type_i } void* -Pool_context::get_memroot() +Pool_context::get_memroot() const { return m_block->m_ctx.m_mm.get_memroot(); } void -Pool_context::handleAbort(int err, const char * msg) +Pool_context::handleAbort(int err, const char * msg) const { m_block->progError(__LINE__, err, msg); } === modified file 'storage/ndb/src/kernel/vm/Pool.hpp' --- a/storage/ndb/src/kernel/vm/Pool.hpp 2011-10-07 11:46:40 +0000 +++ b/storage/ndb/src/kernel/vm/Pool.hpp 2012-01-23 08:00:45 +0000 @@ -72,7 +72,7 @@ struct Pool_context /** * Get mem root */ - void* get_memroot(); + void* get_memroot() const; /** * Alloc consekutive pages @@ -118,12 +118,13 @@ struct Pool_context /** * Abort */ - void handleAbort(int code, const char* msg) ATTRIBUTE_NORETURN; + void handleAbort(int code, const char* msg) const ATTRIBUTE_NORETURN; }; template struct Ptr { + typedef Uint32 I; T * p; Uint32 i; inline bool isNull() const { return i == RNIL; } No bundle (reason: useless for push emails).