Merge poseidon.mysql.com:/home/tomas/mysql-5.1

into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb


sql/ha_ndbcluster.cc:
  Auto merged
This commit is contained in:
unknown 2007-03-08 08:39:49 +07:00
commit 57097f6956
22 changed files with 192 additions and 43 deletions

View file

@ -506,6 +506,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
share->data_file_type = DYNAMIC_RECORD;
my_afree((gptr) disk_cache);
mi_setup_functions(share);
#ifdef HAVE_MMAP
if (open_flags & HA_OPEN_MMAP)
{
info.s= share;
@ -522,6 +523,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
share->file_write= mi_mmap_pwrite;
}
}
#endif /* HAVE_MMAP */
share->is_log_table= FALSE;
#ifdef THREAD
thr_lock_init(&share->lock);

View file

@ -212,7 +212,8 @@ public:
NullablePrimaryKey = 740,
UnsupportedChange = 741,
BackupInProgress = 762,
IncompatibleVersions = 763
IncompatibleVersions = 763,
SingleUser = 299
};
private:

View file

@ -208,6 +208,7 @@ public:
AllocationError = 4252,
CreateIndexTableFailed = 4253,
DuplicateAttributes = 4258,
SingleUser = 299,
TableIsTemporary = 776,
TableIsNotTemporary = 777,
NoLoggingTemporaryIndex = 778

View file

@ -92,6 +92,7 @@ public:
InvalidPrimaryKeySize = 739,
NullablePrimaryKey = 740,
InvalidCharset = 743,
SingleUser = 299,
InvalidTablespace = 755,
VarsizeBitfieldNotSupported = 757,
NotATablespace = 758,

View file

@ -172,7 +172,8 @@ public:
IndexNotFound = 4243,
BadRequestType = 4247,
InvalidName = 4248,
NotAnIndex = 4254
NotAnIndex = 4254,
SingleUser = 299
};
STATIC_CONST( SignalLength = DropIndxConf::SignalLength + 3 );

View file

@ -58,7 +58,8 @@ public:
InvalidTableVersion = 241,
DropInProgress = 283,
NoDropTableRecordAvailable = 1229,
BackupInProgress = 761
BackupInProgress = 761,
SingleUser = 299
};
};

View file

@ -963,7 +963,7 @@ const EventLoggerBase::EventRepLogLevelMatrix EventLoggerBase::matrix[] = {
ROW(NDBStopCompleted, LogLevel::llStartUp, 1, Logger::LL_INFO ),
ROW(NDBStopForced, LogLevel::llStartUp, 1, Logger::LL_ALERT ),
ROW(NDBStopAborted, LogLevel::llStartUp, 1, Logger::LL_INFO ),
ROW(StartREDOLog, LogLevel::llStartUp, 10, Logger::LL_INFO ),
ROW(StartREDOLog, LogLevel::llStartUp, 4, Logger::LL_INFO ),
ROW(StartLog, LogLevel::llStartUp, 10, Logger::LL_INFO ),
ROW(UNDORecordsExecuted, LogLevel::llStartUp, 15, Logger::LL_INFO ),
ROW(StartReport, LogLevel::llStartUp, 4, Logger::LL_INFO ),

View file

@ -96,6 +96,8 @@ printPACKED_SIGNAL(FILE * output, const Uint32 * theData, Uint32 len, Uint16 rec
}
default:
fprintf(output, "Unknown signal type\n");
i = len; // terminate printing
break;
}
}//for
fprintf(output, "--------- End Packed Signals ----------\n");

View file

