#At file:///export/space/pekka/ms/ms-telco-70/ based on revid:jonas@stripped
4327 Pekka Nousiainen 2011-04-20 [merge]
merge from wl4163
modified:
storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp
storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp
storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp
storage/ndb/test/ndbapi/testDict.cpp
storage/ndb/test/run-test/daily-basic-tests.txt
storage/ndb/test/src/HugoCalculator.cpp
=== modified file 'storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp 2011-04-19 09:01:07 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp 2011-04-20 07:07:02 +0000
@@ -2934,7 +2934,7 @@ private:
void removeTdArea(Uint32 tabDesRef, Uint32 list);
void insertTdArea(Uint32 tabDesRef, Uint32 list);
void itdaMergeTabDescr(Uint32& retRef, Uint32& retNo, bool normal);
-#ifdef VM_TRACE
+#if defined VM_TRACE || defined ERROR_INSERT
void verifytabdes();
#endif
=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp 2011-04-07 07:22:49 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp 2011-04-18 15:36:25 +0000
@@ -1809,7 +1809,7 @@ Dbtup::execDROP_TAB_REQ(Signal* signal)
{
jamEntry();
if (ERROR_INSERTED(4013)) {
-#ifdef VM_TRACE
+#if defined VM_TRACE || defined ERROR_INSERT
verifytabdes();
#endif
}
@@ -2565,7 +2565,7 @@ Dbtup::execDROP_FRAG_REQ(Signal* signal)
{
jamEntry();
if (ERROR_INSERTED(4013)) {
-#ifdef VM_TRACE
+#if defined VM_TRACE || defined ERROR_INSERT
verifytabdes();
#endif
}
=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp 2011-02-07 13:21:49 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupTabDesMan.cpp 2011-04-19 15:59:06 +0000
@@ -28,6 +28,9 @@
* TABLE DESCRIPTOR MEMORY MANAGER
*
* Each table has a descriptor which is a contiguous array of words.
+ * Newer NDB versions also have additional "dynamic descriptors"
+ * which are allocated separately using the same method.
+ *
* The descriptor is allocated from a global array using a buddy
* algorithm. Free lists exist for each power of 2 words. Freeing
* a piece first merges with free right and left neighbours and then
@@ -257,14 +260,15 @@ void Dbtup::removeTdArea(Uint32 tabDesRe
}//if
}//Dbtup::removeTdArea()
-#ifdef VM_TRACE
+#if defined VM_TRACE || defined ERROR_INSERT
void
Dbtup::verifytabdes()
{
struct WordType {
short fl; // free list 0-15
short ti; // table id
- WordType() : fl(-1), ti(-1) {}
+ short td; // table descriptor area 0 or >0 for dynamic
+ WordType() : fl(-1), ti(-1), td(-1) {}
};
WordType* wt = new WordType [cnoOfTabDescrRec];
uint free_words = 0;
@@ -339,14 +343,16 @@ Dbtup::verifytabdes()
for (uint j = 0; j < size; j++) {
ndbrequire(wt[desc + j].ti == -1);
wt[desc + j].ti = i;
+ wt[desc + j].td = 0;
}
used_words += size;
}
+ for (uint k = 0; k < NO_DYNAMICS; k++)
{
Uint32 offset[3];
- Uint32 MaskSize = (ptr.p->m_dyn_null_bits[MM] + 31) >> 5;
+ Uint32 MaskSize = (ptr.p->m_dyn_null_bits[k] + 31) >> 5;
const Uint32 alloc = getDynTabDescrOffsets(MaskSize, offset);
- const Uint32 desc = ptr.p->dynTabDescriptor[MM];
+ const Uint32 desc = ptr.p->dynTabDescriptor[k];
Uint32 size = alloc;
if (size % ZTD_FREE_SIZE != 0)
size += ZTD_FREE_SIZE - size % ZTD_FREE_SIZE;
@@ -366,6 +372,7 @@ Dbtup::verifytabdes()
for (uint j = 0; j < size; j++) {
ndbrequire(wt[desc + j].ti == -1);
wt[desc + j].ti = i;
+ wt[desc + j].td = 1 + k;
}
used_words += size;
}
=== modified file 'storage/ndb/test/ndbapi/testDict.cpp'
--- a/storage/ndb/test/ndbapi/testDict.cpp 2011-04-07 07:22:49 +0000
+++ b/storage/ndb/test/ndbapi/testDict.cpp 2011-04-18 11:09:11 +0000
@@ -31,6 +31,7 @@
#include <NdbSqlUtil.hpp>
#include <NdbEnv.h>
#include <ndb_rand.h>
+#include <Bitmask.hpp>
#define ERR_INSERT_MASTER_FAILURE1 6013
#define ERR_INSERT_MASTER_FAILURE2 6014
@@ -294,31 +295,45 @@ int runCreateAndDropAtRandom(NDBT_Contex
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
int loops = ctx->getNumLoops();
- int numTables = NDBT_Tables::getNumTables();
- bool* tabList = new bool [ numTables ];
- int tabCount;
+ int records = ctx->getNumRecords();
- {
- for (int num = 0; num < numTables; num++) {
- (void)pDic->dropTable(NDBT_Tables::getTable(num)->getName());
- tabList[num] = false;
- }
- tabCount = 0;
+ int numAllTables = NDBT_Tables::getNumTables();
+ struct TabList {
+ int exists; // -1 = skip, 0 = no, 1 = yes
+ const NdbDictionary::Table* pTab; // retrieved
+ TabList() { exists = -1; pTab = 0; }
+ };
+ TabList* tabList = new TabList [ numAllTables ];
+ int numTables = 0;
+ int num;
+ for (num = 0; num < numAllTables; num++) {
+ const NdbDictionary::Table* pTab = NDBT_Tables::getTable(num);
+ if (pTab->checkColumns(0, 0) & 2) // skip disk
+ continue;
+ tabList[num].exists = 0;
+ (void)pDic->dropTable(pTab->getName());
+ numTables++;
}
+ int numExists = 0;
+
+ const bool createIndexes = ctx->getProperty("CreateIndexes");
+ const bool loadData = ctx->getProperty("LoadData");
NdbRestarter restarter;
int result = NDBT_OK;
int bias = 1; // 0-less 1-more
int i = 0;
- while (i < loops) {
- g_info << "loop " << i << " tabs " << tabCount << "/" << numTables << endl;
- int num = myRandom48(numTables);
+ while (i < loops && result == NDBT_OK) {
+ num = myRandom48(numAllTables);
+ if (tabList[num].exists == -1)
+ continue;
+ g_info << "loop " << i << " tabs " << numExists << "/" << numTables << endl;
const NdbDictionary::Table* pTab = NDBT_Tables::getTable(num);
char tabName[200];
strcpy(tabName, pTab->getName());
- if (tabList[num] == false) {
+ if (tabList[num].exists == 0) {
if (bias == 0 && myRandom48(100) < 80)
continue;
g_info << tabName << ": create" << endl;
@@ -331,17 +346,110 @@ int runCreateAndDropAtRandom(NDBT_Contex
const NdbDictionary::Table* pTab2 = pDic->getTable(tabName);
if (pTab2 == NULL) {
const NdbError err = pDic->getNdbError();
- g_err << tabName << ": verify create: " << err << endl;
+ g_err << tabName << ": verify create failed: " << err << endl;
result = NDBT_FAILED;
break;
}
- tabList[num] = true;
- assert(tabCount < numTables);
- tabCount++;
- if (tabCount == numTables)
+ tabList[num].pTab = pTab2;
+ if (loadData) {
+ g_info << tabName << ": load data" << endl;
+ HugoTransactions hugoTrans(*pTab2);
+ if (hugoTrans.loadTable(pNdb, records) != 0) {
+ g_err << tabName << ": loadTable failed" << endl;
+ result = NDBT_FAILED;
+ break;
+ }
+ }
+ if (createIndexes) {
+ int icount = myRandom48(10);
+ int inum;
+ for (inum = 0; inum < icount; inum++) {
+ const int tcols = pTab2->getNoOfColumns();
+ assert(tcols != 0);
+ int icols = 1 + myRandom48(tcols);
+ if (icols > NDB_MAX_ATTRIBUTES_IN_INDEX)
+ icols = NDB_MAX_ATTRIBUTES_IN_INDEX;
+ char indName[200];
+ sprintf(indName, "%s_X%d", tabName, inum);
+ NdbDictionary::Index ind(indName);
+ ind.setTable(tabName);
+ ind.setType(NdbDictionary::Index::OrderedIndex);
+ ind.setLogging(false);
+ Bitmask<MAX_ATTRIBUTES_IN_TABLE> mask;
+ char ilist[200];
+ ilist[0] = 0;
+ int ic;
+ for (ic = 0; ic < icols; ic++) {
+ int tc = myRandom48(tcols);
+ const NdbDictionary::Column* c = pTab2->getColumn(tc);
+ assert(c != 0);
+ if (mask.get(tc) ||
+ c->getType() == NdbDictionary::Column::Blob ||
+ c->getType() == NdbDictionary::Column::Text ||
+ c->getType() == NdbDictionary::Column::Bit ||
+ c->getStorageType() == NdbDictionary::Column::StorageTypeDisk)
+ continue;
+ ind.addColumn(*c);
+ mask.set(tc);
+ sprintf(ilist + strlen(ilist), " %d", tc);
+ }
+ if (mask.isclear())
+ continue;
+ g_info << indName << ": columns:" << ilist << endl;
+ if (pDic->createIndex(ind) == 0) {
+ g_info << indName << ": created" << endl;
+ } else {
+ const NdbError err = pDic->getNdbError();
+ g_err << indName << ": create index failed: " << err << endl;
+ if (err.code != 826 && // Too many tables and attributes..
+ err.code != 903 && // Too many ordered indexes..
+ err.code != 904 && // Out of fragment records..
+ err.code != 905 && // Out of attribute records..
+ err.code != 707 && // No more table metadata records..
+ err.code != 708) // No more attribute metadata records..
+ {
+ result = NDBT_FAILED;
+ break;
+ }
+ }
+ }
+ }
+ if (loadData) {
+ // first update a random table to flush global variables
+ int num3 = 0;
+ while (1) {
+ num3 = myRandom48(numAllTables);
+ if (num == num3 || tabList[num3].exists == 1)
+ break;
+ }
+ const NdbDictionary::Table* pTab3 = tabList[num3].pTab;
+ assert(pTab3 != 0);
+ char tabName3[200];
+ strcpy(tabName3, pTab3->getName());
+ HugoTransactions hugoTrans(*pTab3);
+ g_info << tabName3 << ": update data" << endl;
+ if (hugoTrans.pkUpdateRecords(pNdb, records) != 0) {
+ g_err << tabName3 << ": pkUpdateRecords failed" << endl;
+ result = NDBT_FAILED;
+ break;
+ }
+ }
+ if (loadData) {
+ HugoTransactions hugoTrans(*pTab2);
+ g_info << tabName << ": update data" << endl;
+ if (hugoTrans.pkUpdateRecords(pNdb, records) != 0) {
+ g_err << "pkUpdateRecords failed" << endl;
+ result = NDBT_FAILED;
+ break;
+ }
+ }
+ tabList[num].exists = 1;
+ assert(numExists < numTables);
+ numExists++;
+ if (numExists == numTables)
bias = 0;
}
- else {
+ else if (tabList[num].exists == 1) {
if (bias == 1 && myRandom48(100) < 80)
continue;
g_info << tabName << ": drop" << endl;
@@ -369,19 +477,19 @@ int runCreateAndDropAtRandom(NDBT_Contex
result = NDBT_FAILED;
break;
}
- tabList[num] = false;
- assert(tabCount > 0);
- tabCount--;
- if (tabCount == 0)
+ tabList[num].exists = 0;
+ assert(numExists > 0);
+ numExists--;
+ if (numExists == 0)
bias = 1;
}
i++;
}
-
- for (Uint32 i = 0; i<(Uint32)numTables; i++)
- if (tabList[i])
- pDic->dropTable(NDBT_Tables::getTable(i)->getName());
-
+
+ for (num = 0; num < numAllTables; num++)
+ if (tabList[num].exists == 0)
+ pDic->dropTable(NDBT_Tables::getTable(num)->getName());
+
delete [] tabList;
return result;
}
@@ -8737,6 +8845,13 @@ TESTCASE("CreateAndDropAtRandom",
"Uses error insert 4013 to make TUP verify table descriptor"){
INITIALIZER(runCreateAndDropAtRandom);
}
+TESTCASE("CreateAndDropIndexes",
+ "Like CreateAndDropAtRandom but also creates random ordered\n"
+ "indexes and loads data as a simple check of index operation"){
+ TC_PROPERTY("CreateIndexes", 1);
+ TC_PROPERTY("LoadData", 1);
+ INITIALIZER(runCreateAndDropAtRandom);
+}
TESTCASE("CreateAndDropWithData",
"Try to create and drop the table when it's filled with data\n"
"do this loop number of times\n"){
=== modified file 'storage/ndb/test/run-test/daily-basic-tests.txt'
--- a/storage/ndb/test/run-test/daily-basic-tests.txt 2011-04-14 16:29:07 +0000
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt 2011-04-18 12:48:10 +0000
@@ -715,6 +715,10 @@ args: -n CreateAndDropAtRandom -l 200 T1
max-time: 1500
cmd: testDict
+args: -n CreateAndDropIndexes -l 200 T1
+
+max-time: 1500
+cmd: testDict
args: -n CreateAndDropWithData
max-time: 1500
=== modified file 'storage/ndb/test/src/HugoCalculator.cpp'
--- a/storage/ndb/test/src/HugoCalculator.cpp 2011-04-01 14:34:28 +0000
+++ b/storage/ndb/test/src/HugoCalculator.cpp 2011-04-18 11:09:11 +0000
@@ -196,8 +196,6 @@ HugoCalculator::calcValue(int record,
case NdbDictionary::Column::Unsigned:
case NdbDictionary::Column::Bigint:
case NdbDictionary::Column::Bigunsigned:
- case NdbDictionary::Column::Float:
- case NdbDictionary::Column::Double:
case NdbDictionary::Column::Olddecimal:
case NdbDictionary::Column::Olddecimalunsigned:
case NdbDictionary::Column::Decimal:
@@ -227,6 +225,22 @@ HugoCalculator::calcValue(int record,
memcpy(((Uint32*)buf)+tmp, ©, 4);
}
break;
+ case NdbDictionary::Column::Float:
+ {
+ float x = (float)myRand(&seed);
+ memcpy(buf+pos, &x, 4);
+ pos += 4;
+ len -= 4;
+ }
+ break;
+ case NdbDictionary::Column::Double:
+ {
+ double x = (double)myRand(&seed);
+ memcpy(buf+pos, &x, 8);
+ pos += 8;
+ len -= 8;
+ }
+ break;
case NdbDictionary::Column::Varbinary:
case NdbDictionary::Column::Varchar:
len = calc_len(myRand(&seed), len - 1);
No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0 branch (pekka:4327) | Pekka Nousiainen | 20 Apr |