|
1 | 1 | /* |
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. |
3 | 3 |
|
4 | 4 | This program is free software; you can redistribute it and/or modify |
5 | 5 | it under the terms of the GNU General Public License, version 2.0, |
@@ -83,6 +83,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade): |
83 | 83 | noOfConnectedNodes(0), |
84 | 84 | noOfConnectedDBNodes(0), |
85 | 85 | minDbVersion(0), |
| 86 | + minApiVersion(0), |
86 | 87 | theClusterMgrThread(NULL), |
87 | 88 | m_process_info(NULL), |
88 | 89 | m_cluster_state(CS_waiting_for_clean_cache), |
@@ -686,6 +687,52 @@ ClusterMgr::recalcMinDbVersion() |
686 | 687 | minDbVersion = newMinDbVersion; |
687 | 688 | } |
688 | 689 |
|
| 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 | + |
689 | 736 | /****************************************************************************** |
690 | 737 | * Send PROCESSINFO_REP |
691 | 738 | ******************************************************************************/ |
@@ -783,6 +830,7 @@ ClusterMgr::execAPI_REGREQ(const Uint32 * theData){ |
783 | 830 | conf->apiHeartbeatFrequency = m_hbFrequency/10; |
784 | 831 |
|
785 | 832 | conf->minDbVersion= 0; |
| 833 | + conf->minApiVersion= 0; |
786 | 834 | conf->nodeState= node.m_state; |
787 | 835 |
|
788 | 836 | DEBUG_FPRINTF((stderr, "set_confirmed on node: %u\n", nodeId)); |
@@ -835,6 +883,13 @@ ClusterMgr::execAPI_REGCONF(const NdbApiSignal * signal, |
835 | 883 | recalcMinDbVersion(); |
836 | 884 | } |
837 | 885 |
|
| 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 | + |
838 | 893 | node.m_state = apiRegConf->nodeState; |
839 | 894 |
|
840 | 895 | if (node.m_info.m_type == NodeInfo::DB) |
@@ -1183,6 +1238,7 @@ ClusterMgr::reportConnected(NodeId nodeId) |
1183 | 1238 | theNode.m_node_fail_rep = false; |
1184 | 1239 | theNode.m_state.startLevel = NodeState::SL_NOTHING; |
1185 | 1240 | theNode.minDbVersion = 0; |
| 1241 | + theNode.minApiVersion = 0; |
1186 | 1242 |
|
1187 | 1243 | /** |
1188 | 1244 | * End of protected ClusterMgr updates of shared global data. |
@@ -1361,6 +1417,7 @@ ClusterMgr::execNODE_FAILREP(const NdbApiSignal* sig, |
1361 | 1417 | } |
1362 | 1418 |
|
1363 | 1419 | recalcMinDbVersion(); |
| 1420 | + recalcMinApiVersion(); |
1364 | 1421 | if (copy->noOfNodes) |
1365 | 1422 | { |
1366 | 1423 | LinearSectionPtr lsptr[3]; |
|
0 commit comments