@ -3758,6 +3758,15 @@ Dbdict::execCREATE_TABLE_REQ(Signal* signal){
break;
}
if(getNodeState().getSingleUserMode() &&
(refToNode(signal->getSendersBlockRef()) !=
getNodeState().getSingleUserApi()))
{
jam();
parseRecord.errorCode = CreateTableRef::SingleUser;
break;
}
CreateTableRecordPtr createTabPtr;
c_opCreateTable.seize(createTabPtr);
@ -3950,6 +3959,15 @@ Dbdict::execALTER_TABLE_REQ(Signal* signal)
return;
}
if(getNodeState().getSingleUserMode() &&
(refToNode(signal->getSendersBlockRef()) !=
getNodeState().getSingleUserApi()))
{
jam();
alterTableRef(signal, req, AlterTableRef::SingleUser);
return;
}
const TableRecord::TabState tabState = tablePtr.p->tabState;
bool ok = false;
switch(tabState){
@ -6542,6 +6560,15 @@ Dbdict::execDROP_TABLE_REQ(Signal* signal){
return;
}
if(getNodeState().getSingleUserMode() &&
(refToNode(signal->getSendersBlockRef()) !=
getNodeState().getSingleUserApi()))
{
jam();
dropTableRef(signal, req, DropTableRef::SingleUser);
return;
}
const TableRecord::TabState tabState = tablePtr.p->tabState;
bool ok = false;
switch(tabState){
@ -7749,6 +7776,13 @@ Dbdict::execCREATE_INDX_REQ(Signal* signal)
jam();
tmperr = CreateIndxRef::Busy;
}
else if(getNodeState().getSingleUserMode() &&
(refToNode(senderRef) !=
getNodeState().getSingleUserApi()))
{
jam();
tmperr = CreateIndxRef::SingleUser;
}
if (tmperr != CreateIndxRef::NoError) {
releaseSections(signal);
OpCreateIndex opBusy;
@ -8392,6 +8426,13 @@ Dbdict::execDROP_INDX_REQ(Signal* signal)
jam();
tmperr = DropIndxRef::Busy;
}
else if(getNodeState().getSingleUserMode() &&
(refToNode(senderRef) !=
getNodeState().getSingleUserApi()))
{
jam();
tmperr = DropIndxRef::SingleUser;
}
if (tmperr != DropIndxRef::NoError) {
err = tmperr;
goto error;

View file

@ -2098,8 +2098,11 @@ void Dbdih::gcpBlockedLab(Signal* signal)
/*-------------------------------------------------------------------------*/
Uint32 startVersion = getNodeInfo(c_nodeStartMaster.startNode).m_version;
if ((getMajor(startVersion) == 4 && startVersion >= NDBD_INCL_NODECONF_VERSION_4) ||
(getMajor(startVersion) == 5 && startVersion >= NDBD_INCL_NODECONF_VERSION_5))
if ((getMajor(startVersion) == 4 &&
startVersion >= NDBD_INCL_NODECONF_VERSION_4) ||
(getMajor(startVersion) == 5 &&
startVersion >= NDBD_INCL_NODECONF_VERSION_5) ||
(getMajor(startVersion) > 5))
{
c_INCL_NODEREQ_Counter.setWaitingFor(c_nodeStartMaster.startNode);
}
@ -2342,8 +2345,11 @@ void Dbdih::execINCL_NODEREQ(Signal* signal)
CRASH_INSERTION(7171);
Uint32 masterVersion = getNodeInfo(refToNode(cmasterdihref)).m_version;
if ((NDB_VERSION_MAJOR == 4 && masterVersion >= NDBD_INCL_NODECONF_VERSION_4) ||
(NDB_VERSION_MAJOR == 5 && masterVersion >= NDBD_INCL_NODECONF_VERSION_5))
if ((NDB_VERSION_MAJOR == 4 &&
masterVersion >= NDBD_INCL_NODECONF_VERSION_4) ||
(NDB_VERSION_MAJOR == 5 &&
masterVersion >= NDBD_INCL_NODECONF_VERSION_5) ||
(NDB_VERSION_MAJOR > 5))
{
signal->theData[0] = getOwnNodeId();
signal->theData[1] = getOwnNodeId();
@ -14230,7 +14236,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal)
}
if(arg == DumpStateOrd::EnableUndoDelayDataWrite){
g_eventLogger.info("Dbdih:: delay write of datapages for table = %s",
g_eventLogger.info("Dbdih:: delay write of datapages for table = %d",
dumpState->args[1]);
// Send this dump to ACC and TUP
EXECUTE_DIRECT(DBACC, GSN_DUMP_STATE_ORD, signal, 2);

View file

@ -441,6 +441,7 @@ void Dblqh::execCONTINUEB(Signal* signal)
else
{
jam();
cstartRecReq = 2;
ndbrequire(c_redo_complete_fragments.isEmpty());
StartRecConf * conf = (StartRecConf*)signal->getDataPtrSend();
conf->startingNodeId = getOwnNodeId();
@ -11936,7 +11937,7 @@ void Dblqh::execGCP_SAVEREQ(Signal* signal)
return;
}
if (getNodeState().getNodeRestartInProgress() && cstartRecReq == ZFALSE)
if (getNodeState().getNodeRestartInProgress() && cstartRecReq < 2)
{
GCPSaveRef * const saveRef = (GCPSaveRef*)&signal->theData[0];
saveRef->dihPtr = dihPtr;
@ -12248,6 +12249,10 @@ void Dblqh::execFSCLOSECONF(Signal* signal)
// Set the prev file to check if we shall close it.
logFilePtr.i = logFilePtr.p->prevLogFile;
ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
logPartPtr.i = logFilePtr.p->logPartRec;
ptrCheckGuard(logPartPtr, clogPartFileSize, logPartRecord);
exitFromInvalidate(signal);
return;
case LogFileRecord::CLOSING_INIT:
@ -14017,7 +14022,7 @@ void Dblqh::execRESTORE_LCP_CONF(Signal* signal)
return;
}
if (c_lcp_restoring_fragments.isEmpty() && cstartRecReq == ZTRUE)
if (c_lcp_restoring_fragments.isEmpty() && cstartRecReq == 1)
{
jam();
/* ----------------------------------------------------------------
@ -14058,7 +14063,7 @@ void Dblqh::execSTART_RECREQ(Signal* signal)
ndbrequire(req->receivingNodeId == cownNodeid);
cnewestCompletedGci = cnewestGci;
cstartRecReq = ZTRUE;
cstartRecReq = 1;
for (logPartPtr.i = 0; logPartPtr.i < 4; logPartPtr.i++) {
ptrAss(logPartPtr, logPartRecord);
logPartPtr.p->logPartNewestCompletedGCI = cnewestCompletedGci;
@ -14072,6 +14077,7 @@ void Dblqh::execSTART_RECREQ(Signal* signal)
*------------------------------------------------------------------------ */
if(cstartType == NodeState::ST_INITIAL_NODE_RESTART){
jam();
cstartRecReq = 2;
StartRecConf * conf = (StartRecConf*)signal->getDataPtrSend();
conf->startingNodeId = getOwnNodeId();
sendSignal(cmasterDihBlockref, GSN_START_RECCONF, signal,
@ -15893,6 +15899,7 @@ void Dblqh::srFourthComp(Signal* signal)
return;
}
}
cstartRecReq = 2;
StartRecConf * conf = (StartRecConf*)signal->getDataPtrSend();
conf->startingNodeId = getOwnNodeId();
sendSignal(cmasterDihBlockref, GSN_START_RECCONF, signal,
@ -16761,7 +16768,7 @@ void Dblqh::initialiseRecordsLab(Signal* signal, Uint32 data,
cnoActiveCopy = 0;
ccurrentGcprec = RNIL;
caddNodeState = ZFALSE;
cstartRecReq = ZFALSE;
cstartRecReq = 0;
cnewestGci = 0;
cnewestCompletedGci = 0;
crestartOldestGci = 0;

View file

@ -1840,6 +1840,7 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal)
ndbrequire(m_file_hash.find(file_ptr, file_key));
struct req val = lookup_extent(req.key.m_page_no, file_ptr.p);
Uint32 page_no_in_extent = calc_page_no_in_extent(req.key.m_page_no, &val);
Page_cache_client::Request preq;
preq.m_page.m_page_no = val.m_extent_page_no;
@ -1865,7 +1866,6 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal)
ndbrequire(header->m_table == req.request.table_id);
Uint32 page_no_in_extent = calc_page_no_in_extent(req.key.m_page_no, &val);
Uint32 word = header->get_free_word_offset(page_no_in_extent);
Uint32 shift = SZ * (page_no_in_extent & 7);
@ -1925,8 +1925,7 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal)
found:
header->update_free_bits(page_no, src_bits | UNCOMMITTED_MASK);
rep->bits= (src_bits & UNCOMMITTED_MASK) >> UNCOMMITTED_SHIFT;
rep->key.m_page_no=
val.m_extent_pages + val.m_extent_no * val.m_extent_size + page_no;
rep->key.m_page_no = req.key.m_page_no + page_no - page_no_in_extent;
rep->reply.errorCode= 0;
return;
}

View file

@ -22,7 +22,7 @@
RWPool::RWPool()
{
bzero(this, sizeof(* this));
m_current_pos = GLOBAL_PAGE_SIZE_WORDS;
m_current_pos = RWPage::RWPAGE_WORDS;
m_current_first_free = REC_NIL;
m_first_free_page = RNIL;
}
@ -57,7 +57,7 @@ seize_free:
m_current_first_free = pageP->m_data[pos+m_record_info.m_offset_next_pool];
return true;
}
else if (pos + size < GLOBAL_PAGE_SIZE_WORDS)
else if (pos + size < RWPage::RWPAGE_WORDS)
{
seize_first:
ptr.i = (m_current_page_no << POOL_RECORD_BITS) + pos;
@ -81,11 +81,14 @@ seize_first:
{
pageP = m_current_page = m_memroot + m_first_free_page;
m_current_page_no = m_first_free_page;
m_current_pos = GLOBAL_PAGE_SIZE_WORDS;
m_current_pos = RWPage::RWPAGE_WORDS;
m_current_first_free = m_current_page->m_first_free;
m_first_free_page = m_current_page->m_next_page;
m_current_ref_count = m_current_page->m_ref_count;
(m_memroot + m_first_free_page)->m_prev_page = RNIL;
if (m_first_free_page != RNIL)
{
(m_memroot + m_first_free_page)->m_prev_page = RNIL;
}
goto seize_free;
}
@ -105,7 +108,7 @@ seize_first:
m_current_page = 0;
m_current_page_no = RNIL;
m_current_pos = GLOBAL_PAGE_SIZE_WORDS;
m_current_pos = RWPage::RWPAGE_WORDS;
m_current_first_free = REC_NIL;
return false;
@ -154,6 +157,7 @@ RWPool::release(Ptr<void> ptr)
}
page->m_next_page = ffp;
page->m_prev_page = RNIL;
m_first_free_page = ptr_page;
return;
}
else if(ref_cnt == 1)

