#At file:///home/msvensson/mysql/6.3/
2747 Magnus Svensson 2008-11-19 [merge]
Merge
modified:
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
storage/ndb/src/kernel/blocks/lgman.cpp
storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp
storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp
storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.cpp
storage/ndb/src/kernel/blocks/tsman.cpp
storage/ndb/test/include/HugoOperations.hpp
storage/ndb/test/include/HugoTransactions.hpp
storage/ndb/test/src/HugoOperations.cpp
storage/ndb/test/src/HugoTransactions.cpp
storage/ndb/test/src/NDBT_Tables.cpp
storage/ndb/test/tools/hugoPkRead.cpp
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2008-11-18 08:11:19 +0000
+++ b/sql/ha_ndbcluster.cc 2008-11-18 09:08:29 +0000
@@ -8105,11 +8105,13 @@ Ndb* check_ndb_in_thd(THD* thd, bool val
return NULL;
set_thd_ndb(thd, thd_ndb);
}
+#ifdef NOT_YET
else if (validate_ndb && !thd_ndb->valid_ndb())
{
if (!thd_ndb->recycle_ndb(thd))
return NULL;
}
+#endif
return thd_ndb->ndb;
}
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2008-11-18 08:11:19 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2008-11-18 18:51:06 +0000
@@ -5467,7 +5467,9 @@ pthread_handler_t ndb_binlog_thread_func
pthread_mutex_unlock(&LOCK_thread_count);
thd->lex->start_transaction_opt= 0;
+#ifdef NOT_YET
restart_cluster_failure:
+#endif
if (!(s_ndb= new Ndb(g_ndb_cluster_connection, "")) ||
s_ndb->init())
{
@@ -5722,17 +5724,6 @@ restart:
res= i_ndb->pollEvents(tot_poll_wait, &gci);
tot_poll_wait= 0;
}
- else
- {
- /*
- Just consume any events, not used if no binlogging
- e.g. node failure events
- */
- Uint64 tmp_gci;
- if (i_ndb->pollEvents(0, &tmp_gci))
- while (i_ndb->nextEvent())
- ;
- }
int schema_res= s_ndb->pollEvents(tot_poll_wait, &schema_gci);
ndb_latest_received_binlog_epoch= gci;
@@ -5838,7 +5829,35 @@ restart:
}
}
- if (res > 0)
+ if (!ndb_binlog_running)
+ {
+ /*
+ Just consume any events, not used if no binlogging
+ e.g. node failure events
+ */
+ Uint64 tmp_gci;
+ if (i_ndb->pollEvents(0, &tmp_gci))
+ {
+ NdbEventOperation *pOp;
+ while ((pOp= i_ndb->nextEvent()))
+ {
+ if ((unsigned) pOp->getEventType() >=
+ (unsigned) NDBEVENT::TE_FIRST_NON_DATA_EVENT)
+ {
+ ndb_binlog_index_row row;
+ ndb_binlog_thread_handle_non_data_event(thd, i_ndb, pOp, row);
+ }
+ }
+ if (i_ndb->getEventOperation() == NULL &&
+ s_ndb->getEventOperation() == NULL &&
+ do_ndbcluster_binlog_close_connection == BCCC_running)
+ {
+ DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection= BCCC_restart"));
+ do_ndbcluster_binlog_close_connection= BCCC_restart;
+ }
+ }
+ }
+ else if (res > 0)
{
DBUG_PRINT("info", ("pollEvents res: %d", res));
thd->proc_info= "Processing events";
=== modified file 'storage/ndb/src/kernel/blocks/lgman.cpp'
--- a/storage/ndb/src/kernel/blocks/lgman.cpp 2008-04-22 20:09:38 +0000
+++ b/storage/ndb/src/kernel/blocks/lgman.cpp 2008-11-18 10:21:28 +0000
@@ -639,11 +639,10 @@ Lgman::execFSWRITEREQ(Signal* signal)
FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtr();
m_file_pool.getPtr(ptr, req->userPointer);
- m_global_page_pool.getPtr(page_ptr, req->data.pageData[0]);
+ m_shared_page_pool.getPtr(page_ptr, req->data.pageData[0]);
if (req->varIndex == 0)
{
- jam();
File_formats::Undofile::Zero_page* page =
(File_formats::Undofile::Zero_page*)page_ptr.p;
page->m_page_header.init(File_formats::FT_Undofile,
@@ -657,7 +656,6 @@ Lgman::execFSWRITEREQ(Signal* signal)
}
else
{
- jam();
File_formats::Undofile::Undo_page* page =
(File_formats::Undofile::Undo_page*)page_ptr.p;
page->m_page_header.m_page_lsn_hi = 0;
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp 2008-08-28 08:11:47 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp 2008-11-18 10:21:28 +0000
@@ -258,6 +258,8 @@ protected:
public:
SimulatedBlock& m_fs;
+
+ Uint32 m_page_cnt;
Ptr<GlobalPage> m_page_ptr;
};
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 2008-11-06 16:46:27 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp 2008-11-18 10:24:01 +0000
@@ -190,9 +190,15 @@ Ndbfs::execFSOPENREQ(Signal* signal)
if(fsOpenReq->fileFlags & FsOpenReq::OM_INIT)
{
+ jam();
+ Uint32 cnt = 16; // 512k
Ptr<GlobalPage> page_ptr;
- if(m_global_page_pool.seize(page_ptr) == false)
+ m_ctx.m_mm.alloc_pages(RT_DBTUP_PAGE, &page_ptr.i, &cnt, 1);
+ if(cnt == 0)
{
+ file->m_page_ptr.setNull();
+ file->m_page_cnt = 0;
+
FsRef * const fsRef = (FsRef *)&signal->theData[0];
fsRef->userPointer = userPointer;
fsRef->setErrorCode(fsRef->errorCode, FsRef::fsErrOutOfMemory);
@@ -200,12 +206,15 @@ Ndbfs::execFSOPENREQ(Signal* signal)
sendSignal(userRef, GSN_FSOPENREF, signal, 3, JBB);
return;
}
+ m_shared_page_pool.getPtr(page_ptr);
file->m_page_ptr = page_ptr;
+ file->m_page_cnt = cnt;
}
else
{
ndbassert(file->m_page_ptr.isNull());
file->m_page_ptr.setNull();
+ file->m_page_cnt = 0;
}
if(signal->getNoOfSections() == 0){
@@ -700,8 +709,12 @@ Ndbfs::report(Request * request, Signal*
if(!request->file->m_page_ptr.isNull())
{
- m_global_page_pool.release(request->file->m_page_ptr);
+ assert(request->file->m_page_cnt > 0);
+ m_ctx.m_mm.release_pages(RT_DBTUP_PAGE,
+ request->file->m_page_ptr.i,
+ request->file->m_page_cnt);
request->file->m_page_ptr.setNull();
+ request->file->m_page_cnt = 0;
}
if (request->error) {
=== modified file 'storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.cpp'
--- a/storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.cpp 2008-10-21 13:13:10 +0000
+++ b/storage/ndb/src/kernel/blocks/ndbfs/PosixAsyncFile.cpp 2008-11-18 10:21:28 +0000
@@ -32,6 +32,8 @@
#include <signaldata/FsOpenReq.hpp>
#include <signaldata/FsReadWriteReq.hpp>
+#include <NdbTick.h>
+
// use this to test broken pread code
//#define HAVE_BROKEN_PREAD
@@ -330,20 +332,39 @@ no_odirect:
posix_fallocate(theFd, 0, sz);
#endif
+#ifdef VM_TRACE
+#define TRACE_INIT
+#endif
+
+#ifdef TRACE_INIT
+ Uint32 write_cnt = 0;
+ Uint64 start = NdbTick_CurrentMillisecond();
+#endif
while(off < sz)
{
- req->filePointer = 0; // DATA 0
- req->userPointer = request->theUserPointer; // DATA 2
- req->numberOfPages = 1; // DATA 5
- req->varIndex = index++;
- req->data.pageData[0] = m_page_ptr.i;
-
- m_fs.EXECUTE_DIRECT(block, GSN_FSWRITEREQ, signal,
- FsReadWriteReq::FixedLength + 1);
+ off_t size = 0;
+ Uint32 cnt = 0;
+ while (cnt < m_page_cnt && (off + size) < sz)
+ {
+ req->filePointer = 0; // DATA 0
+ req->userPointer = request->theUserPointer; // DATA 2
+ req->numberOfPages = 1; // DATA 5
+ req->varIndex = index++;
+ req->data.pageData[0] = m_page_ptr.i + cnt;
+
+ m_fs.EXECUTE_DIRECT(block, GSN_FSWRITEREQ, signal,
+ FsReadWriteReq::FixedLength + 1);
+
+ cnt++;
+ size += request->par.open.page_size;
+ }
retry:
- Uint32 size = request->par.open.page_size;
+ off_t save_size = size;
char* buf = (char*)m_page_ptr.p;
while(size > 0){
+#ifdef TRACE_INIT
+ write_cnt++;
+#endif
int n;
if(use_gz)
n= azwrite(&azf,buf,size);
@@ -380,8 +401,22 @@ no_odirect:
request->error = err;
return;
}
- off += request->par.open.page_size;
+ off += save_size;
}
+ ::fsync(theFd);
+#ifdef TRACE_INIT
+ Uint64 stop = NdbTick_CurrentMillisecond();
+ Uint64 diff = stop - start;
+ if (diff == 0)
+ diff = 1;
+ ndbout_c("wrote %umb in %u writes %us -> %ukb/write %umb/s",
+ Uint32(sz /1024/1024),
+ write_cnt,
+ Uint32(diff / 1000),
+ Uint32(sz / 1024 / write_cnt),
+ Uint32(sz / diff));
+#endif
+
if(lseek(theFd, 0, SEEK_SET) != 0)
request->error = errno;
}
@@ -399,12 +434,6 @@ no_odirect:
if (request->error)
return;
-#elif defined HAVE_DIRECTIO && defined(DIRECTIO_ON)
- if (directio(theFd, DIRECTIO_ON) == -1)
- {
- ndbout_c("%s Failed to set DIRECTIO_ON errno: %u",
- theFileName.c_str(), errno);
- }
#endif
}
@@ -421,6 +450,7 @@ no_odirect:
#endif
}
#endif
+
if ((flags & FsOpenReq::OM_SYNC) && (flags & FsOpenReq::OM_INIT))
{
#ifdef O_SYNC
@@ -437,6 +467,24 @@ no_odirect:
}
#endif
}
+
+#if ! defined(O_DIRECT) && defined HAVE_DIRECTIO && defined(DIRECTIO_ON)
+ if (flags & FsOpenReq::OM_DIRECT)
+ {
+ if (directio(theFd, DIRECTIO_ON) == -1)
+ {
+ ndbout_c("%s Failed to set DIRECTIO_ON errno: %u",
+ theFileName.c_str(), errno);
+ }
+#ifdef VM_TRACE
+ else
+ {
+ ndbout_c("%s DIRECTIO_ON", theFileName.c_str());
+ }
+#endif
+ }
+#endif
+
if(use_gz)
{
int err;
=== modified file 'storage/ndb/src/kernel/blocks/tsman.cpp'
--- a/storage/ndb/src/kernel/blocks/tsman.cpp 2008-08-08 12:36:04 +0000
+++ b/storage/ndb/src/kernel/blocks/tsman.cpp 2008-11-18 10:21:28 +0000
@@ -786,7 +786,7 @@ Tsman::execFSWRITEREQ(Signal* signal)
FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtr();
m_file_pool.getPtr(ptr, req->userPointer);
- m_global_page_pool.getPtr(page_ptr, req->data.pageData[0]);
+ m_shared_page_pool.getPtr(page_ptr, req->data.pageData[0]);
memset(page_ptr.p, 0, File_formats::NDB_PAGE_SIZE);
Uint32 page_no = req->varIndex;
=== modified file 'storage/ndb/test/include/HugoOperations.hpp'
--- a/storage/ndb/test/include/HugoOperations.hpp 2008-02-19 15:00:29 +0000
+++ b/storage/ndb/test/include/HugoOperations.hpp 2008-11-17 09:26:25 +0000
@@ -51,9 +51,14 @@ public:
int numRecords = 1);
int pkReadRecord(Ndb*,
- int recordNo,
- int numRecords = 1,
- NdbOperation::LockMode lm = NdbOperation::LM_Read);
+ int record,
+ int numRecords = 1,
+ NdbOperation::LockMode lm = NdbOperation::LM_Read);
+
+ int pkReadRandRecord(Ndb*,
+ int records,
+ int numRecords = 1,
+ NdbOperation::LockMode lm = NdbOperation::LM_Read);
int pkUpdateRecord(Ndb*,
int recordNo,
=== modified file 'storage/ndb/test/include/HugoTransactions.hpp'
--- a/storage/ndb/test/include/HugoTransactions.hpp 2007-09-28 12:00:57 +0000
+++ b/storage/ndb/test/include/HugoTransactions.hpp 2008-11-17 09:28:34 +0000
@@ -64,7 +64,8 @@ public:
int pkReadRecords(Ndb*,
int records,
int batchsize = 1,
- NdbOperation::LockMode = NdbOperation::LM_Read);
+ NdbOperation::LockMode = NdbOperation::LM_Read,
+ int rand = 0);
int scanUpdateRecords(Ndb*, NdbScanOperation::ScanFlag,
int records,
=== modified file 'storage/ndb/test/src/HugoOperations.cpp'
--- a/storage/ndb/test/src/HugoOperations.cpp 2008-08-14 12:10:55 +0000
+++ b/storage/ndb/test/src/HugoOperations.cpp 2008-11-17 09:28:34 +0000
@@ -142,6 +142,82 @@ rand_lock_mode:
return NDBT_OK;
}
+int HugoOperations::pkReadRandRecord(Ndb* pNdb,
+ int records,
+ int numRecords,
+ NdbOperation::LockMode lm){
+ int a;
+ allocRows(numRecords);
+ indexScans.clear();
+ int check;
+
+ NdbOperation* pOp = 0;
+ pIndexScanOp = 0;
+
+ for(int r=0; r < numRecords; r++){
+
+ if(pOp == 0)
+ {
+ pOp = getOperation(pTrans, NdbOperation::ReadRequest);
+ }
+ if (pOp == NULL) {
+ ERR(pTrans->getNdbError());
+ return NDBT_FAILED;
+ }
+
+rand_lock_mode:
+ switch(lm){
+ case NdbOperation::LM_Read:
+ case NdbOperation::LM_Exclusive:
+ case NdbOperation::LM_CommittedRead:
+ case NdbOperation::LM_SimpleRead:
+ if(idx && idx->getType() == NdbDictionary::Index::OrderedIndex &&
+ pIndexScanOp == 0)
+ {
+ pIndexScanOp = ((NdbIndexScanOperation*)pOp);
+ check = pIndexScanOp->readTuples(lm);
+ /* Record NdbIndexScanOperation ptr for later... */
+ indexScans.push_back(pIndexScanOp);
+ }
+ else
+ check = pOp->readTuple(lm);
+ break;
+ default:
+ lm = (NdbOperation::LockMode)((rand() >> 16) & 3);
+ goto rand_lock_mode;
+ }
+
+ if( check == -1 ) {
+ ERR(pTrans->getNdbError());
+ return NDBT_FAILED;
+ }
+
+ // Define primary keys
+ if (equalForRow(pOp, rand() % records) != 0)
+ return NDBT_FAILED;
+
+ if(pIndexScanOp)
+ pIndexScanOp->end_of_bound(r);
+
+ if(r == 0 || pIndexScanOp == 0)
+ {
+ // Define attributes to read
+ for(a = 0; a<tab.getNoOfColumns(); a++){
+ if((rows[r]->attributeStore(a) =
+ pOp->getValue(tab.getColumn(a)->getName())) == 0) {
+ ERR(pTrans->getNdbError());
+ return NDBT_FAILED;
+ }
+ }
+ }
+ /* Note pIndexScanOp will point to the 'last' index scan op
+ * we used. The full list is in the indexScans vector
+ */
+ pOp = pIndexScanOp;
+ }
+ return NDBT_OK;
+}
+
int HugoOperations::pkUpdateRecord(Ndb* pNdb,
int recordNo,
int numRecords,
=== modified file 'storage/ndb/test/src/HugoTransactions.cpp'
--- a/storage/ndb/test/src/HugoTransactions.cpp 2008-02-20 11:33:23 +0000
+++ b/storage/ndb/test/src/HugoTransactions.cpp 2008-11-17 09:28:34 +0000
@@ -812,7 +812,8 @@ int
HugoTransactions::pkReadRecords(Ndb* pNdb,
int records,
int batch,
- NdbOperation::LockMode lm){
+ NdbOperation::LockMode lm,
+ int _rand){
int reads = 0;
int r = 0;
int retryAttempt = 0;
@@ -857,11 +858,23 @@ HugoTransactions::pkReadRecords(Ndb* pNd
if (timer_active)
NdbTick_getMicroTimer(&timer_start);
- if(pkReadRecord(pNdb, r, batch, lm) != NDBT_OK)
+ if (_rand == 0)
{
- ERR(pTrans->getNdbError());
- closeTransaction(pNdb);
- return NDBT_FAILED;
+ if(pkReadRecord(pNdb, r, batch, lm) != NDBT_OK)
+ {
+ ERR(pTrans->getNdbError());
+ closeTransaction(pNdb);
+ return NDBT_FAILED;
+ }
+ }
+ else
+ {
+ if(pkReadRandRecord(pNdb, records, batch, lm) != NDBT_OK)
+ {
+ ERR(pTrans->getNdbError());
+ closeTransaction(pNdb);
+ return NDBT_FAILED;
+ }
}
check = pTrans->execute(Commit, AbortOnError);
=== modified file 'storage/ndb/test/src/NDBT_Tables.cpp'
--- a/storage/ndb/test/src/NDBT_Tables.cpp 2008-11-11 11:40:42 +0000
+++ b/storage/ndb/test/src/NDBT_Tables.cpp 2008-11-17 09:26:25 +0000
@@ -882,6 +882,8 @@ NDBT_Tables::create_default_tablespace(N
}
Uint32 mb = 96;
+ Uint32 files = 13;
+
{
char buf[256];
if (NdbEnv_GetEnv("UNDOSIZE", buf, sizeof(buf)))
@@ -891,7 +893,19 @@ NDBT_Tables::create_default_tablespace(N
}
}
+ {
+ char buf[256];
+ if (NdbEnv_GetEnv("UNDOFILES", buf, sizeof(buf)))
+ {
+ files = atoi(buf);
+ ndbout_c("Using max %u dd-undo files", files);
+ }
+ }
+
Uint32 sz = 32;
+ while (mb > files * sz)
+ sz += 32;
+
for (Uint32 i = 0; i * sz < mb; i++)
{
char tmp[256];
@@ -900,7 +914,7 @@ NDBT_Tables::create_default_tablespace(N
if (strcmp(uf.getPath(), tmp) != 0)
{
uf.setPath(tmp);
- uf.setSize(sz*1024*1024);
+ uf.setSize(Uint64(sz)*1024*1024);
uf.setLogfileGroup("DEFAULT-LG");
res = pDict->createUndofile(uf, true);
@@ -926,30 +940,39 @@ NDBT_Tables::create_default_tablespace(N
return NDBT_FAILED;
}
}
+
+ mb = 128;
+ {
+ char buf[256];
+ if (NdbEnv_GetEnv("DATASIZE", buf, sizeof(buf)))
+ {
+ mb = atoi(buf);
+ ndbout_c("Using %umb dd-data", mb);
+ }
+ }
+ sz = 64;
+ files = 13;
{
- NdbDictionary::Datafile df = pDict->getDatafile(0, "datafile01.dat");
- if (strcmp(df.getPath(), "datafile01.dat") != 0)
+ char buf[256];
+ if (NdbEnv_GetEnv("DATAFILES", buf, sizeof(buf)))
{
- df.setPath("datafile01.dat");
- df.setSize(64*1024*1024);
- df.setTablespace("DEFAULT-TS");
-
- res = pDict->createDatafile(df, true);
- if(res != 0){
- g_err << "Failed to create datafile:"
- << endl << pDict->getNdbError() << endl;
- return NDBT_FAILED;
- }
+ files = atoi(buf);
+ ndbout_c("Using max %u dd-data files", files);
}
}
-
+
+ while (mb > files * sz)
+ sz += 32;
+ for (Uint32 i = 0; i * sz < mb; i++)
{
- NdbDictionary::Datafile df = pDict->getDatafile(0, "datafile02.dat");
- if (strcmp(df.getPath(), "datafile02.dat") != 0)
+ char tmp[256];
+ BaseString::snprintf(tmp, sizeof(tmp), "datafile%u.dat", i);
+ NdbDictionary::Datafile df = pDict->getDatafile(0, tmp);
+ if (strcmp(df.getPath(), tmp) != 0)
{
- df.setPath("datafile02.dat");
- df.setSize(64*1024*1024);
+ df.setPath(tmp);
+ df.setSize(Uint64(sz)*1024*1024);
df.setTablespace("DEFAULT-TS");
res = pDict->createDatafile(df, true);
@@ -960,7 +983,7 @@ NDBT_Tables::create_default_tablespace(N
}
}
}
-
+
return NDBT_OK;
}
=== modified file 'storage/ndb/test/tools/hugoPkRead.cpp'
--- a/storage/ndb/test/tools/hugoPkRead.cpp 2007-07-14 08:48:51 +0000
+++ b/storage/ndb/test/tools/hugoPkRead.cpp 2008-11-17 09:26:25 +0000
@@ -34,6 +34,7 @@ struct ThrInput {
int records;
int batch;
int stats;
+ int rand;
};
struct ThrOutput {
@@ -51,7 +52,8 @@ int main(int argc, const char** argv){
int _batch = 1;
const char* _tabname = NULL;
int _help = 0;
-
+ int _rand = 0;
+
struct getargs args[] = {
{ "aborts", 'a', arg_integer, &_abort, "percent of transactions that are aborted", "abort%" },
{ "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
@@ -59,6 +61,7 @@ int main(int argc, const char** argv){
{ "stats", 's', arg_flag, &_stats, "report latency per batch", "stats" },
{ "batch", 'b', arg_integer, &_batch, "batch value(not 0)", "batch" },
{ "records", 'r', arg_integer, &_records, "Number of records", "records" },
+ { "rand", 0, arg_flag, &_rand, "Read random records within range","rand"},
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
@@ -116,6 +119,7 @@ int main(int argc, const char** argv){
input.records = _records;
input.batch = _batch;
input.stats = _stats;
+ input.rand = _rand;
// output is stats
ThrOutput output;
@@ -171,7 +175,9 @@ static void hugoPkRead(NDBT_Thread& thr)
int ret;
ret = hugoTrans.pkReadRecords(thr.get_ndb(),
input->records,
- input->batch);
+ input->batch,
+ NdbOperation::LM_Read,
+ input->rand);
if (ret != 0)
thr.set_err(ret);
}
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (msvensson:2747) | Magnus Svensson | 19 Nov |