ndb - bug#20683

  part 2 - handle safecounter.init() failing in all parts of event code
parent 87460788
......@@ -9476,7 +9476,14 @@ Dbdict::createEventComplete_RT_USER_GET(Signal* signal,
NodeReceiverGroup rg(DBDICT, c_aliveNodes);
RequestTracker & p = evntRecPtr.p->m_reqTracker;
p.init<CreateEvntRef>(c_counterMgr, rg, GSN_CREATE_EVNT_REF, evntRecPtr.i);
if (!p.init<CreateEvntRef>(c_counterMgr, rg, GSN_CREATE_EVNT_REF,
evntRecPtr.i))
{
jam();
evntRecPtr.p->m_errorCode = 701;
createEvent_sendReply(signal, evntRecPtr);
return;
}
sendSignal(rg, GSN_CREATE_EVNT_REQ, signal, CreateEvntReq::SignalLength, JBB);
}
......@@ -9764,8 +9771,12 @@ void Dbdict::execSUB_START_REQ(Signal* signal)
return;
}
OpSubEventPtr subbPtr;
Uint32 errCode = 0;
if (!c_opSubEvent.seize(subbPtr)) {
errCode = SubStartRef::Busy;
busy:
SubStartRef * ref = (SubStartRef *)signal->getDataPtrSend();
{ // fix
Uint32 subcriberRef = ((SubStartReq*)signal->getDataPtr())->subscriberRef;
ref->subscriberRef = subcriberRef;
......@@ -9775,7 +9786,7 @@ void Dbdict::execSUB_START_REQ(Signal* signal)
// ret->setErrorLine(__LINE__);
// ret->setErrorNode(reference());
ref->senderRef = reference();
ref->errorCode = SubStartRef::Busy;
ref->errorCode = errCode;
sendSignal(origSenderRef, GSN_SUB_START_REF, signal,
SubStartRef::SignalLength2, JBB);
......@@ -9798,7 +9809,12 @@ void Dbdict::execSUB_START_REQ(Signal* signal)
subbPtr.p->m_senderRef = origSenderRef; // not sure if API sets correctly
NodeReceiverGroup rg(DBDICT, c_aliveNodes);
RequestTracker & p = subbPtr.p->m_reqTracker;
p.init<SubStartRef>(c_counterMgr, rg, GSN_SUB_START_REF, subbPtr.i);
if (!p.init<SubStartRef>(c_counterMgr, rg, GSN_SUB_START_REF, subbPtr.i))
{
c_opSubEvent.release(subbPtr);
errCode = SubStartRef::Busy;
goto busy;
}
SubStartReq* req = (SubStartReq*) signal->getDataPtrSend();
......@@ -9988,14 +10004,17 @@ void Dbdict::execSUB_STOP_REQ(Signal* signal)
return;
}
OpSubEventPtr subbPtr;
Uint32 errCode = 0;
if (!c_opSubEvent.seize(subbPtr)) {
errCode = SubStopRef::Busy;
busy:
SubStopRef * ref = (SubStopRef *)signal->getDataPtrSend();
jam();
// ret->setErrorCode(SubStartRef::SeizeError);
// ret->setErrorLine(__LINE__);
// ret->setErrorNode(reference());
ref->senderRef = reference();
ref->errorCode = SubStopRef::Busy;
ref->errorCode = errCode;
sendSignal(origSenderRef, GSN_SUB_STOP_REF, signal,
SubStopRef::SignalLength, JBB);
......@@ -10020,10 +10039,16 @@ void Dbdict::execSUB_STOP_REQ(Signal* signal)
subbPtr.p->m_senderRef = origSenderRef; // not sure if API sets correctly
NodeReceiverGroup rg(DBDICT, c_aliveNodes);
RequestTracker & p = subbPtr.p->m_reqTracker;
p.init<SubStopRef>(c_counterMgr, rg, GSN_SUB_STOP_REF, subbPtr.i);
if (!p.init<SubStopRef>(c_counterMgr, rg, GSN_SUB_STOP_REF, subbPtr.i))
{
jam();
c_opSubEvent.release(subbPtr);
errCode = SubStopRef::Busy;
goto busy;
}
SubStopReq* req = (SubStopReq*) signal->getDataPtrSend();
req->senderRef = reference();
req->senderData = subbPtr.i;
......@@ -10313,9 +10338,14 @@ Dbdict::dropEventUTIL_EXECUTE_READ(Signal* signal,
NodeReceiverGroup rg(DBDICT, c_aliveNodes);
RequestTracker & p = evntRecPtr.p->m_reqTracker;
p.init<SubRemoveRef>(c_counterMgr, rg, GSN_SUB_REMOVE_REF,
evntRecPtr.i);
if (!p.init<SubRemoveRef>(c_counterMgr, rg, GSN_SUB_REMOVE_REF,
evntRecPtr.i))
{
evntRecPtr.p->m_errorCode = 701;
dropEvent_sendReply(signal, evntRecPtr);
return;
}
SubRemoveReq* req = (SubRemoveReq*) signal->getDataPtrSend();
req->senderRef = reference();
......
......@@ -2465,7 +2465,8 @@ Suma::execSUB_STOP_REQ(Signal* signal){
TablePtr tabPtr;
tabPtr.i = subPtr.p->m_table_ptrI;
if (!(tabPtr.p = c_tables.getPtr(tabPtr.i)) ||
if (tabPtr.i == RNIL ||
!(tabPtr.p = c_tables.getPtr(tabPtr.i)) ||
tabPtr.p->m_tableId != subPtr.p->m_tableId)
{
jam();
......
......@@ -1559,6 +1559,56 @@ static int runCreateDropNR(NDBT_Context* ctx, NDBT_Step* step)
DBUG_RETURN(result);
}
static
int
runSubscribeUnsubscribe(NDBT_Context* ctx, NDBT_Step* step)
{
char buf[1024];
const NdbDictionary::Table & tab = * ctx->getTab();
sprintf(buf, "%s_EVENT", tab.getName());
Ndb* ndb = GETNDB(step);
int loops = 5 * ctx->getNumLoops();
while (--loops)
{
NdbEventOperation *pOp= ndb->createEventOperation(buf);
if (pOp == 0)
{
g_err << "createEventOperation: "
<< ndb->getNdbError().code << " "
<< ndb->getNdbError().message << endl;
return NDBT_FAILED;
}
int n_columns= tab.getNoOfColumns();
for (int j = 0; j < n_columns; j++)
{
pOp->getValue(tab.getColumn(j)->getName());
pOp->getPreValue(tab.getColumn(j)->getName());
}
if ( pOp->execute() )
{
g_err << "pOp->execute(): "
<< pOp->getNdbError().code << " "
<< pOp->getNdbError().message << endl;
ndb->dropEventOperation(pOp);
return NDBT_FAILED;
}
if (ndb->dropEventOperation(pOp))
{
g_err << "pOp->execute(): "
<< ndb->getNdbError().code << " "
<< ndb->getNdbError().message << endl;
return NDBT_FAILED;
}
}
return NDBT_OK;
}
NDBT_TESTSUITE(test_event);
TESTCASE("BasicEventOperation",
"Verify that we can listen to Events"
......@@ -1673,6 +1723,13 @@ TESTCASE("CreateDropNR",
"NOTE! No errors are allowed!" ){
FINALIZER(runCreateDropNR);
}
TESTCASE("SubscribeUnsubscribe",
"A bunch of threads doing subscribe/unsubscribe in loop"
"NOTE! No errors are allowed!" ){
INITIALIZER(runCreateEvent);
STEPS(runSubscribeUnsubscribe, 16);
FINALIZER(runDropEvent);
}
NDBT_TESTSUITE_END(test_event);
int main(int argc, const char** argv){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment