Skip to content

Commit 14161e7

Browse files
Bug#31016905 MAINTAIN THE MINIMUM CONNECTED API
VERSION VALUE IN NDBAPI Added code to calculate and maintain the minimum API node version connected to the cluster, in NDBAPI. A new method, get_min_api_version, is added to the Ndb_cluster_connection to give access to this value. Changes: class ApiRegConf - Added a new member variable minApiVersion. QMGR uses this variable to send the minimum API version, connected to that data node, to the API nodes as a part of the GSN_API_REGCONF reply. struct trp_node - Added a new member variable minApiVersion to cache the minimum API node version reported by the respective data nodes. class ClusterMgr - Added a new member variable minApiVersion to maintain the minimum API version connected to cluster. - Added a method recalcMinApiVersion() that recalculates the minimum API version connected to cluster by comparing the minimum API node versions reported by all the data nodes. The value is recalculated whenever a new data node connects, when it reports a change in the lowest API node connected to it or when it is disconnected. class Ndb_cluster_connection - Added a new method get_min_api_version() that returns the minimum API version value cached in the ClusterMgr object. Change-Id: I0ac873dbe55da188d049e647c890005f8c81219a
1 parent 1b7fbcf commit 14161e7

File tree

11 files changed

+110
-8
lines changed

11 files changed

+110
-8
lines changed

storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2020, 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, version 2.0,
@@ -93,7 +93,7 @@ class ApiRegConf {
9393
friend class ClusterMgr;
9494

9595
public:
96-
STATIC_CONST( SignalLength = 5 + NodeState::DataLength );
96+
STATIC_CONST( SignalLength = 6 + NodeState::DataLength );
9797
private:
9898

9999
Uint32 qmgrRef;
@@ -102,6 +102,7 @@ class ApiRegConf {
102102
Uint32 mysql_version;
103103
Uint32 minDbVersion;
104104
NodeStatePOD nodeState;
105+
Uint32 minApiVersion;
105106
};
106107

107108

storage/ndb/include/ndb_version.h.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,4 +625,17 @@ ndbd_support_waitgcp_shutdownsync(Uint32 x)
625625
return 1;
626626
}
627627

628+
/*
629+
* Data Node sends minimum API version connected to cluster
630+
* as a part of ApiRegConf reply since 8.0.21
631+
*/
632+
#define NDBD_SEND_MIN_API_VERSION NDB_MAKE_VERSION(8,0,21)
633+
static
634+
inline
635+
int
636+
ndbd_send_min_api_version(Uint32 x)
637+
{
638+
return x >= NDBD_SEND_MIN_API_VERSION;
639+
}
640+
628641
#endif

storage/ndb/include/ndbapi/ndb_cluster_connection.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class Ndb_cluster_connection {
309309
unsigned node_id();
310310
unsigned get_connect_count() const;
311311
unsigned get_min_db_version() const;
312+
unsigned get_min_api_version() const;
312313

313314
void init_get_next_node(Ndb_cluster_connection_node_iter &iter);
314315
unsigned int get_next_node(Ndb_cluster_connection_node_iter &iter);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,6 +4595,7 @@ Qmgr::sendApiRegConf(Signal *signal, Uint32 node)
45954595
}
45964596
NodeVersionInfo info = getNodeVersionInfo();
45974597
apiRegConf->minDbVersion = info.m_type[NodeInfo::DB].m_min_version;
4598+
apiRegConf->minApiVersion = info.m_type[NodeInfo::API].m_min_version;
45984599
apiRegConf->nodeState.m_connected_nodes.assign(c_connectedNodes);
45994600
sendSignal(ref, GSN_API_REGCONF, signal, ApiRegConf::SignalLength, JBB);
46004601
}

storage/ndb/src/ndbapi/ClusterMgr.cpp

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2020, 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, version 2.0,
@@ -83,6 +83,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade):
8383
noOfConnectedNodes(0),
8484
noOfConnectedDBNodes(0),
8585
minDbVersion(0),
86+
minApiVersion(0),
8687
theClusterMgrThread(NULL),
8788
m_process_info(NULL),
8889
m_cluster_state(CS_waiting_for_clean_cache),
@@ -686,6 +687,52 @@ ClusterMgr::recalcMinDbVersion()
686687
minDbVersion = newMinDbVersion;
687688
}
688689

