Skip to content

Commit 980c69f

Browse files
committed
wl#9819 patch #6: Memory allocation in Qmgr
In initData(), a new array receivedProcessInfo is dynamically allocated to hold one ProcessInfo struct for each configured API and MGM node.
1 parent 83b6f45 commit 980c69f

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
2424
#include <SimulatedBlock.hpp>
2525
#include <NodeBitmask.hpp>
2626
#include <SignalCounter.hpp>
27+
#include <ProcessInfo.hpp>
2728

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

486488
private:
487489
void sendPrepFailReqRef(Signal* signal,
@@ -542,6 +544,9 @@ class Qmgr : public SimulatedBlock {
542544
Timer hb_send_timer;
543545
Timer hb_api_timer;
544546

547+
Int16 processInfoNodeIndex[MAX_NODES];
548+
ProcessInfo * receivedProcessInfo;
549+
Uint16 max_api_node_id;
545550

546551
NdbNodeBitmask cfailedNodes;
547552
NdbNodeBitmask cprepFailedNodes;

storage/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -20,6 +20,9 @@
2020
#define QMGR_C
2121
#include "Qmgr.hpp"
2222

23+
#include <EventLogger.hpp>
24+
extern EventLogger * g_eventLogger;
25+
2326
#define JAM_FILE_ID 361
2427

2528

@@ -133,6 +136,30 @@ void Qmgr::initData()
133136
nodePtr.p->sendPresToStatus = Q_NOT_ACTIVE;
134137
nodePtr.p->failState = NORMAL;
135138
}//for
139+
140+
/* Received ProcessInfo are indirectly addressed:
141+
nodeId => fixed array lookup => dynamic array.
142+
The dynamic array contains enough entries for all
143+
configured MGM and API nodes.
144+
*/
145+
int numOfApiAndMgmNodes = 0;
146+
for (int i = 1; i < MAX_NODES; i++)
147+
{
148+
Uint32 type = getNodeInfo(i).m_type;
149+
switch(type){
150+
case NodeInfo::API:
151+
case NodeInfo::MGM:
152+
processInfoNodeIndex[i] = numOfApiAndMgmNodes++;
153+
max_api_node_id = i;
154+
break;
155+
default:
156+
processInfoNodeIndex[i] = -1;
157+
break;
158+
}
159+
}
160+
receivedProcessInfo = new ProcessInfo[numOfApiAndMgmNodes];
161+
g_eventLogger->info("Qmgr initialized %d ProcessInfo records up to "
162+
"node id %d", numOfApiAndMgmNodes, max_api_node_id);
136163
}//Qmgr::initData()
137164

138165
void Qmgr::initRecords()
@@ -228,6 +255,7 @@ Qmgr::Qmgr(Block_context& ctx)
228255
Qmgr::~Qmgr()
229256
{
230257
delete []nodeRec;
258+
delete []receivedProcessInfo;
231259
}//Qmgr::~Qmgr()
232260

233261

storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#include <signaldata/DumpStateOrd.hpp>
4545
#include <signaldata/IsolateOrd.hpp>
4646
#include <ndb_version.h>
47+
#include <OwnProcessInfo.hpp>
48+
#include <NodeInfo.hpp>
4749

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

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

7490+
ProcessInfo *
7491+
Qmgr::getProcessInfo(Uint32 nodeId)
7492+
{
7493+
ProcessInfo * storedProcessInfo = 0;
7494+
Int16 index = processInfoNodeIndex[nodeId];
7495+
if(index >= 0)
7496+
storedProcessInfo = & receivedProcessInfo[index];
7497+
else if(nodeId == getOwnNodeId())
7498+
storedProcessInfo = getOwnProcessInfo(getOwnNodeId());
7499+
return storedProcessInfo;
7500+
}
7501+
74887502
void
74897503
Qmgr::execDBINFO_SCANREQ(Signal *signal)
74907504
{

0 commit comments

Comments
 (0)