Skip to content

Commit

Permalink
wl#9819 patch #6: Memory allocation in Qmgr
Browse files Browse the repository at this point in the history
In initData(), a new array receivedProcessInfo is dynamically allocated
to hold one ProcessInfo struct for each configured API and MGM node.
  • Loading branch information
jdduncan committed Mar 30, 2017
1 parent 83b6f45 commit 980c69f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
7 changes: 6 additions & 1 deletion storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -24,6 +24,7 @@
#include <SimulatedBlock.hpp>
#include <NodeBitmask.hpp>
#include <SignalCounter.hpp>
#include <ProcessInfo.hpp>

#include <signaldata/EventReport.hpp>
#include <signaldata/ArbitSignalData.hpp>
Expand Down Expand Up @@ -482,6 +483,7 @@ class Qmgr : public SimulatedBlock {
void joinedCluster(Signal* signal, NodeRecPtr nodePtr);
void sendCmRegReq(Signal * signal, Uint32 nodeId);
void sendCmNodeInfoReq(Signal* signal, Uint32 nodeId, const NodeRec * self);
ProcessInfo * getProcessInfo(Uint32 nodeId);

private:
void sendPrepFailReqRef(Signal* signal,
Expand Down Expand Up @@ -542,6 +544,9 @@ class Qmgr : public SimulatedBlock {
Timer hb_send_timer;
Timer hb_api_timer;

Int16 processInfoNodeIndex[MAX_NODES];
ProcessInfo * receivedProcessInfo;
Uint16 max_api_node_id;

NdbNodeBitmask cfailedNodes;
NdbNodeBitmask cprepFailedNodes;
Expand Down
30 changes: 29 additions & 1 deletion storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -20,6 +20,9 @@
#define QMGR_C
#include "Qmgr.hpp"

#include <EventLogger.hpp>
extern EventLogger * g_eventLogger;

#define JAM_FILE_ID 361


Expand Down Expand Up @@ -133,6 +136,30 @@ void Qmgr::initData()
nodePtr.p->sendPresToStatus = Q_NOT_ACTIVE;
nodePtr.p->failState = NORMAL;
}//for

/* Received ProcessInfo are indirectly addressed:
nodeId => fixed array lookup => dynamic array.
The dynamic array contains enough entries for all
configured MGM and API nodes.
*/
int numOfApiAndMgmNodes = 0;
for (int i = 1; i < MAX_NODES; i++)
{
Uint32 type = getNodeInfo(i).m_type;
switch(type){
case NodeInfo::API:
case NodeInfo::MGM:
processInfoNodeIndex[i] = numOfApiAndMgmNodes++;
max_api_node_id = i;
break;
default:
processInfoNodeIndex[i] = -1;
break;
}
}
receivedProcessInfo = new ProcessInfo[numOfApiAndMgmNodes];
g_eventLogger->info("Qmgr initialized %d ProcessInfo records up to "
"node id %d", numOfApiAndMgmNodes, max_api_node_id);
}//Qmgr::initData()

void Qmgr::initRecords()
Expand Down Expand Up @@ -228,6 +255,7 @@ Qmgr::Qmgr(Block_context& ctx)
Qmgr::~Qmgr()
{
delete []nodeRec;
delete []receivedProcessInfo;
}//Qmgr::~Qmgr()


Expand Down
14 changes: 14 additions & 0 deletions storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include <signaldata/DumpStateOrd.hpp>
#include <signaldata/IsolateOrd.hpp>
#include <ndb_version.h>
#include <OwnProcessInfo.hpp>
#include <NodeInfo.hpp>

#include <TransporterRegistry.hpp> // Get connect address

Expand Down Expand Up @@ -7485,6 +7487,18 @@ Qmgr::handleFailFromSuspect(Signal* signal,
failReportLab(signal, sourceNode, (FailRep::FailCause) reason, getOwnNodeId());
}

ProcessInfo *
Qmgr::getProcessInfo(Uint32 nodeId)
{
ProcessInfo * storedProcessInfo = 0;
Int16 index = processInfoNodeIndex[nodeId];
if(index >= 0)
storedProcessInfo = & receivedProcessInfo[index];
else if(nodeId == getOwnNodeId())
storedProcessInfo = getOwnProcessInfo(getOwnNodeId());
return storedProcessInfo;
}

void
Qmgr::execDBINFO_SCANREQ(Signal *signal)
{
Expand Down

0 comments on commit 980c69f

Please sign in to comment.