View file

@ -20,12 +20,14 @@
struct RWPage
{
STATIC_CONST( RWPAGE_WORDS = GLOBAL_PAGE_SIZE_WORDS - 4 );
Uint32 m_type_id;
Uint16 m_first_free;
Uint16 m_ref_count;
Uint32 m_next_page;
Uint32 m_prev_page;
Uint32 m_data[GLOBAL_PAGE_SIZE_WORDS - 4];
Uint32 m_data[RWPAGE_WORDS];
};
/**

View file

@ -20,7 +20,7 @@
WOPool::WOPool()
{
bzero(this, sizeof(* this));
m_current_pos = GLOBAL_PAGE_SIZE_WORDS;
m_current_pos = WOPage::WOPAGE_WORDS;
}
void

View file

@ -20,9 +20,11 @@
struct WOPage
{
STATIC_CONST( WOPAGE_WORDS = GLOBAL_PAGE_SIZE_WORDS - 2 );
Uint32 m_type_id;
Uint32 m_ref_count;
Uint32 m_data[GLOBAL_PAGE_SIZE_WORDS - 2];
Uint32 m_data[WOPAGE_WORDS];
};
/**
@ -61,7 +63,7 @@ WOPool::seize(Ptr<void>& ptr)
Uint32 pos = m_current_pos;
Uint32 size = m_record_info.m_size;
WOPage *pageP = m_current_page;
if (likely(pos + size < GLOBAL_PAGE_SIZE_WORDS))
if (likely(pos + size < WOPage::WOPAGE_WORDS))
{
ptr.i = (m_current_page_no << POOL_RECORD_BITS) + pos;
ptr.p = (pageP->m_data + pos);

View file

@ -343,24 +343,24 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
}
break;
case NdbDictionary::Column::Blob:
{
const NdbBlob::Head* h = (const NdbBlob::Head*)r.aRef();
out << h->length << ":";
const unsigned char* p = (const unsigned char*)(h + 1);
unsigned n = r.get_size_in_bytes() - sizeof(*h);
for (unsigned k = 0; k < n && k < h->length; k++)
out.print("%02X", (int)p[k]);
j = length;
}
break;
case NdbDictionary::Column::Text:
{
const NdbBlob::Head* h = (const NdbBlob::Head*)r.aRef();
out << h->length << ":";
const unsigned char* p = (const unsigned char*)(h + 1);
unsigned n = r.get_size_in_bytes() - sizeof(*h);
for (unsigned k = 0; k < n && k < h->length; k++)
out.print("%c", (int)p[k]);
// user defined aRef() may not be aligned to Uint64
NdbBlob::Head head;
memcpy(&head, r.aRef(), sizeof(head));
out << head.length << ":";
const unsigned char* p = (const unsigned char*)r.aRef() + sizeof(head);
if (r.get_size_in_bytes() < sizeof(head))
out << "***error***"; // really cannot happen
else {
unsigned n = r.get_size_in_bytes() - sizeof(head);
for (unsigned k = 0; k < n && k < head.length; k++) {
if (r.getType() == NdbDictionary::Column::Blob)
out.print("%02X", (int)p[k]);
else
out.print("%c", (int)p[k]);
}
}
j = length;
}
break;

View file

@ -283,6 +283,7 @@ ErrorBundle ErrorCodes[] = {
/**
* Application error
*/
{ 299, DMEC, AE, "Operation not allowed or aborted due to single user mode" },
{ 763, DMEC, AE, "Alter table requires cluster nodes to have exact same version" },
{ 823, DMEC, AE, "Too much attrinfo from application in tuple manager" },
{ 831, DMEC, AE, "Too many nullable/bitfields in table definition" },

