#At file:///home/tomas/mysql_src/mysql-5.1-telco-6.2-merge/
2739 Tomas Ulin 2008-11-18 [merge]
merge
modified:
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 '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 11:56:33 +0000
+++ b/storage/ndb/test/include/HugoTransactions.hpp 2008-11-17 09:26:25 +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-02-19 15:00:29 +0000
+++ b/storage/ndb/test/src/HugoOperations.cpp 2008-11-17 09:26:25 +0000
@@ -147,6 +147,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-19 15:00:29 +0000
+++ b/storage/ndb/test/src/HugoTransactions.cpp 2008-11-17 09:26:25 +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 (tomas.ulin:2739) | Tomas Ulin | 19 Nov |