Commit b3dd80dd authored by unknown's avatar unknown

[PATCH] WL#3704 mgmapi timeouts: Add ndb_mgmd error injection

Add error injection either for this connection or for whole server.

Currently nothing for injecting errors into *another* connection... but that's
perhaps getting tricky-dicky for this point in time. Perhaps needed for events
if we don't do anything fancy.

Index: ndb-work/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
===================================================================


storage/ndb/src/mgmsrv/MgmtSrvr.cpp:
  WL#3704 mgmapi timeouts: Add ndb_mgmd error injection
storage/ndb/src/mgmsrv/MgmtSrvr.hpp:
  WL#3704 mgmapi timeouts: Add ndb_mgmd error injection
storage/ndb/src/mgmsrv/Services.cpp:
  WL#3704 mgmapi timeouts: Add ndb_mgmd error injection
storage/ndb/src/mgmsrv/Services.hpp:
  WL#3704 mgmapi timeouts: Add ndb_mgmd error injection
storage/ndb/test/ndbapi/testMgm.cpp:
  WL#3704 mgmapi timeouts: Add ndb_mgmd error injection
parent 9f10e20f
......@@ -66,6 +66,9 @@
#define DEBUG(x)
#endif
int g_errorInsert;
#define ERROR_INSERTED(x) (g_errorInsert == x)
#define INIT_SIGNAL_SENDER(ss,nodeId) \
SignalSender ss(theFacade); \
ss.lock(); /* lock will be released on exit */ \
......@@ -177,6 +180,7 @@ MgmtSrvr::logLevelThreadRun()
m_log_level_requests.lock();
}
m_log_level_requests.unlock();
NdbSleep_MilliSleep(_logLevelThreadSleep);
}
}
......@@ -1730,14 +1734,29 @@ MgmtSrvr::setNodeLogLevelImpl(int nodeId, const SetLogLevelOrd & ll)
int
MgmtSrvr::insertError(int nodeId, int errorNo)
{
int block;
if (errorNo < 0) {
return INVALID_ERROR_NUMBER;
}
INIT_SIGNAL_SENDER(ss,nodeId);
SignalSender ss(theFacade);
ss.lock(); /* lock will be released on exit */
if(getNodeType(nodeId) == NDB_MGM_NODE_TYPE_NDB)
{
block= CMVMI;
if(!theFacade->theClusterMgr->getNodeInfo(nodeId).connected
|| !theFacade->get_node_alive(nodeId))
return NO_CONTACT_WITH_PROCESS;
}
else if(getNodeType(nodeId) == NDB_MGM_NODE_TYPE_MGM)
block= _blockNumber;
else
return WRONG_PROCESS_TYPE;
SimpleSignal ssig;
ssig.set(ss,TestOrd::TraceAPI, CMVMI, GSN_TAMPER_ORD,
ssig.set(ss,TestOrd::TraceAPI, block, GSN_TAMPER_ORD,
TamperOrd::SignalLength);
TamperOrd* const tamperOrd = CAST_PTR(TamperOrd, ssig.getDataPtrSend());
tamperOrd->errorNo = errorNo;
......@@ -1972,6 +1991,10 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
case GSN_NODE_FAILREP:
break;
case GSN_TAMPER_ORD:
ndbout << "TAMPER ORD" << endl;
break;
default:
g_eventLogger.error("Unknown signal received. SignalNumber: "
"%i from (%d, %x)",
......
......@@ -38,6 +38,10 @@
*/
#define MGMSRV 1
#define MGM_ERROR_MAX_INJECT_SESSION_ONLY 10000
extern int g_errorInsert;
class ConfigInfoServer;
class NdbApiSignal;
class Config;
......
......@@ -288,6 +288,8 @@ struct PurgeStruct
NDB_TICKS tick;
};
#define ERROR_INSERTED(x) (g_errorInsert == x || m_errorInsert == x)
MgmApiSession::MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock, Uint64 session_id)
: SocketServer::Session(sock), m_mgmsrv(mgm)
{
......@@ -300,6 +302,7 @@ MgmApiSession::MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock, Uint64
m_ctx= NULL;
m_session_id= session_id;
m_mutex= NdbMutex_Create();
m_errorInsert= 0;
DBUG_VOID_RETURN;
}
......@@ -613,11 +616,22 @@ void
MgmApiSession::insertError(Parser<MgmApiSession>::Context &,
Properties const &args) {
Uint32 node = 0, error = 0;
int result= 0;
args.get("node", &node);
args.get("error", &error);
int result = m_mgmsrv.insertError(node, error);
if(node==m_mgmsrv.getOwnNodeId()
&& error < MGM_ERROR_MAX_INJECT_SESSION_ONLY)
{
m_errorInsert= error;
if(error==0)
g_errorInsert= error;
}
else
{
result= m_mgmsrv.insertError(node, error);
}
m_output->println("insert error reply");
if(result != 0)
......@@ -1602,6 +1616,10 @@ void
MgmApiSession::check_connection(Parser_t::Context &ctx,
const class Properties &args)
{
if(ERROR_INSERTED(1))
{
NdbSleep_SecSleep(10);
}
m_output->println("check connection reply");
m_output->println("result: Ok");
m_output->println("");
......
......@@ -46,6 +46,8 @@ private:
Parser_t::Context *m_ctx;
Uint64 m_session_id;
int m_errorInsert;
const char *get_error_text(int err_no)
{ return m_mgmsrv.getErrorText(err_no, m_err_str, sizeof(m_err_str)); }
......
......@@ -207,6 +207,53 @@ int runTestApiSession(NDBT_Context* ctx, NDBT_Step* step)
}
}
int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step)
{
char *mgm= ctx->getRemoteMgm();
int result= NDBT_FAILED;
int cc= 0;
NdbMgmHandle h;
h= ndb_mgm_create_handle();
ndb_mgm_set_connectstring(h, mgm);
ndb_mgm_connect(h,0,0,0);
ndbout << "Connected" << endl;
if(ndb_mgm_check_connection(h) < 0)
{
result= NDBT_FAILED;
goto done;
}
ndbout << "Checked Connection" << endl;
ndb_mgm_reply reply;
reply.return_code= 0;
if(ndb_mgm_insert_error(h, 3, 1, &reply)< 0)
{
ndbout << "failed to insert error " << endl;
result= NDBT_FAILED;
goto done;
}
ndbout << "Inserted session error" << endl;
cc= ndb_mgm_check_connection(h);
if(cc < 0)
result= NDBT_OK;
else
result= NDBT_FAILED;
ndbout << "Tried check connection with result: " << cc << endl;
done:
ndb_mgm_disconnect(h);
ndb_mgm_destroy_handle(&h);
return result;
}
NDBT_TESTSUITE(testMgm);
TESTCASE("SingleUserMode",
......@@ -218,6 +265,11 @@ TESTCASE("ApiSessionFailure",
"Test failures in MGMAPI session"){
INITIALIZER(runTestApiSession);
}
TESTCASE("ApiTimeout1",
"Test timeout for MGMAPI"){
INITIALIZER(runTestApiTimeout1);
}
NDBT_TESTSUITE_END(testMgm);
......
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