View file

@ -1353,6 +1353,68 @@ runBug26481(NDBT_Context* ctx, NDBT_Step* step)
return NDBT_OK;
}
int
runBug26450(NDBT_Context* ctx, NDBT_Step* step)
{
Uint32 i;
int result = NDBT_OK;
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
NdbRestarter res;
Ndb* pNdb = GETNDB(step);
int node = res.getRandomNotMasterNodeId(rand());
Vector<int> nodes;
for (unsigned i = 0; i<res.getNumDbNodes(); i++)
{
if (res.getDbNodeId(i) != node)
nodes.push_back(res.getDbNodeId(i));
}
if (res.restartAll())
return NDBT_FAILED;
if (res.waitClusterStarted())
return NDBT_FAILED;
ndbout_c("node: %d", node);
if (res.restartOneDbNode(node, false, true, true))
return NDBT_FAILED;
if (res.waitNodesNoStart(&node, 1))
return NDBT_FAILED;
if (runClearTable(ctx, step))
return NDBT_FAILED;
for (i = 0; i < 2; i++)
{
if (res.restartAll(false, true, i > 0))
return NDBT_FAILED;
if (res.waitClusterNoStart())
return NDBT_FAILED;
if (res.startNodes(nodes.getBase(), nodes.size()))
return NDBT_FAILED;
if (res.waitNodesStarted(nodes.getBase(), nodes.size()))
return NDBT_FAILED;
}
if (res.startNodes(&node, 1))
return NDBT_FAILED;
if (res.waitNodesStarted(&node, 1))
return NDBT_FAILED;
HugoTransactions trans (* ctx->getTab());
if (trans.selectCount(pNdb) != 0)
return NDBT_FAILED;
return NDBT_OK;
}
NDBT_TESTSUITE(testNodeRestart);
TESTCASE("NoLoad",
"Test that one node at a time can be stopped and then restarted "\
@ -1697,6 +1759,10 @@ TESTCASE("Bug26457", ""){
TESTCASE("Bug26481", ""){
INITIALIZER(runBug26481);
}
TESTCASE("Bug26450", ""){
INITIALIZER(runLoadTable);
INITIALIZER(runBug26450);
}
NDBT_TESTSUITE_END(testNodeRestart);
int main(int argc, const char** argv){

View file

@ -59,7 +59,12 @@ BackupFile::Twiddle(const AttributeDesc* attr_desc, AttributeData* attr_data, Ui
return true;
case 64:
for(i = 0; i<arraySize; i++){
attr_data->u_int64_value[i] = Twiddle64(attr_data->u_int64_value[i]);
// allow unaligned
char* p = (char*)&attr_data->u_int64_value[i];
Uint64 x;
memcpy(&x, p, sizeof(Uint64));
x = Twiddle64(x);
memcpy(p, &x, sizeof(Uint64));
}
return true;
default:

View file

@ -669,6 +669,8 @@ err:
bool
BackupRestore::createSystable(const TableS & tables){
if (!m_restore && !m_restore_meta && !m_restore_epoch)
return true;
const char *tablename = tables.getTableName();
if( strcmp(tablename, NDB_REP_DB "/def/" NDB_APPLY_TABLE) != 0 &&

View file

@ -18,13 +18,18 @@
#include <tap.h>
#include <string.h>
#define BASE64_LOOP_COUNT 500
#define BASE64_ROWS 4 /* Number of ok(..) */
int
main(void)
{
int i, cmp;
size_t j, k, l, dst_len, needed_length;
for (i= 0; i < 500; i++)
plan(BASE64_LOOP_COUNT * BASE64_ROWS);
for (i= 0; i < BASE64_LOOP_COUNT; i++)
{
/* Create source data */
const size_t src_len= rand() % 1000 + 1;