690+
/**
691+
* recalcMinApiVersion
692+
*
693+
* This method is called whenever the 'minimum API node
694+
* version' data for the connected DB nodes changes
695+
* It calculates the minimum version of all the connected
696+
* API nodes.
697+
* This information is cached by Ndb object instances.
698+
* This information is useful when implementing API compatibility
699+
* with older API nodes
700+
*/
701+
void
702+
ClusterMgr::recalcMinApiVersion()
703+
{
704+
Uint32 newMinApiVersion = ~ (Uint32) 0;
705+
706+
for (Uint32 i = 0; i < MAX_NODES; i++)
707+
{
708+
trp_node& node = theNodes[i];
709+
710+
if (node.is_connected() &&
711+
node.is_confirmed() &&
712+
node.m_info.getType() == NodeInfo::DB)
713+
{
714+
/* Include this node in the set of nodes used to
715+
* compute the lowest current API node version
716+
*/
717+
assert(node.m_info.m_version);
718+
719+
if (node.minApiVersion < newMinApiVersion)
720+
{
721+
newMinApiVersion = node.minApiVersion;
722+
}
723+
}
724+
}
725+
726+
/* Now update global min Api version if we have one.
727+
* Otherwise set it to 0
728+
*/
729+
newMinApiVersion = (newMinApiVersion == ~ (Uint32) 0) ?
730+
0 :
731+
newMinApiVersion;
732+
733+
minApiVersion = newMinApiVersion;
734+
}
735+
689736
/******************************************************************************
690737
* Send PROCESSINFO_REP
691738
******************************************************************************/
@@ -783,6 +830,7 @@ ClusterMgr::execAPI_REGREQ(const Uint32 * theData){
783830
conf->apiHeartbeatFrequency = m_hbFrequency/10;
784831

785832
conf->minDbVersion= 0;
833+
conf->minApiVersion= 0;
786834
conf->nodeState= node.m_state;
787835

788836
DEBUG_FPRINTF((stderr, "set_confirmed on node: %u\n", nodeId));
@@ -835,6 +883,13 @@ ClusterMgr::execAPI_REGCONF(const NdbApiSignal * signal,
835883
recalcMinDbVersion();
836884
}
837885

886+
if (ndbd_send_min_api_version(apiRegConf->mysql_version) &&
887+
node.minApiVersion != apiRegConf->minApiVersion)
888+
{
889+
node.minApiVersion = apiRegConf->minApiVersion;
890+
recalcMinApiVersion();
891+
}
892+
838893
node.m_state = apiRegConf->nodeState;
839894

840895
if (node.m_info.m_type == NodeInfo::DB)
@@ -1183,6 +1238,7 @@ ClusterMgr::reportConnected(NodeId nodeId)
11831238
theNode.m_node_fail_rep = false;
11841239
theNode.m_state.startLevel = NodeState::SL_NOTHING;
11851240
theNode.minDbVersion = 0;
1241+
theNode.minApiVersion = 0;
11861242

11871243
/**
11881244
* End of protected ClusterMgr updates of shared global data.
@@ -1361,6 +1417,7 @@ ClusterMgr::execNODE_FAILREP(const NdbApiSignal* sig,
13611417
}
13621418

13631419
recalcMinDbVersion();
1420+
recalcMinApiVersion();
13641421
if (copy->noOfNodes)
13651422
{
13661423
LinearSectionPtr lsptr[3];

storage/ndb/src/ndbapi/ClusterMgr.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class ClusterMgr : public trp_client
157157
Uint32 noOfConnectedNodes;
158158
Uint32 noOfConnectedDBNodes;
159159
Uint32 minDbVersion;
160+
Uint32 minApiVersion;
160161
Node theNodes[MAX_NODES];
161162
NdbThread* theClusterMgrThread;
162163

@@ -223,6 +224,7 @@ class ClusterMgr : public trp_client
223224

224225
void print_nodes(const char* where, NdbOut& out = ndbout);
225226
void recalcMinDbVersion();
227+
void recalcMinApiVersion();
226228
void sendProcessInfoReport(NodeId nodeId);
227229

228230
public:

storage/ndb/src/ndbapi/TransporterFacade.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2020, 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, version 2.0,
@@ -132,6 +132,7 @@ class TransporterFacade :
132132

133133
public:
134134
Uint32 getMinDbNodeVersion() const;
135+
Uint32 getMinApiNodeVersion() const;
135136

136137
// My own processor id
137138
NodeId ownId() const;
@@ -652,6 +653,12 @@ unsigned Ndb_cluster_connection_impl::get_min_db_version() const
652653
return m_transporter_facade->getMinDbNodeVersion();
653654
}
654655

656+
inline
657+
unsigned Ndb_cluster_connection_impl::get_min_api_version() const
658+
{
659+
return m_transporter_facade->getMinApiNodeVersion();
660+
}
661+
655662
inline
656663
bool
657664
TransporterFacade::get_node_alive(NodeId n) const {
@@ -678,6 +685,16 @@ TransporterFacade::getMinDbNodeVersion() const
678685
return 0;
679686
}
680687

688+
inline
689+
Uint32
690+
TransporterFacade::getMinApiNodeVersion() const
691+
{
692+
if (theClusterMgr)
693+
return theClusterMgr->minApiVersion;
694+
else
695+
return 0;
696+
}
697+
681698
inline
682699
const trp_node &
683700
trp_client::getNodeInfo(Uint32 nodeId) const

storage/ndb/src/ndbapi/ndb_cluster_connection.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2004, 2020, 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, version 2.0,
@@ -431,6 +431,11 @@ unsigned Ndb_cluster_connection::get_min_db_version() const
431431
return m_impl.get_min_db_version();
432432
}
433433

434+
unsigned Ndb_cluster_connection::get_min_api_version() const
435+
{
436+
return m_impl.get_min_api_version();
437+
}
438+
434439
int Ndb_cluster_connection::get_latest_error() const
435440
{
436441
return m_impl.m_latest_error;

storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2004, 2020, 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, version 2.0,
@@ -82,6 +82,7 @@ class Ndb_cluster_connection_impl : public Ndb_cluster_connection
8282

8383
inline unsigned get_connect_count() const;
8484
inline unsigned get_min_db_version() const;
85+
inline unsigned get_min_api_version() const;
8586
public:
8687
inline Uint64 *get_latest_trans_gci() { return &m_latest_trans_gci; }
8788

storage/ndb/src/ndbapi/trp_node.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2010, 2020, 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, version 2.0,
@@ -33,6 +33,7 @@ trp_node::trp_node()
3333
m_state.init();
3434
m_state.startLevel = NodeState::SL_NOTHING;
3535
minDbVersion = 0;
36+
minApiVersion = 0;
3637
}
3738

3839
bool
@@ -46,6 +47,7 @@ trp_node::operator==(const trp_node& other) const
4647
m_api_reg_conf == other.m_api_reg_conf &&
4748
m_node_fail_rep == other.m_node_fail_rep &&
4849
minDbVersion == other.minDbVersion &&
50+
minApiVersion == other.minApiVersion &&
4951
memcmp(&m_state, &other.m_state, sizeof(m_state)) == 0);
5052
}
5153

@@ -61,6 +63,7 @@ operator<<(NdbOut& out, const trp_node& n)
6163
<< ", nodefailrep: " << n.m_node_fail_rep
6264
<< ", nfCompleteRep: " << n.nfCompleteRep
6365
<< ", minDbVersion: " << n.minDbVersion
66+
<< ", minApiVersion: " << n.minApiVersion
6467
<< ", state: " << n.m_state
6568
<< ", connected: "
6669
<< BaseString::getPrettyTextShort(n.m_state.m_connected_nodes).c_str()

0 commit comments

Comments
 (0)