Below is the list of changes that have just been committed into a local
5.1 repository of pekka. When pekka does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-05-20 16:50:50+02:00, pekka@stripped +7 -0
ndb - wl#3600 simplify iteration and keep more state
storage/ndb/include/kernel/signaldata/SchemaTransImpl.hpp@stripped, 2007-05-20 16:50:13+02:00, pekka@stripped +45 -43
wl#3600 simplify iteration and keep more state
storage/ndb/src/common/debugger/signaldata/SchemaTransImpl.cpp@stripped, 2007-05-20 16:50:13+02:00, pekka@stripped +8 -31
wl#3600 simplify iteration and keep more state
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp@stripped, 2007-05-20 16:50:14+02:00, pekka@stripped +585 -650
wl#3600 simplify iteration and keep more state
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp@stripped, 2007-05-20 16:50:14+02:00, pekka@stripped +190 -141
wl#3600 simplify iteration and keep more state
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp@stripped, 2007-05-20 16:50:14+02:00, pekka@stripped +2 -2
wl#3600 simplify iteration and keep more state
storage/ndb/test/ndbapi/testDict.cpp@stripped, 2007-05-20 16:50:14+02:00, pekka@stripped +333 -49
wl#3600 simplify iteration and keep more state
storage/ndb/test/tools/create_index.cpp@stripped, 2007-05-20 16:50:14+02:00, pekka@stripped +3 -3
wl#3600 simplify iteration and keep more state
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: pekka
# Host: clam.(none)
# Root: /export/space/pekka/ndb/version/my52-wl3600-a
--- 1.172/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2007-05-01 12:36:25 +02:00
+++ 1.173/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2007-05-20 16:50:14 +02:00
@@ -2184,9 +2184,8 @@
c_opSectionPool.setSize(2048); // in 60-word units
c_schemaOpPool.setSize(256);
c_schemaOpHash.setSize(256);
- c_schemaTransPool.setSize(2);
+ c_schemaTransPool.setSize(1);
c_schemaTransHash.setSize(2);
- c_phaseIteratorPool.setSize(2);
c_txHandlePool.setSize(2);
c_txHandleHash.setSize(2);
@@ -3647,8 +3646,8 @@
if (hasError(op_ptr.p->m_error))
{
char buf[100];
- BaseString::snprintf(buf, sizeof(buf), "Failed to create table %u during"
- " restart, error: %u line: %u",
+ BaseString::snprintf(buf, sizeof(buf), "Failed to create table %u"
+ " during restart, error: %u line: %u",
createTabPtr.p->m_request.tableId,
op_ptr.p->m_error.errorCode,
op_ptr.p->m_error.errorLine);
@@ -8886,9 +8885,6 @@
getOpData(op_ptr, createIndexPtr);
const CreateIndxImplReq* impl_req = &createIndexPtr.p->m_request;
- TableRecordPtr indexPtr;
- c_tableRecordPool.getPtr(indexPtr, createIndexPtr.p->m_request.indexId);
-
if (!hasError(error)) {
CreateIndxConf* conf = (CreateIndxConf*)signal->getDataPtrSend();
conf->senderRef = reference();
@@ -17683,32 +17679,18 @@
void
Dbdict::addSchemaOp(SchemaTransPtr trans_ptr, SchemaOpPtr& op_ptr)
{
-#ifdef VM_TRACE
- {
- OpIterator loop_it(trans_ptr.p->m_opList);
- itFirst(loop_it);
- while (itExists(loop_it)) {
- jam();
- SchemaOpPtr loop_ptr = itGetPtr(loop_it);
- ndbrequire(loop_ptr.i != op_ptr.i);
- ndbrequire(loop_ptr.p->op_key != op_ptr.p->op_key);
- itNext(loop_it);
- }
- jam();
- }
-#endif
+ TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ iteratorAddOp(tLoc, op_ptr);
const Uint32 opDepth = trans_ptr.p->m_opDepth;
-
- OpIterator& it = getIterator(trans_ptr).m_opIterator;
- itAddLast(it, op_ptr);
op_ptr.p->m_trans_ptr = trans_ptr;
op_ptr.p->m_opDepth = opDepth;
- D("addSchemaOp" << *op_ptr.p);
+ // add global flags from trans
+ const Uint32 requestInfo = trans_ptr.p->m_requestInfo;
+ DictSignal::copyGlobalFlags(op_ptr.p->m_requestInfo, requestInfo);
- // add global flags from trans (some may already be there from REQ)
- DictSignal::copyGlobalFlags(op_ptr.p->m_requestInfo, trans_ptr.p->m_requestInfo);
+ D("addSchemaOp" << *op_ptr.p);
}
// the link between SchemaOp and DictObject
@@ -17818,6 +17800,310 @@
release_object(obj_ptr.i);
}
+// trans state
+
+bool
+Dbdict::getOpPtr(const TransLoc& tLoc, SchemaOpPtr& op_ptr)
+{
+ if (tLoc.op_key == 0) {
+ jam();
+ op_ptr.setNull();
+ } else {
+ jam();
+ bool ok = findSchemaOp(op_ptr, tLoc.op_key);
+ ndbrequire(ok);
+ }
+ return !op_ptr.isNull();
+}
+
+const Dbdict::TransPhaseEntry&
+Dbdict::getPhaseEntry(const TransLoc& tLoc)
+{
+ ndbrequire(tLoc.m_phaseList != 0);
+ const TransPhaseList& phaseList = *tLoc.m_phaseList;
+ const Uint32 phaseIndex = tLoc.m_phaseIndex;
+ ndbrequire(phaseIndex > 0 && phaseIndex < phaseList.m_length);
+ const TransPhaseEntry& phaseEntry = phaseList.m_phaseEntry[phaseIndex];
+ return phaseEntry;
+}
+
+void
+Dbdict::iteratorAddOp(TransLoc& tLoc, SchemaOpPtr op_ptr)
+{
+ LocalDLFifoList<SchemaOp> list(c_schemaOpPool, tLoc.m_opList.m_head);
+ // check for duplicates
+ SchemaOpPtr loop_ptr;
+ Uint32 size = 0;
+ list.first(loop_ptr);
+ while (!loop_ptr.isNull()) {
+ jam();
+ ndbrequire(loop_ptr.i != op_ptr.i);
+ ndbrequire(loop_ptr.p->op_key != op_ptr.p->op_key);
+ list.next(loop_ptr);
+ size++;
+ }
+ // add it to end
+ list.addLast(op_ptr);
+ ndbrequire(tLoc.m_opList.m_size == size);
+ tLoc.m_opList.m_size += 1;
+ // position iterator at the new op
+ tLoc.op_key = op_ptr.p->op_key;
+}
+
+bool
+Dbdict::iteratorFirstOp(TransLoc& tLoc, int dir)
+{
+ if (tLoc.m_opList.m_size == 0) {
+ jam();
+ return false;
+ }
+ LocalDLFifoList<SchemaOp> list(c_schemaOpPool, tLoc.m_opList.m_head);
+ SchemaOpPtr op_ptr;
+ bool ok = dir > 0 ? list.first(op_ptr) : list.last(op_ptr);
+ ndbrequire(ok);
+ ndbrequire(op_ptr.p->op_key != 0);
+ tLoc.op_key = op_ptr.p->op_key;
+ return true;
+}
+
+bool
+Dbdict::iteratorNextOp(TransLoc& tLoc, int dir)
+{
+ if (tLoc.m_opList.m_size == 0) {
+ jam();
+ return false;
+ }
+ LocalDLFifoList<SchemaOp> list(c_schemaOpPool, tLoc.m_opList.m_head);
+ SchemaOpPtr op_ptr;
+ ndbrequire(tLoc.op_key != 0);
+ bool ok = findSchemaOp(op_ptr, tLoc.op_key);
+ ndbrequire(ok);
+ if (!(dir > 0 ? list.next(op_ptr) : list.prev(op_ptr))) {
+ jam();
+ return false;
+ }
+ ndbrequire(op_ptr.p->op_key != 0);
+ tLoc.op_key = op_ptr.p->op_key;
+ return true;
+}
+
+bool
+Dbdict::iteratorFirst(TransLoc& tLoc, int dir)
+{
+ ndbrequire(tLoc.m_phaseList != 0);
+ const TransPhaseList& phaseList = *tLoc.m_phaseList;
+ ndbrequire(phaseList.m_length >= 2);
+ const Uint32 i = dir > 0 ? 1 : phaseList.m_length - 1;
+ const TransPhaseEntry& phaseEntry = phaseList.m_phaseEntry[i];
+ // end points must be simple (no ops)
+ ndbrequire(phaseEntry.m_phasetype & TransPhasetype::Simple);
+ tLoc.m_phaseIndex = i;
+ tLoc.m_phase = phaseEntry.m_phase;
+ tLoc.m_subphase = phaseEntry.m_subphase;
+ tLoc.m_repeat = 0;
+ tLoc.op_key = 0;
+ return true;
+}
+
+bool
+Dbdict::iteratorNext(TransLoc& tLoc, int dir)
+{
+ ndbrequire(tLoc.m_phaseList != 0);
+ const TransPhaseList& phaseList = *tLoc.m_phaseList;
+ bool loop_one = true;
+ Uint32 i = tLoc.m_phaseIndex;
+ for (; i > 0 && i < phaseList.m_length; i += dir, loop_one = false) {
+ const TransPhaseEntry& phaseEntry = phaseList.m_phaseEntry[i];
+ if (phaseEntry.m_phasetype & TransPhasetype::Simple ||
+ tLoc.m_opList.m_size == 0) {
+ jam();
+ tLoc.op_key = 0;
+ if (loop_one) {
+ jam();
+ continue;
+ }
+ } else {
+ if (tLoc.op_key == 0) {
+ jam();
+ bool ok = iteratorFirstOp(tLoc, dir);
+ ndbrequire(ok);
+ } else {
+ jam();
+ if (!iteratorNextOp(tLoc, dir)) {
+ jam();
+ tLoc.op_key = 0;
+ continue;
+ }
+ }
+ }
+ tLoc.m_phaseIndex = i;
+ tLoc.m_phase = phaseEntry.m_phase;
+ tLoc.m_subphase = phaseEntry.m_subphase;
+ tLoc.m_repeat = 0;
+ return true;
+ }
+ return false;
+}
+
+bool
+Dbdict::iteratorInit(TransLoc& tLoc)
+{
+ tLoc.m_phaseList = &g_defaultPhaseList;
+ tLoc.m_mode = TransMode::Normal;
+ return iteratorFirst(tLoc, +1);
+}
+
+bool
+Dbdict::iteratorMove(TransLoc& tLoc, bool repeatFlag)
+{
+ D("iteratorMove <" << tLoc << V(repeatFlag));
+ bool ret = false;
+ if (repeatFlag) {
+ jam();
+ tLoc.m_repeat += 1;
+ ret = true;
+ } else if (tLoc.m_mode == TransMode::Normal) {
+ jam();
+ ret = iteratorNext(tLoc, +1);
+ } else if (tLoc.m_mode == TransMode::Abort) {
+ jam();
+ ret = true;
+ } else if (tLoc.m_mode == TransMode::Aborting) {
+ jam();
+ ret = iteratorNext(tLoc, -1);
+ } else {
+ ndbrequire(false);
+ }
+ D("iteratorMove >" << tLoc << V(ret));
+ return ret;
+}
+
+void
+Dbdict::iteratorCopy(TransLoc& tLoc, Uint32 mode,
+ Uint32 phaseIndex, Uint32 op_key, Uint32 repeat)
+{
+ D("iteratorCopy <" << tLoc);
+ tLoc.m_phaseList = &g_defaultPhaseList;
+ tLoc.m_mode = (TransMode::Value)mode;
+ tLoc.m_phaseIndex = phaseIndex;
+ const TransPhaseEntry& phaseEntry = getPhaseEntry(tLoc);
+ tLoc.m_phase = phaseEntry.m_phase;
+ tLoc.m_subphase = phaseEntry.m_subphase;
+ tLoc.op_key = op_key;
+ tLoc.m_repeat = repeat;
+ D("iteratorCopy >" << tLoc);
+}
+
+void
+Dbdict::setGlobState(SchemaTransPtr trans_ptr,
+ Uint32 nodeId, TransState::Value state)
+{
+ ndbrequire(nodeId > 0 && nodeId < MAX_NDB_NODES);
+ ndbrequire(trans_ptr.p->m_initNodes.get(nodeId));
+ TransGlob& tGlob = trans_ptr.p->m_transGlob[nodeId];
+ D("setGlobState " << nodeId << ": " << tGlob.state() << "->" << state);
+ tGlob.state(state);
+}
+
+void
+Dbdict::setGlobState(SchemaTransPtr trans_ptr,
+ const NdbNodeBitmask& nodes, TransState::Value state)
+{
+ Uint32 nodeId;
+ for (nodeId = 1; nodeId < MAX_NDB_NODES; nodeId++) {
+ if (nodes.get(nodeId)) {
+ setGlobState(trans_ptr, nodeId, state);
+ }
+ }
+}
+
+void
+Dbdict::setGlobState(SchemaTransPtr trans_ptr,
+ TransState::Value oldstate, TransState::Value state)
+{
+ Uint32 nodeId;
+ for (nodeId = 1; nodeId < MAX_NDB_NODES; nodeId++) {
+ if (trans_ptr.p->m_initNodes.get(nodeId)) {
+ if (hasGlobState(trans_ptr, nodeId, oldstate)) {
+ setGlobState(trans_ptr, nodeId, state);
+ }
+ }
+ }
+}
+
+bool
+Dbdict::hasGlobState(SchemaTransPtr trans_ptr,
+ Uint32 nodeId, TransState::Value state)
+{
+ ndbrequire(nodeId > 0 && nodeId < MAX_NDB_NODES);
+ ndbrequire(trans_ptr.p->m_initNodes.get(nodeId));
+ const TransGlob& tGlob = trans_ptr.p->m_transGlob[nodeId];
+ return tGlob.state() == state;
+}
+
+const Dbdict::TransPhaseEntry
+Dbdict::g_defaultPhaseEntry[] = {
+ { TransPhase::Undef,
+ TransSubphase::Undef,
+ 0,
+ 0,
+ 0
+ },
+ {
+ TransPhase::Begin,
+ TransSubphase::Main,
+ TransPhasetype::Simple,
+ 0,
+ 0
+ },
+ {
+ TransPhase::Parse,
+ TransSubphase::Main,
+ 0,
+ 0,
+ 0
+ },
+ {
+ TransPhase::Prepare,
+ TransSubphase::Main,
+ 0,
+ 0,
+ 0
+ },
+ {
+ TransPhase::Commit,
+ TransSubphase::Main,
+ 0,
+ 0,
+ 0
+ },
+ {
+ TransPhase::End,
+ TransSubphase::Main,
+ TransPhasetype::Simple,
+ 0,
+ 0
+ }
+};
+
+const Dbdict::TransPhaseList
+Dbdict::g_defaultPhaseList = {
+ 0,
+ sizeof(g_defaultPhaseEntry) / sizeof(g_defaultPhaseEntry[0]),
+ g_defaultPhaseEntry
+};
+
+void
+Dbdict::schemaTrans_dummy(Signal* signal, SchemaTransPtr trans_ptr)
+{
+ jam();
+ Uint32 itRepeat = getIteratorRepeat(trans_ptr);
+
+ D("schemaTrans_dummy");
+ ndbrequire(itRepeat == 0);
+ schemaTrans_sendConf(signal, trans_ptr);
+}
+
// SchemaTrans
bool
@@ -17835,14 +18121,10 @@
jam();
new (trans_ptr.p) SchemaTrans();
trans_ptr.p->trans_key = trans_key;
- if (c_phaseIteratorPool.seize(trans_ptr.p->m_iterator_ptr)) {
- jam();
- c_schemaTransHash.add(trans_ptr);
- trans_ptr.p->m_magic = SchemaTrans::DICT_MAGIC;
- D("seizeSchemaTrans" << V(trans_key));
- return true;
- }
- c_schemaTransHash.release(trans_ptr);
+ c_schemaTransHash.add(trans_ptr);
+ trans_ptr.p->m_magic = SchemaTrans::DICT_MAGIC;
+ D("seizeSchemaTrans" << V(trans_key));
+ return true;
}
}
trans_ptr.setNull();
@@ -17880,13 +18162,13 @@
Uint32 trans_key = trans_ptr.p->trans_key;
D("releaseSchemaTrans" << V(trans_key));
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, trans_ptr.p->m_opList.m_head);
+ TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ LocalDLFifoList<SchemaOp> list(c_schemaOpPool, tLoc.m_opList.m_head);
SchemaOpPtr op_ptr;
while (list.first(op_ptr)) {
list.remove(op_ptr);
releaseSchemaOp(op_ptr);
}
- c_phaseIteratorPool.release(trans_ptr.p->m_iterator_ptr);
ndbrequire(trans_ptr.p->m_magic == SchemaTrans::DICT_MAGIC);
trans_ptr.p->m_magic = 0;
c_schemaTransHash.release(trans_ptr);
@@ -17897,19 +18179,11 @@
ndbrequire(c_opSectionPool.getNoOfFree() == c_opSectionPool.getSize());
}
-Dbdict::PhaseIterator&
-Dbdict::getIterator(SchemaTransPtr trans_ptr)
-{
- PhaseIteratorPtr iterator_ptr = trans_ptr.p->m_iterator_ptr;
- ndbrequire(!iterator_ptr.isNull());
- return *iterator_ptr.p;
-}
-
Uint32
Dbdict::getIteratorRepeat(SchemaTransPtr trans_ptr)
{
- const PhaseIterator& it = getIterator(trans_ptr);
- return it.m_repeat;
+ const TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ return tLoc.m_repeat;
}
// client requests
@@ -17953,12 +18227,6 @@
break;
}
- // initialize iterator in master
- {
- PhaseIterator& it = getIterator(trans_ptr);
- new (&it) PhaseIterator(g_defaultPhaseList, trans_ptr.p->m_opList);
- }
-
trans_ptr.p->m_isMaster = true;
trans_ptr.p->m_masterRef = reference();
trans_ptr.p->m_clientRef = clientRef;
@@ -17972,11 +18240,20 @@
}
trans_ptr.p->m_clientGsn = GSN_SCHEMA_TRANS_BEGIN_REQ;
+ // initialize local state and iterator
+ TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ iteratorInit(tLoc);
+
+ // initialize global state
+ const Uint32 ownNodeId = getOwnNodeId();
+ setGlobState(trans_ptr, ownNodeId, TransState::Ok);
+
+ // other nodes have no trans record yet
+ NdbNodeBitmask nodes = trans_ptr.p->m_initNodes;
+ nodes.clear(ownNodeId);
+ setGlobState(trans_ptr, nodes, TransState::NeedTrans);
+
// begin tx on all participants
- trans_ptr.p->m_requestType = SchemaTransImplReq::RT_BEGIN;
- // nodes which have not yet seized trans record
- trans_ptr.p->m_skipNodes = trans_ptr.p->m_initNodes;
- trans_ptr.p->m_skipNodes.clear(getOwnNodeId());
schemaTrans_sendReq(signal, trans_ptr);
#if wl3600_todo
@@ -18041,9 +18318,14 @@
trans_ptr.p->m_clientGsn = GSN_SCHEMA_TRANS_END_REQ;
- D("execSCHEMA_TRANS_END_REQ" << *trans_ptr.p << trans_ptr.p->m_opList);
+ const TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ ndbrequire(tLoc.m_mode == TransMode::Normal);
+
+ D("execSCHEMA_TRANS_END_REQ" << *trans_ptr.p << tLoc.m_opList);
+
+ setGlobState(trans_ptr, TransState::NeedOp, TransState::NoOp);
+ setGlobState(trans_ptr, TransState::NeedTrans, TransState::NoTrans);
- ndbrequire(trans_ptr.p->m_abortMode == 0);
if (!commitFlag) {
jam();
abortSchemaTrans(signal, trans_ptr);
@@ -18075,17 +18357,15 @@
{
D("schemaTrans_sendReq" << *trans_ptr.p);
- const PhaseIterator& it = getIterator(trans_ptr);
- SchemaOpPtr op_ptr = itGetPtr(it);
-
- const Uint32 requestType = trans_ptr.p->m_requestType;
- const Uint32 abortMode = trans_ptr.p->m_abortMode;
+ const TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ SchemaOpPtr op_ptr;
+ getOpPtr(tLoc, op_ptr);
Uint32 gsn = 0;
// piggy-backed signal in parse phase
Uint32 extra_length = 0;
- if (requestType == SchemaTransImplReq::RT_PARSE &&
- abortMode == 0) {
+ if (tLoc.m_mode == TransMode::Normal &&
+ tLoc.m_phase == TransPhase::Parse) {
jam();
const OpInfo& info = getOpInfo(op_ptr);
gsn = info.m_impl_req_gsn;
@@ -18104,10 +18384,11 @@
SchemaTransImplReq* req = (SchemaTransImplReq*)signal->getDataPtrSend();
Uint32 requestInfo = 0;
- SchemaTransImplReq::setRequestType(requestInfo, requestType);
- SchemaTransImplReq::setAbortMode(requestInfo, abortMode);
+ SchemaTransImplReq::setMode(requestInfo, tLoc.m_mode);
+ SchemaTransImplReq::setPhase(requestInfo, tLoc.m_phase);
+ SchemaTransImplReq::setSubphase(requestInfo, tLoc.m_subphase);
+
// pass any global flags
- // wl3600_todo should separate trans/op flags
DictSignal::copyGlobalFlags(requestInfo, trans_ptr.p->m_requestInfo);
if (!op_ptr.isNull())
DictSignal::copyGlobalFlags(requestInfo, op_ptr.p->m_requestInfo);
@@ -18117,28 +18398,40 @@
SchemaTransImplReq::setGsn(operationInfo, gsn);
SchemaTransImplReq::setOpDepth(operationInfo, op_ptr.p->m_opDepth);
}
+
+ Uint32 iteratorInfo = 0;
+ SchemaTransImplReq::setListId(iteratorInfo, tLoc.m_phaseList->m_id);
+ SchemaTransImplReq::setListIndex(iteratorInfo, tLoc.m_phaseIndex);
+ if (!op_ptr.isNull())
+ SchemaTransImplReq::setOpIndex(iteratorInfo, op_ptr.p->m_opIndex);
+ else
+ SchemaTransImplReq::setOpIndex(iteratorInfo, ZNIL);
+ SchemaTransImplReq::setItRepeat(iteratorInfo, tLoc.m_repeat);
req->senderRef = reference();
req->transKey = trans_ptr.p->trans_key;
- req->opKey = !op_ptr.isNull() ? op_ptr.p->op_key : RNIL;
+ req->opKey = !op_ptr.isNull() ? op_ptr.p->op_key : 0;
req->requestInfo = requestInfo;
req->operationInfo = operationInfo;
- req->iteratorInfo = trans_ptr.p->m_iteratorInfo;
+ req->iteratorInfo = iteratorInfo;
req->clientRef = trans_ptr.p->m_clientRef;
req->transId = trans_ptr.p->m_transId;
- NdbNodeBitmask nodes = trans_ptr.p->m_initNodes;
- nodes.bitANDC(trans_ptr.p->m_deadNodes);
+ NdbNodeBitmask nodes;
+ Uint32 nodeId;
- if (abortMode == 1 && !trans_ptr.p->m_skipNodes.isclear()) {
- jam();
- ndbrequire(requestType == SchemaTransImplReq::RT_BEGIN ||
- requestType == SchemaTransImplReq::RT_PARSE ||
- requestType == SchemaTransImplReq::RT_END);
- // first round of abort begin/parse omits nodes without trans/op
- nodes.bitANDC(trans_ptr.p->m_skipNodes);
- trans_ptr.p->m_skipNodes.clear();
+ for (nodeId = 1; nodeId < MAX_NDB_NODES; nodeId++) {
+ if (trans_ptr.p->m_initNodes.get(nodeId)) {
+ if (hasGlobState(trans_ptr, nodeId, TransState::NodeFail) ||
+ hasGlobState(trans_ptr, nodeId, TransState::NoTrans) ||
+ hasGlobState(trans_ptr, nodeId, TransState::NoOp)) {
+ D("skip send:" << V(nodeId));
+ } else {
+ nodes.set(nodeId);
+ }
+ }
}
+
ndbrequire(!nodes.isclear());//wl3600_todo got crash here after NF
NodeReceiverGroup rg(DBDICT, nodes);
@@ -18147,8 +18440,8 @@
bool ok = sc.init<SchemaTransImplRef>(rg, trans_ptr.p->trans_key);
ndbrequire(ok);
}
- trans_ptr.p->m_recvItFlags = 0;
+ trans_ptr.p->m_recvItFlags = 0;
sendFragmentedSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
SchemaTransImplReq::SignalLength + extra_length, JBB);
}
@@ -18156,8 +18449,12 @@
void
Dbdict::schemaTrans_sendParseReq(Signal* signal, SchemaOpPtr op_ptr)
{
+ D("schemaTrans_sendParseReq");
+
SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
- ndbrequire(trans_ptr.p->m_requestType == SchemaTransImplReq::RT_PARSE);
+ const TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ ndbrequire(tLoc.m_mode == TransMode::Normal &&
+ tLoc.m_phase == TransPhase::Parse);
schemaTrans_sendReq(signal, trans_ptr);
releaseSections(signal);
}
@@ -18203,37 +18500,56 @@
}
Uint32 nodeId = refToNode(senderRef);
- D("schemaTrans_recvReply" << V(isConf) << V(nodeId) << hex << V(trans_key));
+ D("schemaTrans_recvReply" << V(isConf) << V(nodeId) << V(trans_key));
SchemaTransPtr trans_ptr;
findSchemaTrans(trans_ptr, trans_key);
ndbrequire(!trans_ptr.isNull());
trans_ptr.p->m_recvItFlags |= recvItFlags;
- if (error.errorCode == SchemaTransImplRef::NF_FakeErrorREF) {
+ const TransLoc& tLoc = trans_ptr.p->m_transLoc;
+
+ // clear previous round
+
+ setGlobState(trans_ptr, TransState::NoTrans, TransState::Ok);
+ setGlobState(trans_ptr, TransState::NoOp, TransState::Ok);
+
+ // set remote state according to error type
+
+ if (!hasError(error)) {
+ jam();
+ setGlobState(trans_ptr, nodeId, TransState::Ok);
+
+ } else if (error.errorCode == SchemaTransImplRef::NF_FakeErrorREF) {
jam();
// exclude the node permanently from this tx
- trans_ptr.p->m_deadNodes.set(nodeId);
D("node marked dead:" << V(nodeId));
+ setGlobState(trans_ptr, nodeId, TransState::NodeFail);
resetError(error);
- }
- if (hasError(error)) {
+ } else if (error.errorCode == SchemaTransImplRef::TooManySchemaTrans) {
jam();
- D("node returned error:" << V(nodeId) << V(error.errorCode));
+ D("node failed to seize trans record:" << V(nodeId));
+ ndbrequire(tLoc.m_mode == TransMode::Normal);
+ ndbrequire(tLoc.m_phase == TransPhase::Begin);
+ ndbrequire(hasGlobState(trans_ptr, nodeId, TransState::NeedTrans));
+ setGlobState(trans_ptr, nodeId, TransState::NoTrans);
setError(trans_ptr.p->m_error, error);
- }
- if (trans_ptr.p->m_abortMode == 0) {
- if (trans_ptr.p->m_requestType == SchemaTransImplReq::RT_BEGIN &&
- error.errorCode != SchemaTransImplRef::TooManySchemaTrans ||
- trans_ptr.p->m_requestType == SchemaTransImplReq::RT_PARSE &&
- error.errorCode != SchemaTransImplRef::TooManySchemaOps) {
- jam();
- // this node has seized current trans/op record
- //ndbrequire(!trans_ptr.p->m_skipNodes.get(nodeId));
- trans_ptr.p->m_skipNodes.clear(nodeId);
- }
+ } else if (error.errorCode == SchemaTransImplRef::TooManySchemaOps) {
+ jam();
+ D("node failed to seize op record:" << V(nodeId));
+ ndbrequire(tLoc.m_mode == TransMode::Normal);
+ ndbrequire(tLoc.m_phase == TransPhase::Parse);
+ ndbrequire(hasGlobState(trans_ptr, nodeId, TransState::NeedOp));
+ setGlobState(trans_ptr, nodeId, TransState::NoOp);
+ setError(trans_ptr.p->m_error, error);
+
+ } else {
+ jam();
+ D("node returned error:" << V(nodeId) << V(error.errorCode));
+ setGlobState(trans_ptr, nodeId, TransState::Error);
+ setError(trans_ptr.p->m_error, error);
}
{
@@ -18251,22 +18567,19 @@
void
Dbdict::schemaTrans_handleReply(Signal* signal, SchemaTransPtr trans_ptr)
{
- PhaseIterator& it = getIterator(trans_ptr);
- SchemaOpPtr op_ptr = itGetPtr(it);
+ const TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ SchemaOpPtr op_ptr;
+ getOpPtr(tLoc, op_ptr);
const Uint32 trans_key = trans_ptr.p->trans_key;
const Uint32 clientRef = trans_ptr.p->m_clientRef;
const Uint32 transId = trans_ptr.p->m_transId;
- // set received flags as initial value
- const Uint32 recvItFlags = trans_ptr.p->m_recvItFlags;
- SchemaTransImplReq::setItFlags(trans_ptr.p->m_iteratorInfo, recvItFlags);
-
if (hasError(trans_ptr.p->m_error) ||
- trans_ptr.p->m_abortMode != 0) {
+ tLoc.m_mode != TransMode::Normal) {
// in PARSE phase only return REF, client must do abort
- if (trans_ptr.p->m_requestType == SchemaTransImplReq::RT_PARSE &&
- trans_ptr.p->m_abortMode == 0) {
+ if (tLoc.m_phase == TransPhase::Parse &&
+ tLoc.m_mode == TransMode::Normal) {
jam();
const OpInfo& info = getOpInfo(op_ptr);
(this->*(info.m_reply))(signal, op_ptr, trans_ptr.p->m_error);
@@ -18277,21 +18590,20 @@
abortSchemaTrans(signal, trans_ptr);
}
- const Uint32 requestType = trans_ptr.p->m_requestType;
- const Uint32 abortMode = trans_ptr.p->m_abortMode;
const Uint32 clientGsn = trans_ptr.p->m_clientGsn;
- D("schemaTrans_handleReply" << V(requestType) << V(abortMode) << V(clientGsn));
+ D("schemaTrans_handleReply" << tLoc << V(clientGsn));
- if (abortMode == 0) {
- switch (requestType) {
- case SchemaTransImplReq::RT_BEGIN:
+ if (tLoc.m_mode == TransMode::Normal) {
+ jam();
+ switch (tLoc.m_phase) {
+ case TransPhase::Begin:
jam();
{
schemaTrans_reply(signal, trans_ptr);
}
break;
- case SchemaTransImplReq::RT_PARSE:
+ case TransPhase::Parse:
jam();
{
/*
@@ -18303,24 +18615,16 @@
}
break;
- case SchemaTransImplReq::RT_PREPARE_BEGIN:
- jam();
- case SchemaTransImplReq::RT_PREPARE:
- jam();
- case SchemaTransImplReq::RT_PREPARE_END:
- jam();
- case SchemaTransImplReq::RT_COMMIT_BEGIN:
- jam();
- case SchemaTransImplReq::RT_COMMIT:
+ case TransPhase::Prepare:
jam();
- case SchemaTransImplReq::RT_COMMIT_END:
+ case TransPhase::Commit:
jam();
{
runSchemaTrans(signal, trans_ptr);
}
break;
- case SchemaTransImplReq::RT_END:
+ case TransPhase::End:
jam();
{
schemaTrans_reply(signal, trans_ptr);
@@ -18334,31 +18638,29 @@
break;
}
} else {
- switch (requestType) {
- case SchemaTransImplReq::RT_BEGIN:
- jam();
- case SchemaTransImplReq::RT_PARSE:
- jam();
- case SchemaTransImplReq::RT_PREPARE_BEGIN:
- jam();
- case SchemaTransImplReq::RT_PREPARE:
+ jam();
+ switch (tLoc.m_phase) {
+ case TransPhase::Begin:
jam();
- case SchemaTransImplReq::RT_PREPARE_END:
+ {
+ schemaTrans_reply(signal, trans_ptr);
+ releaseSchemaTrans(trans_ptr);
+ c_blockState = BS_IDLE;
+ }
+ break;
+
+ case TransPhase::Parse:
jam();
- case SchemaTransImplReq::RT_COMMIT_BEGIN:
+ case TransPhase::Prepare:
jam();
{
runSchemaTrans(signal, trans_ptr);
}
break;
- case SchemaTransImplReq::RT_END:
+ case TransPhase::End:
jam();
- {
- schemaTrans_reply(signal, trans_ptr);
- releaseSchemaTrans(trans_ptr);
- c_blockState = BS_IDLE;
- }
+ ndbrequire(false);
break;
default:
@@ -18412,112 +18714,48 @@
(this->*(info.m_reply))(signal, op_ptr, error);
}
-bool
-Dbdict::stepSchemaTrans(Signal*, SchemaTransPtr trans_ptr)
-{
- PhaseIterator& it = getIterator(trans_ptr);
-
- const Uint32 info = trans_ptr.p->m_iteratorInfo;
- const Uint32 itFlags = SchemaTransImplReq::getItFlags(info);
-
- D("stepSchemaTrans [in]" << it << hex << V(itFlags));
-
- bool found;
- if (itFlags & SchemaTransImplReq::IT_HOLD) {
- jam();
- // wl3600_todo something
- found = it.m_index != 0 || !it.m_opIterator.m_op_ptr.isNull();
- } else if (itFlags & SchemaTransImplReq::IT_REPEAT) {
- jam();
- bool ok = itRepeat(it);
- ndbrequire(ok);
- found = true;
- } else if (!(itFlags & SchemaTransImplReq::IT_REVERSE)) {
- jam();
- found = itNext(it);
- } else {
- jam();
- found = itPrev(it);
- }
-
- // on master fill in new, on slave verify
- if (found) {
- jam();
-
- SchemaOpPtr op_ptr = itGetPtr(it);
- const PhaseList& pl = it.m_phaseList;
- const Uint32 listId = pl.m_listId;
- const Uint32 listIndex = it.m_index;
- const Uint32 opIndex = !op_ptr.isNull() ? op_ptr.p->m_opIndex : ~(Uint32)0;
- const Uint32 itRepeat = it.m_repeat;
-
- if (trans_ptr.p->m_isMaster) {
- Uint32& info = trans_ptr.p->m_iteratorInfo;
- SchemaTransImplReq::setListId(info, listId);
- SchemaTransImplReq::setListIndex(info, listIndex);
- SchemaTransImplReq::setOpIndex(info, opIndex);
- SchemaTransImplReq::setItRepeat(info, itRepeat);
- } else {
- jam();
- ndbrequire(SchemaTransImplReq::getListId(info) == listId);
- ndbrequire(SchemaTransImplReq::getListIndex(info) == listIndex);
- ndbrequire(SchemaTransImplReq::getOpIndex(info) == opIndex);
- ndbrequire(SchemaTransImplReq::getItRepeat(info) == itRepeat);
- }
- }
-
- D("stepSchemaTrans [out]" << V(found) << it);
- return found;
-}
-
void
Dbdict::runSchemaTrans(Signal* signal, SchemaTransPtr trans_ptr)
{
- const PhaseIterator& it = getIterator(trans_ptr);
D("runSchemaTrans");
+ TransLoc& tLoc = trans_ptr.p->m_transLoc;
- const bool found = stepSchemaTrans(signal, trans_ptr);
-
- if (found) {
+ if (tLoc.m_phase == TransPhase::Begin) {
jam();
- const PhaseList& pl = it.m_phaseList;
- ndbrequire(it.m_index < pl.m_count);
- const PhaseEntry& pe = pl.m_entry[it.m_index];
-
- // always send to all in order to keep iterators synced
- trans_ptr.p->m_requestType = pe.m_requestType;
- schemaTrans_sendReq(signal, trans_ptr);
- return;
+ // choose to skip trans with no operations
+ if (tLoc.m_mode == TransMode::Normal) {
+ while (tLoc.m_phase != TransPhase::End) {
+ jam();
+ iteratorMove(tLoc, false);
+ }
+ }
+ } else {
+ jam();
+ bool repeatFlag = (trans_ptr.p->m_recvItFlags & SchemaTransImplReq::IT_REPEAT);
+ bool found = iteratorMove(tLoc, repeatFlag);
+ ndbrequire(found);
}
- trans_ptr.p->m_requestType = SchemaTransImplReq::RT_END;
+ // always send to all in order to keep iterators synced
schemaTrans_sendReq(signal, trans_ptr);
}
-// advances abort mode and sets iterator flags on each round
+// advances abort mode
void
Dbdict::abortSchemaTrans(Signal* signal, SchemaTransPtr trans_ptr)
{
D("abortSchemaTrans" << *trans_ptr.p);
+ TransLoc& tLoc = trans_ptr.p->m_transLoc;
- if (trans_ptr.p->m_abortMode == 0) {
+ if (tLoc.m_mode == TransMode::Normal) {
jam();
-
// intermediate mode to undo the failed step
- trans_ptr.p->m_abortMode = 1;
- const Uint32 addItFlags = SchemaTransImplReq::IT_HOLD;
- SchemaTransImplReq::addItFlags(trans_ptr.p->m_iteratorInfo, addItFlags);
- } else if (trans_ptr.p->m_abortMode <= 2) {
- jam();
-
- // normal abort run
- trans_ptr.p->m_abortMode = 2;
- const Uint32 delItFlags = SchemaTransImplReq::IT_HOLD;
- const Uint32 addItFlags = SchemaTransImplReq::IT_REVERSE;
- SchemaTransImplReq::delItFlags(trans_ptr.p->m_iteratorInfo, delItFlags);
- SchemaTransImplReq::addItFlags(trans_ptr.p->m_iteratorInfo, addItFlags);
+ tLoc.m_mode = TransMode::Abort;
} else {
- ndbrequire(false);
+ jam();
+ ndbrequire(tLoc.m_mode == TransMode::Abort ||
+ tLoc.m_mode == TransMode::Aborting);
+ tLoc.m_mode = TransMode::Aborting;
}
}
@@ -18550,14 +18788,20 @@
const Uint32 transId = req->transId;
// unpack requestInfo
- const Uint32 requestType = SchemaTransImplReq::getRequestType(requestInfo);
- const Uint32 abortMode = SchemaTransImplReq::getAbortMode(requestInfo);
+ const Uint32 mode = SchemaTransImplReq::getMode(requestInfo);
+ const Uint32 phase = SchemaTransImplReq::getPhase(requestInfo);
+ const Uint32 subphase = SchemaTransImplReq::getSubphase(requestInfo);
+ const Uint32 repeat = SchemaTransImplReq::getItRepeat(iteratorInfo);
// unpack operation info
const Uint32 gsn = SchemaTransImplReq::getGsn(operationInfo);
const Uint32 opDepth = SchemaTransImplReq::getOpDepth(operationInfo);
- D("schemaTrans_recvReq");
+ // unpack iterator info
+ const Uint32 phaseIndex = SchemaTransImplReq::getListIndex(iteratorInfo);
+
+ // wl3600_todo signal length is wrong
+ D("schemaTrans_recvReq" << V(signal->getLength()));
// cannot receive a new master before this signal arrives
// enable when RF_LOCAL_TRANS is in req
@@ -18569,14 +18813,14 @@
const bool isMaster = (senderRef == reference());
const bool seizeTrans =
- !isMaster && requestType == SchemaTransImplReq::RT_BEGIN;
+ !isMaster && mode == TransMode::Normal && phase == TransPhase::Begin;
const bool releaseTrans =
- !isMaster && requestType == SchemaTransImplReq::RT_END;
+ !isMaster && mode == TransMode::Normal && phase == TransPhase::End ||
+ !isMaster && mode != TransMode::Normal && phase == TransPhase::Begin;
const bool sendConf =
- requestType == SchemaTransImplReq::RT_BEGIN ||
- requestType == SchemaTransImplReq::RT_END;
+ phase == TransPhase::Begin || phase == TransPhase::End;
if (seizeTrans) {
jam();
@@ -18593,11 +18837,14 @@
ndbrequire(!trans_ptr.isNull());
}
+ TransLoc& tLoc = trans_ptr.p->m_transLoc;
+
if (isMaster) {
ndbrequire(trans_ptr.p->m_isMaster == true);
ndbrequire(trans_ptr.p->m_masterRef == senderRef);
- ndbrequire(trans_ptr.p->m_requestType == requestType);
- ndbrequire(trans_ptr.p->m_iteratorInfo == iteratorInfo);
+ ndbrequire(tLoc.m_mode == mode);
+ ndbrequire(tLoc.m_phase == phase);
+ ndbrequire(tLoc.m_subphase == subphase);
} else {
jam();
if (trans_ptr.p->m_masterRef == 0) {
@@ -18610,71 +18857,46 @@
ndbrequire(trans_ptr.p->m_isMaster == false);
ndbrequire(trans_ptr.p->m_masterRef == senderRef);
}
- trans_ptr.p->m_requestType = requestType;
- trans_ptr.p->m_abortMode = abortMode;
trans_ptr.p->m_opDepth = opDepth;
- trans_ptr.p->m_iteratorInfo = iteratorInfo;
+ iteratorCopy(tLoc, mode, phaseIndex, op_key, repeat);
+ ndbrequire(tLoc.m_phase == phase && tLoc.m_subphase == subphase);
}
- // iterator on slave will be initialized or advanced
- PhaseIterator& it = getIterator(trans_ptr);
-
- if (abortMode == 0) {
- switch (requestType) {
- case SchemaTransImplReq::RT_BEGIN:
+ if (tLoc.m_mode == TransMode::Normal) {
+ jam();
+ switch (tLoc.m_phase) {
+ case TransPhase::Begin:
jam();
- {
- // initialize iterator on slave
- if (!isMaster) {
- PhaseIterator& it = getIterator(trans_ptr);
- new (&it) PhaseIterator(g_defaultPhaseList, trans_ptr.p->m_opList);
- }
- }
break;
- case SchemaTransImplReq::RT_PARSE:
+ case TransPhase::Parse:
jam();
{
- Uint32* data = signal->getDataPtrSend();
-
+ const OpInfo* info = findOpInfo(gsn);
+ ndbrequire(info != 0);
+ Uint32 length = info->m_impl_req_length;
Uint32 skip = SchemaTransImplReq::SignalLength;
- ndbrequire(signal->getLength() > skip);
- Uint32 length = signal->getLength() - skip;
+ ndbrequire(skip + length <= 25);
+ Uint32* data = signal->getDataPtrSend();
Uint32 i = 0;
- while (i < length) {
+ for (i = 0; i < length; i++)
data[i] = data[skip + i];
- i++;
- }
- schemaTrans_recvParseReq(signal, trans_ptr, op_key, gsn);
+ schemaTrans_recvParseReq(signal, trans_ptr, op_key, *info);
}
break;
- case SchemaTransImplReq::RT_PREPARE_BEGIN:
- jam();
- case SchemaTransImplReq::RT_PREPARE:
- jam();
- case SchemaTransImplReq::RT_PREPARE_END:
+ case TransPhase::Prepare:
jam();
- case SchemaTransImplReq::RT_COMMIT_BEGIN:
- jam();
- case SchemaTransImplReq::RT_COMMIT:
- jam();
- case SchemaTransImplReq::RT_COMMIT_END:
+ case TransPhase::Commit:
jam();
{
- // advance iterator on slave
- if (!isMaster) {
- jam();
- bool ok = stepSchemaTrans(signal, trans_ptr);
- ndbrequire(ok);
- }
runSchemaOp(signal, trans_ptr);
}
break;
- case SchemaTransImplReq::RT_END:
+ case TransPhase::End:
jam();
break;
@@ -18683,36 +18905,20 @@
break;
}
} else {
- switch (requestType) {
- case SchemaTransImplReq::RT_BEGIN:
- ndbrequire(false);
+ switch (tLoc.m_phase) {
+ case TransPhase::Begin:
+ jam();
break;
- case SchemaTransImplReq::RT_PARSE:
- jam();
- case SchemaTransImplReq::RT_PREPARE_BEGIN:
+ case TransPhase::Parse:
jam();
- case SchemaTransImplReq::RT_PREPARE:
- jam();
- case SchemaTransImplReq::RT_PREPARE_END:
- jam();
- case SchemaTransImplReq::RT_COMMIT_BEGIN:
+ case TransPhase::Prepare:
jam();
{
- // advance iterator on slave
- if (!isMaster) {
- jam();
- bool ok = stepSchemaTrans(signal, trans_ptr);
- ndbrequire(ok);
- }
runSchemaOp(signal, trans_ptr);
}
break;
- case SchemaTransImplReq::RT_END:
- jam();
- break;
-
default:
ndbrequire(false);
break;
@@ -18723,12 +18929,10 @@
jam();
schemaTrans_sendConf(signal, trans_ptr);
}
-
if (releaseTrans) {
jam();
releaseSchemaTrans(trans_ptr);
}
-
return;
} while (0);
@@ -18748,12 +18952,10 @@
*/
void
Dbdict::schemaTrans_recvParseReq(Signal* signal, SchemaTransPtr trans_ptr,
- Uint32 op_key, Uint32 gsn)
+ Uint32 op_key, const OpInfo& info)
{
- const OpInfo* info_p = findOpInfo(gsn);
- ndbrequire(info_p != 0);
- const OpInfo& info = *info_p;
SchemaOpPtr op_ptr;
+ D("schemaTrans_recvParseReq");
// signal data contains impl_req
const Uint32* src = signal->getDataPtr();
@@ -18801,48 +19003,45 @@
void
Dbdict::runSchemaOp(Signal* signal, SchemaTransPtr trans_ptr)
{
- const Uint32 requestType = trans_ptr.p->m_requestType;
- const Uint32 abortMode = trans_ptr.p->m_abortMode;
-
- D("runSchemaOp" << V(requestType));
+ const TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ SchemaOpPtr op_ptr;
+ getOpPtr(tLoc, op_ptr);
- const PhaseIterator& it = getIterator(trans_ptr);
- const PhaseList& pl = it.m_phaseList;
- ndbrequire(it.m_index < pl.m_count);
- const PhaseEntry& pe = pl.m_entry[it.m_index];
+ D("runSchemaOp");
+ const TransPhaseEntry& phaseEntry = getPhaseEntry(tLoc);
const bool isMaster = (trans_ptr.p->m_masterRef == reference());
// master phase on slave does nothing more
- if (!isMaster && (pe.m_flags & PH_MASTER)) {
+ if (!isMaster && (phaseEntry.m_phasetype & TransPhasetype::Master)) {
jam();
schemaTrans_sendConf(signal, trans_ptr);
return;
}
- if (pe.m_flags & PH_SIMPLE) {
+ if (phaseEntry.m_phasetype & TransPhasetype::Simple) {
jam();
- if (!abortMode) {
+ ndbrequire(op_ptr.isNull());
+ if (tLoc.m_mode == TransMode::Normal) {
jam();
- ndbrequire(pe.m_simple != 0);
- (this->*(pe.m_simple))(signal, trans_ptr);
+ ndbrequire(phaseEntry.m_run != 0);
+ (this->*(phaseEntry.m_run))(signal, trans_ptr);
} else {
jam();
- ndbrequire(pe.m_abort != 0);
- (this->*(pe.m_abort))(signal, trans_ptr);
+ ndbrequire(phaseEntry.m_abort != 0);
+ (this->*(phaseEntry.m_abort))(signal, trans_ptr);
}
} else {
jam();
- SchemaOpPtr op_ptr = itGetPtr(it);
ndbrequire(!op_ptr.isNull());
// wl3600_todo verify op_key
const OpInfo& info = getOpInfo(op_ptr);
- if (!abortMode) {
- switch (trans_ptr.p->m_requestType) {
- case SchemaTransImplReq::RT_PREPARE:
+ if (tLoc.m_mode == TransMode::Normal) {
+ switch (tLoc.m_phase) {
+ case TransPhase::Prepare:
(this->*(info.m_prepare))(signal, op_ptr);
break;
- case SchemaTransImplReq::RT_COMMIT:
+ case TransPhase::Commit:
(this->*(info.m_commit))(signal, op_ptr);
break;
default:
@@ -18850,11 +19049,11 @@
break;
}
} else {
- switch (trans_ptr.p->m_requestType) {
- case SchemaTransImplReq::RT_PARSE:
+ switch (tLoc.m_phase) {
+ case TransPhase::Parse:
(this->*(info.m_abortParse))(signal, op_ptr);
break;
- case SchemaTransImplReq::RT_PREPARE:
+ case TransPhase::Prepare:
(this->*(info.m_abortPrepare))(signal, op_ptr);
// mark it in advance
op_ptr.p->m_abortPrepareDone = true;
@@ -18905,24 +19104,17 @@
void
Dbdict::schemaTrans_sendRef(Signal* signal, SchemaTransPtr trans_ptr)
{
+ D("schemaTrans_sendRef");
ndbrequire(hasError(trans_ptr.p->m_error));
// trans is not defined on RT_BEGIN REF
if (trans_ptr.i != RNIL) {
- const PhaseIterator& it = getIterator(trans_ptr);
- const PhaseList& pl = it.m_phaseList;
- ndbrequire(it.m_index < pl.m_count);
- const PhaseEntry& pe = pl.m_entry[it.m_index];
-
- const Uint32 abortMode = trans_ptr.p->m_abortMode;
- D("schemaTrans_sendRef" << V(abortMode) << V(pe.m_requestType));
-
- if (abortMode == 0) {
- switch (pe.m_requestType) {
- case SchemaTransImplReq::RT_COMMIT_BEGIN:
- case SchemaTransImplReq::RT_COMMIT:
- case SchemaTransImplReq::RT_COMMIT_END:
- case SchemaTransImplReq::RT_END:
+ const TransLoc& tLoc = trans_ptr.p->m_transLoc;
+
+ if (tLoc.m_mode == TransMode::Normal) {
+ switch (tLoc.m_phase) {
+ case TransPhase::Commit:
+ case TransPhase::End:
// fail commit must crash
ndbrequire(false);
break;
@@ -19010,286 +19202,6 @@
ndbrequire(false);
}
-// phases and iterators
-
-Dbdict::SchemaOpPtr
-Dbdict::itGetPtr(const OpIterator& it)
-{
- return it.m_op_ptr;
-}
-
-void
-Dbdict::itAddLast(OpIterator& it, SchemaOpPtr op_ptr)
-{
- {
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, it.m_opList.m_head);
- list.addLast(op_ptr);
- op_ptr.p->m_opIndex = it.m_opList.m_size;
- it.m_opList.m_size += 1;
- }
- it.m_op_ptr = op_ptr;
-}
-
-void
-Dbdict::itAddBeforeLast(OpIterator& it, SchemaOpPtr op_ptr)
-{
- {
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, it.m_opList.m_head);
- SchemaOpPtr last_op_ptr = itGetPtr(it);
- ndbrequire(!last_op_ptr.isNull());
- list.insert(op_ptr, last_op_ptr);
- op_ptr.p->m_opIndex = last_op_ptr.p->m_opIndex;
- last_op_ptr.p->m_opIndex += 1;
- it.m_opList.m_size += 1;
- }
- it.m_op_ptr = op_ptr;
-}
-
-bool
-Dbdict::itExists(const OpIterator& it)
-{
- return !itGetPtr(it).isNull();
-}
-
-bool
-Dbdict::itFirst(OpIterator& it)
-{
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, it.m_opList.m_head);
- return list.first(it.m_op_ptr);
-}
-
-bool
-Dbdict::itLast(OpIterator& it)
-{
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, it.m_opList.m_head);
- return list.last(it.m_op_ptr);
-}
-
-bool
-Dbdict::itNext(OpIterator& it)
-{
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, it.m_opList.m_head);
- ndbrequire(!it.m_op_ptr.isNull());
- return list.next(it.m_op_ptr);
-}
-
-bool
-Dbdict::itPrev(OpIterator& it)
-{
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, it.m_opList.m_head);
- ndbrequire(!it.m_op_ptr.isNull());
- return list.prev(it.m_op_ptr);
-}
-
-bool
-Dbdict::itHasNext(OpIterator& it)
-{
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, it.m_opList.m_head);
- ndbrequire(!it.m_op_ptr.isNull());
- return list.hasNext(it.m_op_ptr);
-}
-
-bool
-Dbdict::itHasPrev(OpIterator& it)
-{
- LocalDLFifoList<SchemaOp> list(c_schemaOpPool, it.m_opList.m_head);
- ndbrequire(!it.m_op_ptr.isNull());
- return list.hasPrev(it.m_op_ptr);
-}
-
-// phase iterator
-
-Dbdict::SchemaOpPtr
-Dbdict::itGetPtr(const PhaseIterator& it)
-{
- return itGetPtr(it.m_opIterator);
-}
-
-bool
-Dbdict::itExists(const PhaseIterator& it)
-{
- const PhaseList& pl = it.m_phaseList;
- if (it.m_index < pl.m_count) {
- const PhaseEntry& pe = pl.m_entry[it.m_index];
- // current op exists if not simple phase
- ndbrequire(itExists(it.m_opIterator) == !(pe.m_flags & PH_SIMPLE));
- return true;
- }
- return false;
-}
-
-bool
-Dbdict::itFirst(PhaseIterator& it)
-{
- D("itFirst" << it);
- it.m_repeat = 0;
- const PhaseList& pl = it.m_phaseList;
- for (it.m_index = 0; it.m_index < pl.m_count; it.m_index++) {
- const PhaseEntry& pe = pl.m_entry[it.m_index];
- if (pe.m_flags & PH_SIMPLE) {
- it.m_opIterator.m_op_ptr.setNull();
- D("itFirst [simple]");
- return true;
- }
- if (itFirst(it.m_opIterator)) {
- D("itFirst [first op]" << it);
- return true;
- }
- // empty op list is allowed, keep looking for simple phase
- }
- return false;
-}
-
-bool
-Dbdict::itLast(PhaseIterator& it)
-{
- D("itLast" << it);
- it.m_repeat = 0;
- const PhaseList& pl = it.m_phaseList;
- for (it.m_index = pl.m_count - 1; it.m_index != (Uint32)-1; it.m_index--) {
- const PhaseEntry& pe = pl.m_entry[it.m_index];
- if (pe.m_flags & PH_SIMPLE) {
- it.m_opIterator.m_op_ptr.setNull();
- D("itLast [simple]");
- return true;
- }
- if (itLast(it.m_opIterator)) {
- D("itLast [last op]" << it);
- return true;
- }
- // empty op list is allowed, keep looking for simple phase
- }
- return false;
-}
-
-bool
-Dbdict::itNext(PhaseIterator& it)
-{
- D("itNext" << it);
- it.m_repeat = 0;
- const PhaseList& pl = it.m_phaseList;
- bool loop_one = true;
- for (; it.m_index < pl.m_count; it.m_index++, loop_one = false) {
- const PhaseEntry& pe = pl.m_entry[it.m_index];
- if (loop_one) {
- if (pe.m_flags & PH_SIMPLE)
- continue;
- if (itExists(it.m_opIterator) && itNext(it.m_opIterator)) {
- D("itNext [next op]" << it);
- return true;
- }
- } else {
- if (pe.m_flags & PH_SIMPLE) {
- it.m_opIterator.m_op_ptr.setNull();
- D("itNext [simple]" << it);
- return true;
- }
- if (itFirst(it.m_opIterator)) {
- D("itNext [first op]" << it);
- return true;
- }
- }
- }
- D("itNext [end]" << it);
- return false;
-}
-
-bool
-Dbdict::itPrev(PhaseIterator& it)
-{
- D("itPrev" << it);
- it.m_repeat = 0;
- const PhaseList& pl = it.m_phaseList;
- bool loop_one = true;
- for (; it.m_index != (Uint32)-1; it.m_index--, loop_one = false) {
- const PhaseEntry& pe = pl.m_entry[it.m_index];
- if (loop_one) {
- if (pe.m_flags & PH_SIMPLE)
- continue;
- if (itPrev(it.m_opIterator)) {
- D("itPrev [prev op]" << it);
- return true;
- }
- } else {
- if (pe.m_flags & PH_SIMPLE) {
- it.m_opIterator.m_op_ptr.setNull();
- D("itPrev [simple]" << it);
- return true;
- }
- if (itLast(it.m_opIterator)) {
- D("itPrev [last op]" << it);
- return true;
- }
- }
- }
- D("itPrev [end]" << it);
- return false;
-}
-
-bool
-Dbdict::itRepeat(PhaseIterator& it)
-{
- if (itExists(it)) {
- it.m_repeat++;
- return true;
- }
- return false;
-}
-
-// phases
-
-void
-Dbdict::schemaTrans_dummy(Signal* signal, SchemaTransPtr trans_ptr)
-{
- jam();
- Uint32 itRepeat = getIteratorRepeat(trans_ptr);
-
- D("schemaTrans_dummy");
- ndbrequire(itRepeat == 0);
- schemaTrans_sendConf(signal, trans_ptr);
-}
-
-const Dbdict::PhaseEntry
-Dbdict::g_defaultPhaseEntry[] = {
- { SchemaTransImplReq::RT_PARSE, 0, 0, 0 },
-
- { SchemaTransImplReq::RT_PREPARE_BEGIN,
- PH_SIMPLE | PH_MASTER,
- &Dbdict::schemaTrans_dummy,
- &Dbdict::schemaTrans_dummy },
-
- { SchemaTransImplReq::RT_PREPARE, 0, 0, 0 },
-
- { SchemaTransImplReq::RT_PREPARE_END,
- PH_SIMPLE | PH_MASTER,
- &Dbdict::schemaTrans_dummy,
- &Dbdict::schemaTrans_dummy },
-
- { SchemaTransImplReq::RT_PREPARE_END,
- PH_SIMPLE | PH_MASTER,
- &Dbdict::schemaTrans_dummy,
- &Dbdict::schemaTrans_dummy },
-
- { SchemaTransImplReq::RT_COMMIT_BEGIN,
- PH_SIMPLE | PH_MASTER,
- &Dbdict::schemaTrans_dummy,
- &Dbdict::schemaTrans_dummy },
-
- { SchemaTransImplReq::RT_COMMIT, 0, 0, 0 },
-
- { SchemaTransImplReq::RT_COMMIT_BEGIN,
- PH_SIMPLE | PH_MASTER,
- &Dbdict::schemaTrans_dummy,
- &Dbdict::schemaTrans_dummy }
-};
-
-const Dbdict::PhaseList
-Dbdict::g_defaultPhaseList = {
- 0,
- g_defaultPhaseEntry,
- sizeof(g_defaultPhaseEntry) / sizeof(g_defaultPhaseEntry[0])
-};
-
// DICT as schema trans client
bool
@@ -19541,13 +19453,13 @@
{
Dbdict* dict = (Dbdict*)globalData.getBlock(DBDICT);
Dbdict::OpList a_copy = *this;
- Dbdict::OpIterator it(a_copy);
+ LocalDLFifoList<SchemaOp> list(dict->c_schemaOpPool, a_copy.m_head);
+ Dbdict::SchemaOpPtr op_ptr;
out << " (OpList";
Uint32 depth = 0;
out << " [";
- dict->itFirst(it);
- while (dict->itExists(it)) {
- Dbdict::SchemaOpPtr op_ptr = dict->itGetPtr(it);
+ list.first(op_ptr);
+ while (!op_ptr.isNull()) {
if (op_ptr.p->m_opDepth > depth) {
assert(op_ptr.p->m_opDepth > depth);
out << " [";
@@ -19560,7 +19472,7 @@
const Dbdict::OpInfo& info = dict->getOpInfo(op_ptr);
out << " " << dec << op_ptr.p->op_key << "-" << info.m_opType;
depth = op_ptr.p->m_opDepth;
- dict->itNext(it);
+ list.next(op_ptr);
}
while (depth != 0) {
out << "]";
@@ -19571,44 +19483,67 @@
}
NdbOut&
-operator<<(NdbOut& out, const Dbdict::SchemaTrans& a)
+operator<<(NdbOut& out, const Dbdict::TransLoc& a)
{
a.print(out);
return out;
}
void
-Dbdict::SchemaTrans::print(NdbOut& out) const
+Dbdict::TransLoc::print(NdbOut& out) const
{
- out << " (SchemaTrans";
- out << dec << V(trans_key);
- out << dec << V(m_isMaster);
- out << hex << V(m_clientRef);
- out << hex << V(m_transId);
- out << dec << V(m_requestType);
- out << dec << V(m_abortMode);
- out << hex << V(m_iteratorInfo);
+ out << " (TransLoc";
+ out << dec << V(m_mode)
+ << " [" << SchemaTransImplReq::modeName(m_mode) << "]";
+ out << dec << V(m_phaseIndex);
+ out << dec << V(m_phase)
+ << " [" << SchemaTransImplReq::phaseName(m_phase) << "]";
+ out << dec << V(m_subphase)
+ << " [" << SchemaTransImplReq::subphaseName(m_subphase) << "]";
+ out << dec << V(m_repeat);
+ out << dec << V(op_key);
out << ")";
}
NdbOut&
-operator<<(NdbOut& out, const Dbdict::PhaseIterator& a)
+operator<<(NdbOut& out, const Dbdict::SchemaTrans& a)
{
a.print(out);
return out;
}
void
-Dbdict::PhaseIterator::print(NdbOut& out) const
+Dbdict::SchemaTrans::print(NdbOut& out) const
{
- const Dbdict::PhaseList& pl = m_phaseList;
- const Dbdict::PhaseEntry& pe = pl.m_entry[m_index];
- const Dbdict::SchemaOpPtr op_ptr = m_opIterator.m_op_ptr;
- out << " (PhaseIterator";
- out << dec << V(m_index);
- out << dec << V(pe.m_requestType);
- if (!op_ptr.isNull())
- out << *op_ptr.p;
+ out << " (SchemaTrans";
+ out << dec << V(trans_key);
+ out << dec << V(m_isMaster);
+ out << hex << V(m_clientRef);
+ out << hex << V(m_transId);
+ out << " State";
+ Uint32 i;
+ for (i = 1; i < MAX_NDB_NODES; i++) {
+ if (m_initNodes.get(i)) {
+ out << dec << " " << i << ":";
+ TransState::Value state = m_transGlob[i].state();
+ if (state == TransState::Ok)
+ out << "Ok";
+ else if (state == TransState::Error)
+ out << "Error";
+ else if (state == TransState::NodeFail)
+ out << "NoNodeFail";
+ else if (state == TransState::NeedTrans)
+ out << "Needtrans";
+ else if (state == TransState::NoTrans)
+ out << "NoTrans";
+ else if (state == TransState::NeedOp)
+ out << "NeedOp";
+ else if (state == TransState::NoOp)
+ out << "NoOp";
+ else
+ out << (Uint32)state << "?";
+ }
+ }
out << ")";
}
--- 1.95/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2007-05-01 12:36:26 +02:00
+++ 1.96/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2007-05-20 16:50:14 +02:00
@@ -1213,10 +1213,8 @@
struct SchemaOp;
struct SchemaTrans;
- struct PhaseIterator;
typedef Ptr<SchemaOp> SchemaOpPtr;
typedef Ptr<SchemaTrans> SchemaTransPtr;
- typedef Ptr<PhaseIterator> PhaseIteratorPtr;
// ErrorInfo
@@ -1434,7 +1432,7 @@
m_sections = 0;
m_callback.m_callbackFunction = 0;
m_callback.m_callbackData = 0;
- m_opIndex = ~(Uint32)0;
+ m_opIndex = ZNIL;
m_opDepth = 0;
m_aux_op_ptr.setNull();
m_org_op_ptr.setNull();
@@ -1600,6 +1598,168 @@
#endif
};
+ // transaction phases and state
+
+ struct TransMode {
+ enum Value {
+ Undef = 0,
+ Normal, // normal run
+ Abort, // error detected in current step
+ Aborting // normal abort run
+ };
+ };
+
+ struct TransPhase {
+ enum Value {
+ Undef = 0,
+ Begin,
+ Parse,
+ Prepare,
+ Commit,
+ Complete,
+ End
+ };
+ };
+
+ // phase can be divided in up to 3 phases
+ struct TransSubphase {
+ enum Value {
+ Undef = 0,
+ Pre,
+ Main,
+ Post
+ };
+ };
+
+ struct TransPhasetype {
+ enum {
+ Master = (1 << 0), // no-op on slave participant
+ Simple = (1 << 1) // not iterated over operations
+ };
+ };
+
+ struct TransPhaseEntry {
+ TransPhase::Value m_phase;
+ TransSubphase::Value m_subphase;
+ Uint32 m_phasetype;
+ // for simple phase
+ void (Dbdict::*m_run)(Signal*, SchemaTransPtr);
+ void (Dbdict::*m_abort)(Signal*, SchemaTransPtr);
+ };
+
+ struct TransPhaseList {
+ Uint32 m_id; // list id to send between nodes
+ Uint32 m_length;
+ const TransPhaseEntry* const m_phaseEntry;
+ };
+
+ // default (and only) phase array
+ static const TransPhaseEntry g_defaultPhaseEntry[];
+ static const TransPhaseList g_defaultPhaseList;
+
+ /*
+ * Local transaction state contains current run location.
+ * Iteration is on 3 levels:
+ *
+ * - phases and subphases
+ * - operations, if not simple phase
+ * - repeat executions of same operation or simple phase
+ *
+ * Initial phases are Begin and Parse which builds up
+ * operation list and final phase is End. These phases
+ * have special hardwired semantics.
+ *
+ * Abort mode reverses iterator direction. The steps done
+ * so far are executed backwards.
+ *
+ * Slaves have no iteration logic but instead copy master
+ * local state on each round.
+ */
+ struct TransLoc {
+ const TransPhaseList* m_phaseList;
+ OpList m_opList;
+ TransMode::Value m_mode;
+ // index into phase list
+ Uint32 m_phaseIndex;
+ // these match current phase entry
+ TransPhase::Value m_phase;
+ TransSubphase::Value m_subphase;
+ Uint32 m_repeat;
+ Uint32 op_key;
+ TransLoc () {
+ m_mode = TransMode::Undef,
+ m_phaseIndex = 0;
+ m_phase = TransPhase::Undef,
+ m_subphase = TransSubphase::Undef,
+ m_repeat = 0;
+ op_key = 0;
+ }
+#ifdef VM_TRACE
+ void print(NdbOut&) const;
+#endif
+ };
+
+ bool getOpPtr(const TransLoc&, SchemaOpPtr&);
+ const TransPhaseEntry& getPhaseEntry(const TransLoc&);
+
+ void iteratorAddOp(TransLoc&, SchemaOpPtr);
+ bool iteratorFirstOp(TransLoc&, int dir);
+ bool iteratorNextOp(TransLoc&, int dir);
+ bool iteratorFirst(TransLoc&, int dir);
+ bool iteratorNext(TransLoc&, int dir);
+ bool iteratorInit(TransLoc&);
+ bool iteratorMove(TransLoc&, bool repeatFlag);
+ void iteratorCopy(TransLoc&, Uint32 mode,
+ Uint32 phaseIndex, Uint32 op_key, Uint32 repeat);
+
+ // global state
+ struct TransState {
+ enum Value {
+ Undef = 0,
+ Ok,
+ Error,
+ NodeFail,
+ /*
+ * Handle cases where slave has no free record.
+ * Should not happen on correctly configured nodes.
+ */
+ NeedTrans,
+ NoTrans,
+ NeedOp,
+ NoOp,
+ // end valid values
+ End
+ };
+ };
+
+ // global state of each node tracked by coordinator only
+ struct TransGlob {
+ // pack TransState::Value
+ Uint8 m_state;
+ TransGlob() {
+ m_state = TransState::Undef;
+ }
+ TransState::Value state() const {
+ return (TransState::Value)m_state;
+ }
+ void state(TransState::Value state) {
+ assert(state > 0 && state < TransState::End);
+ m_state = (Uint8)state;
+ }
+ };
+
+ void setGlobState(SchemaTransPtr,
+ Uint32 nodeId, TransState::Value state);
+ void setGlobState(SchemaTransPtr,
+ const NdbNodeBitmask&, TransState::Value state);
+ void setGlobState(SchemaTransPtr,
+ TransState::Value oldstate, TransState::Value state);
+ bool hasGlobState(SchemaTransPtr,
+ Uint32 nodeId, TransState::Value state);
+
+ // a dummy simple phase
+ void schemaTrans_dummy(Signal*, SchemaTransPtr);
+
// SchemaTrans
struct SchemaTrans {
@@ -1624,31 +1784,19 @@
Uint32 m_transId;
Uint32 m_requestInfo; // global flags are passed to each op
- Uint32 m_requestType;
+ // local and global transaction state
+ TransLoc m_transLoc;
+ TransGlob m_transGlob[MAX_NDB_NODES];
+
NdbNodeBitmask m_initNodes;
- NdbNodeBitmask m_deadNodes;
- // nodes which have not yet seized current trans/op
- NdbNodeBitmask m_skipNodes;
SafeCounterHandle m_counter;
// operation depth during parse (increased for sub-ops)
Uint32 m_opDepth;
- // list of schema ops under this tx
- OpList m_opList;
-
- // iterator for all phases
- PhaseIteratorPtr m_iterator_ptr;
-
- // 0-no abort 1-error at current step 2-aborting
- Uint32 m_abortMode;
-
// client REQ signal to distinguish some cases
Uint32 m_clientGsn;
- // iterator info in master, slave, internal signal
- Uint32 m_iteratorInfo;
-
// temporarily holds iterator flags received
Uint32 m_recvItFlags;
@@ -1667,15 +1815,9 @@
m_clientRef = 0;
m_transId = 0;
m_requestInfo = 0;
- m_requestType = 0;
m_initNodes.clear(); // ctor does too
- m_deadNodes.clear();
- m_skipNodes.clear();
m_opDepth = 0;
- m_iterator_ptr.setNull();
- m_abortMode = 0;
m_clientGsn = 0;
- m_iteratorInfo = 0;
m_recvItFlags = 0;
m_callback.m_callbackFunction = 0;
m_callback.m_callbackData = 0;
@@ -1699,7 +1841,6 @@
bool findSchemaTrans(SchemaTransPtr&, Uint32 trans_key);
void releaseSchemaTrans(SchemaTransPtr&);
- PhaseIterator& getIterator(SchemaTransPtr trans_ptr);
Uint32 getIteratorRepeat(SchemaTransPtr trans_ptr);
// coordinator
@@ -1709,14 +1850,13 @@
void schemaTrans_handleReply(Signal*, SchemaTransPtr);
void createSubOps(Signal*, SchemaOpPtr, bool first = false);
void abortSubOps(Signal*, SchemaOpPtr, ErrorInfo);
- bool stepSchemaTrans(Signal*, SchemaTransPtr);
void runSchemaTrans(Signal*, SchemaTransPtr);
void abortSchemaTrans(Signal*, SchemaTransPtr);
// participant
void schemaTrans_recvReq(Signal*);
void schemaTrans_recvParseReq(Signal*, SchemaTransPtr,
- Uint32 op_key, Uint32 gsn);
+ Uint32 op_key, const OpInfo& info);
void runSchemaOp(Signal*, SchemaTransPtr);
void schemaTrans_sendConf(Signal*, SchemaOpPtr, Uint32 itFlags = 0);
void schemaTrans_sendConf(Signal*, SchemaTransPtr, Uint32 itFlags = 0);
@@ -1726,113 +1866,6 @@
// reply to client
void schemaTrans_reply(Signal*, SchemaTransPtr);
- // PhaseList
-
- enum PhaseFlag {
- PH_SIMPLE = (1 << 0), // not iterated over ops, calls m_simple
- PH_MASTER = (1 << 1) // not run on slaves (is sent though)
- };
-
- struct PhaseEntry {
- SchemaTransImplReq::RequestType m_requestType;
- Uint32 m_flags;
- void (Dbdict::*m_simple)(Signal*, SchemaTransPtr);
- void (Dbdict::*m_abort)(Signal*, SchemaTransPtr);
- };
-
- struct PhaseList {
- Uint32 m_listId;
- const PhaseEntry* const m_entry;
- const Uint32 m_count;
- };
-
- // OpIterator
-
- struct OpIterator {
- OpList& m_opList;
- SchemaOpPtr m_op_ptr;
- OpIterator(OpList& opList) :
- m_opList(opList) {
- m_op_ptr.setNull();
- }
- };
-
- SchemaOpPtr itGetPtr(const OpIterator&);
- void itAddLast(OpIterator&, SchemaOpPtr);
- void itAddBeforeLast(OpIterator&, SchemaOpPtr);
- bool itExists(const OpIterator&);
- bool itFirst(OpIterator&);
- bool itLast(OpIterator&);
- bool itNext(OpIterator&);
- bool itPrev(OpIterator&);
- bool itHasNext(OpIterator&);
- bool itHasPrev(OpIterator&);
-
- /*
- * PhaseIterator
- *
- * Iterates on 3 levels: 1) phases 2) operations of non-simple
- * phase 3) repeated executions of same operation or simple phase.
- *
- * First phase (in the normal, and only, use-case) is PARSE. This
- * builds up operation list. The iterator stays on the last op
- * added. At execute it advances to first execution phase.
- *
- * Abort mode runs the iterator backwards. In particular there
- * are separate abort-prepare and abort-parse phases. The repeat
- * count is local to the step and is discarded between steps.
- *
- * The iterator is kept at same position on all nodes (it can be off
- * by one after master-NF). The position is described by:
- *
- * 0. phase list id (only one list with id 0 now)
- * 1. phase list index (index of PhaseEntry in phase list)
- * 2. operation index in non-simple phase (verified by op_key)
- * 3. operation or simple phase repeat count
- * 4. flags for each round
- *
- * These are sent in each SCHEMA_TRANS_IMPL_REQ.
- */
-
- struct PhaseIterator {
- // ArrayPool
- Uint32 nextPool;
-
- const PhaseList m_phaseList;
- Uint32 m_index;
- OpIterator m_opIterator;
-
- // repeat count of current step
- Uint32 m_repeat;
-
- PhaseIterator(const PhaseList& phaseList, OpList& opList) :
- m_phaseList(phaseList),
- m_opIterator(opList) {
- m_index = 0;
- m_repeat = 0;
- }
-#ifdef VM_TRACE
- void print(NdbOut&) const;
-#endif
- };
-
- ArrayPool<PhaseIterator> c_phaseIteratorPool;
-
- SchemaOpPtr itGetPtr(const PhaseIterator&);
- bool itExists(const PhaseIterator&);
- bool itFirst(PhaseIterator&);
- bool itLast(PhaseIterator&);
- bool itNext(PhaseIterator&);
- bool itPrev(PhaseIterator&);
- bool itRepeat(PhaseIterator&);
-
- // a dummy simple phase
- void schemaTrans_dummy(Signal*, SchemaTransPtr);
-
- // default (and only) phase list
- static const PhaseEntry g_defaultPhaseEntry[];
- static const PhaseList g_defaultPhaseList;
-
// common code for different op types
// client REQ starts with find trans and add op record
@@ -1873,6 +1906,21 @@
break;
}
+ TransLoc& tLoc = trans_ptr.p->m_transLoc;
+
+ if (tLoc.m_phase != TransPhase::Begin &&
+ tLoc.m_phase != TransPhase::Parse) {
+ jam();
+ setError(error, SchemaTransImplRef::InvalidTransState, __LINE__);
+ break;
+ }
+
+ // switch to parse phase on first op
+ if (tLoc.m_phase == TransPhase::Begin) {
+ jam();
+ iteratorMove(tLoc, false);
+ }
+
// set requestInfo before addSchemaOp
op_ptr.p->m_requestInfo = requestInfo;
addSchemaOp(trans_ptr, op_ptr);
@@ -1881,12 +1929,13 @@
op_ptr.p->m_clientRef = req->clientRef;
op_ptr.p->m_clientData = req->clientData;
- // nodes which have not seized op record
- trans_ptr.p->m_skipNodes = trans_ptr.p->m_initNodes;
- trans_ptr.p->m_skipNodes.clear(getOwnNodeId());
+ const Uint32 ownNodeId = getOwnNodeId();
+ ndbrequire(hasGlobState(trans_ptr, ownNodeId, TransState::Ok));
- // switch to parse phase wl3600_todo do it somewhere else
- trans_ptr.p->m_requestType = SchemaTransImplReq::RT_PARSE;
+ // other nodes have no op record yet
+ NdbNodeBitmask nodes = trans_ptr.p->m_initNodes;
+ nodes.clear(ownNodeId);
+ setGlobState(trans_ptr, nodes, TransState::NeedOp);
} while (0);
}
@@ -3336,8 +3385,8 @@
friend NdbOut& operator<<(NdbOut& out, const ErrorInfo&);
friend NdbOut& operator<<(NdbOut& out, const SchemaOp&);
friend NdbOut& operator<<(NdbOut& out, const OpList&);
+ friend NdbOut& operator<<(NdbOut& out, const TransLoc&);
friend NdbOut& operator<<(NdbOut& out, const SchemaTrans&);
- friend NdbOut& operator<<(NdbOut& out, const PhaseIterator&);
friend NdbOut& operator<<(NdbOut& out, const CreateTableData&);
friend NdbOut& operator<<(NdbOut& out, const AlterTableData&);
friend NdbOut& operator<<(NdbOut& out, const DropTableData&);
--- 1.165/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2007-02-25 12:54:00 +01:00
+++ 1.166/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2007-05-20 16:50:14 +02:00
@@ -616,14 +616,14 @@
{
DBUG_PRINT("info",("m_tablespace_id %d != %d",m_tablespace_id,
obj.m_tablespace_id));
- DBUG_RETURN(false);
+ //DBUG_RETURN(false); // wl3600_todo
}
if(m_tablespace_version != obj.m_tablespace_version)
{
DBUG_PRINT("info",("m_tablespace_version %d != %d",m_tablespace_version,
obj.m_tablespace_version));
- DBUG_RETURN(false);
+ //DBUG_RETURN(false); // wl3600_todo
}
if(m_id != obj.m_id)
--- 1.41/storage/ndb/test/ndbapi/testDict.cpp 2007-03-09 21:34:14 +01:00
+++ 1.42/storage/ndb/test/ndbapi/testDict.cpp 2007-05-20 16:50:14 +02:00
@@ -2143,13 +2143,336 @@
return result;
}
+#define chk1(x) \
+ do { \
+ if (x) break; \
+ g_err << "FAIL " << __LINE__ << " " << #x << endl; \
+ goto err; \
+ } while (0)
+
+#define chk2(x, e) \
+ do { \
+ if (x) break; \
+ g_err << "FAIL " << __LINE__ << " " #x << ": " << e << endl; \
+ goto err; \
+ } while (0)
+
+static uint
+urandom(uint m)
+{
+ uint n = myRandom48(1 << 16);
+ return n % m;
+}
+
+struct ErrIns {
+ const uint errValue;
+ const uint errCode;
+ const bool onMaster;
+ int nodeId;
+};
+
+NdbOut&
+operator<<(NdbOut& out, const ErrIns& errIns)
+{
+ out << "errValue=" << errIns.errValue;
+ out << " errCode=" << errIns.errCode;
+ out << " onMaster=" << errIns.onMaster;
+ out << " nodeId=" << errIns.nodeId;
+ return out;
+}
+
+static bool
+hasErrIns(const ErrIns& errIns)
+{
+ return errIns.errValue != 0;
+}
+
+static int
+doErrIns(ErrIns& errIns, NdbRestarter& restarter)
+{
+ if (hasErrIns(errIns)) {
+ int nodeId = 0;
+ if (errIns.onMaster || restarter.getNumDbNodes() < 2) {
+ nodeId = restarter.getMasterNodeId();
+ } else {
+ uint rand = urandom(restarter.getNumDbNodes());
+ nodeId = restarter.getRandomNotMasterNodeId(rand);
+ }
+ errIns.nodeId = nodeId;
+ g_info << "errIns: " << errIns << endl;
+ if (restarter.insertErrorInNode(nodeId, errIns.errValue) != 0) {
+ g_err << "errIns failed: " << errIns << endl;
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int
+chkErrIns(ErrIns& errIns, const NdbError& ndbError)
+{
+ if (hasErrIns(errIns)) {
+ if (errIns.errCode == 0) {
+ if (ndbError.code != 0) {
+ g_err << "errIns expected no error: "
+ << errIns << " " << ndbError << endl;
+ return -1;
+ }
+ } else {
+ if (ndbError.code == 0) {
+ g_err << "errIns had no effect : "
+ << errIns << endl;
+ return -1;
+ }
+ if (errIns.errCode != ndbError.code) {
+ g_err << "errIns got wrong error code: "
+ << errIns << " " << ndbError << endl;
+ return -1;
+ }
+ }
+ } else {
+ if (ndbError.code != 0) {
+ g_err << "errIns not done but got error: "
+ << ndbError << endl;
+ return -1;
+ }
+ }
+ return 0;
+}
+
int
-runSchemaTrans(NDBT_Context* ctx, NDBT_Step* step)
+runSchemaTrans_empty(NDBT_Context* ctx, NDBT_Step* step)
{
+ g_err << "runSchemaTrans_empty" << endl;
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
+ const int loops = ctx->getNumLoops();
+ g_info << "loops " << loops << endl;
+ int loop;
+ for (loop = 0; loop < loops; loop++) {
+ g_info << "loop " << loop << endl;
+ chk1(pDic->hasSchemaTrans() == false);
+ chk2(pDic->beginSchemaTrans() != -1, pDic->getNdbError());
+ chk1(pDic->hasSchemaTrans() == true);
+ if (loop % 2 == 0)
+ chk2(pDic->endSchemaTrans(true) != -1, pDic->getNdbError());
+ else
+ chk2(pDic->endSchemaTrans(false) != -1, pDic->getNdbError());
+ }
+ return NDBT_OK;
+err:
+ return NDBT_FAILED;
+}
+
+int
+runSchemaTrans_emptyErrIns(NDBT_Context* ctx, NDBT_Step* step)
+{
+ g_err << "runSchemaTrans_emptyErrIns" << endl;
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
NdbRestarter restarter;
+ ErrIns errInsList[] = {
+ {6101,780,1,0}, {6101,780,0,0}, {0,0,0,0}
+ };
+ const uint errInsLen = sizeof(errInsList)/sizeof(errInsList[0]);
+ const int loops = ctx->getNumLoops();
+ g_info << "loops " << loops << endl;
+ int loop;
+ for (loop = 0; loop < loops; loop++) {
+ g_info << "loop " << loop << endl;
+ uint rand = urandom(errInsLen);
+ ErrIns& errIns = errInsList[rand % errInsLen];
+ chk1(doErrIns(errIns, restarter) == 0);
+ pDic->beginSchemaTrans();
+ chk1(chkErrIns(errIns, pDic->getNdbError()) == 0);
+ if (!hasErrIns(errIns)) {
+ chk1(pDic->hasSchemaTrans() == true);
+ if (loop % 2 == 0)
+ chk2(pDic->endSchemaTrans(true) != -1, pDic->getNdbError());
+ else
+ chk2(pDic->endSchemaTrans(false) != -1, pDic->getNdbError());
+ }
+ }
+ return NDBT_OK;
+err:
+ return NDBT_FAILED;
+}
+
+int
+runSchemaTrans_table(NDBT_Context* ctx, NDBT_Step* step)
+{
+ g_err << "runSchemaTrans_table" << endl;
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
+ const int loops = ctx->getNumLoops();
+ g_info << "loops " << loops << endl;
+ int loop;
+ for (loop = 0; loop < loops; loop++) {
+ g_info << "loop " << loop << endl;
+ const NdbDictionary::Table* pTab = ctx->getTab();
+ char tabName[200];
+ strcpy(tabName, pTab->getName());
+ chk2(pDic->createTable(*pTab) == 0, pDic->getNdbError());
+ g_info << "created" << endl;
+ const NdbDictionary::Table* pTab2 = pDic->getTable(tabName);
+ chk2(pTab2 != 0, pDic->getNdbError());
+ chk1(pTab->equal(*pTab2) == true);
+ g_info << "create verified" << endl;
+ if (loop % 2 == 1) {
+ int i;
+ for (i = 0; i < 3; i++) {
+ g_info << "try duplicate create" << endl;
+ chk1(pDic->createTable(*pTab) == -1);
+ chk2(pDic->getNdbError().code == 721, pDic->getNdbError());
+ g_info << "duplicate create verified" << endl;
+ }
+ }
+ chk2(pDic->dropTable(tabName) == 0, pDic->getNdbError());
+ g_info << "dropped" << endl;
+ chk1(pDic->getTable(tabName) == 0);
+ chk2(pDic->getNdbError().code == 723, pDic->getNdbError());
+ g_info << "drop verified" << endl;
+ if (loop % 2 == 1) {
+ int i;
+ for (i = 0; i < 3; i++) {
+ g_info << "try duplicate drop" << endl;
+ chk1(pDic->dropTable(tabName) == -1);
+ chk2(pDic->getNdbError().code == 723, pDic->getNdbError());
+ g_info << "duplicate drop verified" << endl;
+ }
+ }
+ }
+ return NDBT_OK;
+err:
+ return NDBT_FAILED;
+}
+
+int
+runSchemaTrans_tableErrIns(NDBT_Context* ctx, NDBT_Step* step)
+{
+ g_err << "runSchemaTrans_tableErrIns" << endl;
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
+ NdbRestarter restarter;
+ ErrIns errInsList[] = {
+ {6111,783,1,0}, {6111,783,0,0}, {0,0,0,0},
+ {6112,9999,1,0}, {6112,9999,0,0}, {0,0,0,0},
+ {6113,9999,1,0}, {6113,9999,0,0}, {0,0,0,0}
+ };
+ const uint errInsLen = sizeof(errInsList)/sizeof(errInsList[0]);
const int loops = ctx->getNumLoops();
+ g_info << "loops " << loops << endl;
+ int loop;
+ for (loop = 0; loop < loops; loop++) {
+ g_info << "loop " << loop << endl;
+ const NdbDictionary::Table* pTab = ctx->getTab();
+ char tabName[200];
+ strcpy(tabName, pTab->getName());
+ uint rand = urandom(errInsLen);
+ ErrIns& errIns = errInsList[rand % errInsLen];
+ chk1(doErrIns(errIns, restarter) == 0);
+ pDic->createTable(*pTab);
+ chk1(chkErrIns(errIns, pDic->getNdbError()) == 0);
+ if (!hasErrIns(errIns)) {
+ g_info << "created" << endl;
+ const NdbDictionary::Table* pTab2 = pDic->getTable(tabName);
+ chk2(pTab2 != 0, pDic->getNdbError());
+ chk1(pTab->equal(*pTab2) == true);
+ g_info << "create verified" << endl;
+ chk2(pDic->dropTable(tabName) == 0, pDic->getNdbError());
+ g_info << "dropped" << endl;
+ chk1(pDic->getTable(tabName) == 0);
+ chk2(pDic->getNdbError().code == 723, pDic->getNdbError());
+ g_info << "drop verified" << endl;
+ }
+ }
+ return NDBT_OK;
+err:
+ return NDBT_FAILED;
+}
+
+int
+runSchemaTrans_index(NDBT_Context* ctx, NDBT_Step* step)
+{
+ return NDBT_OK;
+err:
+ return NDBT_FAILED;
+}
+
+int
+runSchemaTrans_indexErrIns(NDBT_Context* ctx, NDBT_Step* step)
+{
+ return NDBT_OK;
+err:
+ return NDBT_FAILED;
+}
+
+struct SubTest {
+ Uint32 key;
+ int (*run)(NDBT_Context* ctx, NDBT_Step* step);
+};
+
+int
+runSchemaTrans_dropAll(NDBT_Context* ctx, NDBT_Step* step)
+{
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
+ int numTables = NDBT_Tables::getNumTables();
+ int num;
+ for (num = 0; num < numTables; num++) {
+ const NdbDictionary::Table* pTab = NDBT_Tables::getTable(num);
+ char tabName[200];
+ strcpy(tabName, pTab->getName());
+ if (pDic->getTable(tabName)) {
+ chk2(pDic->dropTable(tabName) == 0, pDic->getNdbError());
+ }
+ }
+ return NDBT_OK;
+err:
+ return NDBT_FAILED;
+}
+
+int
+runSchemaTrans(NDBT_Context* ctx, NDBT_Step* step)
+{
+ const SubTest subTestList[] = {
+ { 1, runSchemaTrans_empty },
+ { 1, runSchemaTrans_emptyErrIns },
+ { 2, runSchemaTrans_table },
+ { 2, runSchemaTrans_tableErrIns },
+ { 3, runSchemaTrans_index },
+ { 3, runSchemaTrans_indexErrIns }
+ };
+ const Uint32 subTestLen = sizeof(subTestList)/sizeof(subTestList[0]);
+
+ //DBUG_PUSH("d:t:L:F:o,zz.log");
+ chk1(runSchemaTrans_dropAll(ctx, step) == NDBT_OK);
+
+ {
+ const int loops = ctx->getNumLoops();
+ int loop = 0;
+ Uint32 subTestKey = ctx->getProperty("SubTestKey");
+ while (loop < loops) {
+ uint index = 0;
+ while (index < subTestLen) {
+ const SubTest& subTest = subTestList[index];
+ if (subTestKey == 0 || subTestKey == subTest.key) {
+ chk1((*subTest.run)(ctx, step) == NDBT_OK);
+ }
+ index++;
+ }
+ loop++;
+ }
+ }
+ return NDBT_OK;
+err:
+ return NDBT_FAILED;
+
+#ifdef notdef
+ int l;
+ NdbRestarter restarter;
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
const bool standalone = ctx->getProperty("Standalone");
const bool errIns = ctx->getProperty("ErrIns");
const bool noAbort = ctx->getProperty("NoAbort");
@@ -2176,7 +2499,6 @@
}
}
- int l = 0;
int nodeId = 0;
int ret = NDBT_FAILED;
@@ -2209,31 +2531,6 @@
g_info << "opt " << opt << endl;
g_info << "begin trans" << endl;
- if (errIns) {
- int i;
- for (i = 0; i < 2; i++) {
- nodeId = restarter.getMasterNodeId();
- if (i % 2 != 0 && numDbNodes > 1) {
- int rand = myRandom48(numDbNodes);
- nodeId = restarter.getRandomNotMasterNodeId(rand);
- }
- g_info << "errins 6101 nodeId=" << nodeId << endl;
- if (restarter.insertErrorInNode(nodeId, 6101) != 0) {
- g_err << "errins 6101 nodeId=" << nodeId << " failed" << endl;
- goto out;
- }
- if (pDic->beginSchemaTrans() == 0) {
- g_err << "beginSchemaTrans errins 6101 nodeId=" << nodeId
- << " no error" << endl;
- goto out;
- }
- if (pDic->getNdbError().code != tooManySchemaTrans) {
- g_err << "beginSchemaTrans errins 6101 nodeId=" << nodeId
- << " unexpected error: " << pDic->getNdbError() << endl;
- goto out;
- }
- }
- }
if (pDic->beginSchemaTrans() == -1) {
const NdbError err = pDic->getNdbError();
g_err << "begin trans: " << err << endl;
@@ -2377,6 +2674,7 @@
out:
delete [] tabInfo;
return ret;
+#endif
}
@@ -2526,37 +2824,23 @@
STEP(runRestarts);
STEP(runDictOps);
}
-TESTCASE("SchemaTrans_0",
- "Empty schema transactions with commit/abort"
- " and error inserts"){
- TC_PROPERTY("Standalone", 1);
- TC_PROPERTY("ErrIns", 1);
- TC_PROPERTY("NumberOfTables", (Uint32)0);
+TESTCASE("SchemaTrans",
+ "schema transactions full test"){
STEP(runSchemaTrans);
}
TESTCASE("SchemaTrans_1",
- "Schema transactions with create/drop tables commit"){
- TC_PROPERTY("Standalone", 1);
- TC_PROPERTY("NoAbort", 1);
+ "schema transactions: empty transactions"){
+ TC_PROPERTY("SubTestKey", 1);
STEP(runSchemaTrans);
}
TESTCASE("SchemaTrans_2",
- "Schema transactions with create/drop tables commit/abort"){
- TC_PROPERTY("Standalone", 1);
+ "schema transactions: table"){
+ TC_PROPERTY("SubTestKey", 2);
STEP(runSchemaTrans);
}
TESTCASE("SchemaTrans_3",
- "Schema transactions with create/drop tables commit/abort"
- " and error inserts"){
- TC_PROPERTY("Standalone", 1);
- TC_PROPERTY("ErrIns", 1);
- STEP(runSchemaTrans);
-}
-TESTCASE("SchemaTrans_NF",
- "Schema transactions under slave NF"){
- TC_PROPERTY("Restart_NF_ops", 1);
- TC_PROPERTY("Restart_NR_ops", 1);
- STEP(runRestarts);
+ "schema transactions: table with indexes"){
+ TC_PROPERTY("SubTestKey", 3);
STEP(runSchemaTrans);
}
--- 1.10/storage/ndb/test/tools/create_index.cpp 2005-04-08 02:44:33 +02:00
+++ 1.11/storage/ndb/test/tools/create_index.cpp 2007-05-20 16:50:14 +02:00
@@ -99,13 +99,13 @@
}
ndbout << "creating index " << buf << " on table " << argv[i] << "...";
const int res = dict->createIndex(ind);
- if(res != 0)
+ if(res != 0) {
ndbout << endl << dict->getNdbError() << endl;
+ return NDBT_ProgramExit(NDBT_FAILED);
+ }
else
ndbout << "OK" << endl;
}
return NDBT_ProgramExit(NDBT_OK);
}
-
-
--- 1.10/storage/ndb/include/kernel/signaldata/SchemaTransImpl.hpp 2007-02-25 12:53:59 +01:00
+++ 1.11/storage/ndb/include/kernel/signaldata/SchemaTransImpl.hpp 2007-05-20 16:50:13 +02:00
@@ -22,51 +22,64 @@
#include "GlobalSignalNumbers.h"
struct SchemaTransImplReq {
- enum RequestType {
- RT_UNDEFINED = 0,
- RT_BEGIN = 1,
- RT_PARSE = 2,
- RT_PREPARE_BEGIN = 3,
- RT_PREPARE = 4,
- RT_PREPARE_END = 5,
- RT_COMMIT_BEGIN = 6,
- RT_COMMIT = 7,
- RT_COMMIT_END = 8,
- RT_END = 9
- };
-
enum IteratorFlag {
- IT_FIRST = (1 << 0),
- IT_REPEAT = (1 << 1),
- IT_HOLD = (1 << 2),
- IT_REVERSE = (1 << 3),
- IT_END = (1 << 4)
+ IT_REPEAT = (1 << 1)
};
STATIC_CONST( SignalLength = 8 );
Uint32 senderRef;
Uint32 transKey;
Uint32 opKey;
- Uint32 requestInfo; // request type | abort mode | flags
+ Uint32 requestInfo; // mode phase subphase | ... | flags
Uint32 operationInfo; // piggy-backed gsn | op depth
Uint32 iteratorInfo; // list id | list index | op index | repeat | flags
Uint32 clientRef;
Uint32 transId;
- // requestInfo (confirms to DictSignal format)
- static Uint32 getRequestType(const Uint32& info) {
- return BitmaskImpl::getField(1, &info, 0, 8);
+ // requestInfo confirms to DictSignal format
+ static Uint32 getMode(const Uint32& info) {
+ return BitmaskImpl::getField(1, &info, 0, 2);
+ }
+ static void setMode(Uint32& info, Uint32 val) {
+ assert(val < (1 << 2));
+ BitmaskImpl::setField(1, &info, 0, 2, val);
}
- static void setRequestType(Uint32& info, Uint32 val) {
- assert(val < (1 << 8));
- BitmaskImpl::setField(1, &info, 0, 8, val);
+ static Uint32 getPhase(const Uint32& info) {
+ return BitmaskImpl::getField(1, &info, 2, 4);
+ }
+ static void setPhase(Uint32& info, Uint32 val) {
+ assert(val < (1 << 4));
+ BitmaskImpl::setField(1, &info, 2, 4, val);
}
- static Uint32 getAbortMode(const Uint32& info) {
- return BitmaskImpl::getField(1, &info, 8, 8);
+ static Uint32 getSubphase(const Uint32& info) {
+ return BitmaskImpl::getField(1, &info, 6, 2);
}
- static void setAbortMode(Uint32& info, Uint32 val) {
- assert(val < (1 << 8));
- BitmaskImpl::setField(1, &info, 8, 8, val);
+ static void setSubphase(Uint32& info, Uint32 val) {
+ assert(val < (1 << 2));
+ BitmaskImpl::setField(1, &info, 6, 2, val);
+ }
+
+ // names come from Dict
+ static const char* modeName(Uint32 val) {
+ static char* name[] = {
+ "Undef", "Normal", "Abort", "Aborting"
+ };
+ Uint32 size = sizeof(name)/sizeof(name[0]);
+ return val < size ? name[val] : "?";
+ }
+ static const char* phaseName(Uint32 val) {
+ static char* name[] = {
+ "Undef", "Begin", "Parse", "Prepare", "Commit", "Complete", "End"
+ };
+ Uint32 size = sizeof(name)/sizeof(name[0]);
+ return val < size ? name[val] : "?";
+ }
+ static const char* subphaseName(Uint32 val) {
+ static char* name[] = {
+ "Undef", "Pre", "Main", "Post"
+ };
+ Uint32 size = sizeof(name)/sizeof(name[0]);
+ return val < size ? name[val] : "?";
}
// operation info
@@ -102,14 +115,10 @@
}
static Uint32 getOpIndex(const Uint32& info) {
Uint32 val = BitmaskImpl::getField(1, &info, 8, 16);
- if (val == (1 << 16) - 1)
- val = ~(Uint32)0;
return val;
}
static void setOpIndex(Uint32& info, Uint32 val) {
- assert(val < (1 << 16) -1 || val == ~(Uint32)0);
- if (val == ~(Uint32)0)
- val = (1 << 16) - 1;
+ assert(val < (1 << 16));
BitmaskImpl::setField(1, &info, 8, 16, val);
}
static Uint32 getItRepeat(const Uint32& info) {
@@ -126,14 +135,6 @@
assert(val < (1 << 4));
BitmaskImpl::setField(1, &info, 28, 4, val);
}
- static void addItFlags(Uint32& info, Uint32 val) {
- val = getItFlags(info) | val;
- setItFlags(info, val);
- }
- static void delItFlags(Uint32& info, Uint32 val) {
- val = getItFlags(info) & ~val;
- setItFlags(info, val);
- }
};
struct SchemaTransImplConf {
@@ -152,6 +153,7 @@
TooManySchemaTrans = 780,
InvalidTransKey = 781,
InvalidTransId = 782,
+ InvalidTransState = 785,
TooManySchemaOps = 783,
NF_FakeErrorREF = 1
};
--- 1.17/storage/ndb/src/common/debugger/signaldata/SchemaTransImpl.cpp 2007-03-15 14:56:38 +01:00
+++ 1.18/storage/ndb/src/common/debugger/signaldata/SchemaTransImpl.cpp 2007-05-20 16:50:13 +02:00
@@ -29,22 +29,10 @@
fprintf(output, " opKey: %u", sig->opKey);
fprintf(output, " requestInfo: %08x", sig->requestInfo);
fprintf(output, "\n");
- Uint32 requestType = SchemaTransImplReq::getRequestType(sig->requestInfo);
- Uint32 abortMode = SchemaTransImplReq::getAbortMode(sig->requestInfo);
+ Uint32 mode = SchemaTransImplReq::getMode(sig->requestInfo);
+ Uint32 phase = SchemaTransImplReq::getPhase(sig->requestInfo);
+ Uint32 subphase = SchemaTransImplReq::getSubphase(sig->requestInfo);
Uint32 requestFlags = DictSignal::getRequestFlags(sig->requestInfo);
- char requestTypeNoName[20];
- sprintf(requestTypeNoName, "%u", requestType);
- const char* requestTypeName =
- requestType == SchemaTransImplReq::RT_BEGIN ? "BEGIN" :
- requestType == SchemaTransImplReq::RT_PARSE ? "PARSE" :
- requestType == SchemaTransImplReq::RT_PREPARE_BEGIN ? "PREPARE_BEGIN" :
- requestType == SchemaTransImplReq::RT_PREPARE ? "PREPARE" :
- requestType == SchemaTransImplReq::RT_PREPARE_END ? "PREPARE_END" :
- requestType == SchemaTransImplReq::RT_COMMIT_BEGIN ? "COMMIT_BEGIN" :
- requestType == SchemaTransImplReq::RT_COMMIT ? "COMMIT" :
- requestType == SchemaTransImplReq::RT_COMMIT_END ? "COMMIT_END" :
- requestType == SchemaTransImplReq::RT_END ? "END" :
- requestTypeNoName;
Uint32 gsn = SchemaTransImplReq::getGsn(sig->operationInfo);
Uint32 opDepth = SchemaTransImplReq::getOpDepth(sig->operationInfo);
Uint32 listId = SchemaTransImplReq::getListId(sig->iteratorInfo);
@@ -52,21 +40,10 @@
Uint32 opIndex = SchemaTransImplReq::getOpIndex(sig->iteratorInfo);
Uint32 itRepeat = SchemaTransImplReq::getItRepeat(sig->iteratorInfo);
Uint32 itFlags = SchemaTransImplReq::getItFlags(sig->iteratorInfo);
- char itFlagsName[20];
- itFlagsName[0] = itFlagsName[1] = 0;
- if (itFlags & SchemaTransImplReq::IT_FIRST)
- strcat(itFlagsName, " FIRST");
- if (itFlags & SchemaTransImplReq::IT_REPEAT)
- strcat(itFlagsName, " REPEAT");
- if (itFlags & SchemaTransImplReq::IT_HOLD)
- strcat(itFlagsName, " HOLD");
- if (itFlags & SchemaTransImplReq::IT_REVERSE)
- strcat(itFlagsName, " REVERSE");
- if (itFlags & SchemaTransImplReq::IT_END)
- strcat(itFlagsName, " END");
- fprintf(output, " requestType: %u", requestType);
- fprintf(output, " abortMode: %u", abortMode);
- fprintf(output, " [%s%s]", requestTypeName, !abortMode ? "" : " ABORT");
+ fprintf(output, " mode: %u [%s] phase: %u [%s] subphase: %u [%s]",
+ mode, SchemaTransImplReq::modeName(mode),
+ phase, SchemaTransImplReq::phaseName(phase),
+ subphase, SchemaTransImplReq::subphaseName(subphase));
fprintf(output, "\n");
fprintf(output, " requestFlags: %x", requestFlags);
{
@@ -85,7 +62,7 @@
else
fprintf(output, " opIndex: NIL");
fprintf(output, " itRepeat: %u", itRepeat);
- fprintf(output, " itFlags: %x [%s]", itFlags, &itFlagsName[1]);
+ fprintf(output, " itFlags: %x", itFlags);
fprintf(output, "\n");
fprintf(output, " clientRef: %x", sig->clientRef);
fprintf(output, " transId: %x", sig->transId);
| Thread |
|---|
| • bk commit into 5.1 tree (pekka:1.2430) | pekka | 20 May |