1 /*
2 Copyright (c) 2003, 2021, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include "Suma.hpp"
26
27 #include <Properties.hpp>
28 #include <Configuration.hpp>
29
30 #define JAM_FILE_ID 468
31
32
Suma(Block_context & ctx)33 Suma::Suma(Block_context& ctx) :
34 SimulatedBlock(SUMA, ctx),
35 c_tables(c_tablePool),
36 c_subscriptions(c_subscriptionPool),
37 c_gcp_list(c_gcp_pool),
38 m_current_gci(~(Uint64)0)
39 {
40 BLOCK_CONSTRUCTOR(Suma);
41
42 // Add received signals
43 addRecSignal(GSN_READ_CONFIG_REQ, &Suma::execREAD_CONFIG_REQ);
44 addRecSignal(GSN_STTOR, &Suma::execSTTOR);
45 addRecSignal(GSN_NDB_STTOR, &Suma::execNDB_STTOR);
46 addRecSignal(GSN_DUMP_STATE_ORD, &Suma::execDUMP_STATE_ORD);
47 addRecSignal(GSN_DBINFO_SCANREQ, &Suma::execDBINFO_SCANREQ);
48 addRecSignal(GSN_READ_NODESCONF, &Suma::execREAD_NODESCONF);
49 addRecSignal(GSN_API_START_REP, &Suma::execAPI_START_REP, true);
50 addRecSignal(GSN_API_FAILREQ, &Suma::execAPI_FAILREQ);
51 addRecSignal(GSN_NODE_FAILREP, &Suma::execNODE_FAILREP);
52 addRecSignal(GSN_INCL_NODEREQ, &Suma::execINCL_NODEREQ);
53 addRecSignal(GSN_CONTINUEB, &Suma::execCONTINUEB);
54 addRecSignal(GSN_SIGNAL_DROPPED_REP, &Suma::execSIGNAL_DROPPED_REP, true);
55 addRecSignal(GSN_UTIL_SEQUENCE_CONF, &Suma::execUTIL_SEQUENCE_CONF);
56 addRecSignal(GSN_UTIL_SEQUENCE_REF, &Suma::execUTIL_SEQUENCE_REF);
57 addRecSignal(GSN_CREATE_SUBID_REQ,
58 &Suma::execCREATE_SUBID_REQ);
59
60 addRecSignal(GSN_SUB_CREATE_CONF, &Suma::execSUB_CREATE_CONF);
61 addRecSignal(GSN_SUB_CREATE_REF, &Suma::execSUB_CREATE_REF);
62
63 addRecSignal(GSN_SUB_START_CONF, &Suma::execSUB_START_CONF);
64 addRecSignal(GSN_SUB_START_REF, &Suma::execSUB_START_REF);
65
66 addRecSignal(GSN_SUMA_START_ME_REQ, &Suma::execSUMA_START_ME_REQ);
67 addRecSignal(GSN_SUMA_START_ME_REF, &Suma::execSUMA_START_ME_REF);
68 addRecSignal(GSN_SUMA_START_ME_CONF, &Suma::execSUMA_START_ME_CONF);
69 addRecSignal(GSN_SUMA_HANDOVER_REQ, &Suma::execSUMA_HANDOVER_REQ);
70 addRecSignal(GSN_SUMA_HANDOVER_REF, &Suma::execSUMA_HANDOVER_REF);
71 addRecSignal(GSN_SUMA_HANDOVER_CONF, &Suma::execSUMA_HANDOVER_CONF);
72
73 addRecSignal(GSN_SUB_GCP_COMPLETE_ACK,
74 &Suma::execSUB_GCP_COMPLETE_ACK);
75
76 addRecSignal(GSN_STOP_ME_REQ,
77 &Suma::execSTOP_ME_REQ);
78
79 /**
80 * SUMA participant if
81 */
82 addRecSignal(GSN_SUB_CREATE_REQ, &Suma::execSUB_CREATE_REQ);
83 addRecSignal(GSN_SUB_REMOVE_REQ, &Suma::execSUB_REMOVE_REQ);
84 addRecSignal(GSN_SUB_START_REQ, &Suma::execSUB_START_REQ);
85 addRecSignal(GSN_SUB_STOP_REQ, &Suma::execSUB_STOP_REQ);
86 addRecSignal(GSN_SUB_SYNC_REQ, &Suma::execSUB_SYNC_REQ);
87
88 /**
89 * Dict interface
90 */
91 addRecSignal(GSN_DROP_TAB_CONF, &Suma::execDROP_TAB_CONF);
92 addRecSignal(GSN_ALTER_TAB_REQ, &Suma::execALTER_TAB_REQ);
93 addRecSignal(GSN_CREATE_TAB_CONF, &Suma::execCREATE_TAB_CONF);
94
95 addRecSignal(GSN_GET_TABINFO_CONF, &Suma::execGET_TABINFO_CONF);
96 addRecSignal(GSN_GET_TABINFOREF, &Suma::execGET_TABINFOREF);
97
98 addRecSignal(GSN_DICT_LOCK_REF, &Suma::execDICT_LOCK_REF);
99 addRecSignal(GSN_DICT_LOCK_CONF, &Suma::execDICT_LOCK_CONF);
100
101 /**
102 * Dih interface
103 */
104 addRecSignal(GSN_DIH_SCAN_TAB_REF, &Suma::execDIH_SCAN_TAB_REF);
105 addRecSignal(GSN_DIH_SCAN_TAB_CONF, &Suma::execDIH_SCAN_TAB_CONF);
106 addRecSignal(GSN_DIH_SCAN_GET_NODES_CONF, &Suma::execDIH_SCAN_GET_NODES_CONF);
107 addRecSignal(GSN_CHECKNODEGROUPSCONF, &Suma::execCHECKNODEGROUPSCONF);
108 addRecSignal(GSN_GCP_PREPARE, &Suma::execGCP_PREPARE);
109
110 /**
111 * Scan interface
112 */
113 addRecSignal(GSN_SCAN_HBREP, &Suma::execSCAN_HBREP);
114 addRecSignal(GSN_TRANSID_AI, &Suma::execTRANSID_AI);
115 addRecSignal(GSN_KEYINFO20, &Suma::execKEYINFO20);
116 addRecSignal(GSN_SCAN_FRAGREF, &Suma::execSCAN_FRAGREF);
117 addRecSignal(GSN_SCAN_FRAGCONF, &Suma::execSCAN_FRAGCONF);
118 #if 0
119 addRecSignal(GSN_SUB_SYNC_CONTINUE_REF,
120 &Suma::execSUB_SYNC_CONTINUE_REF);
121 #endif
122 addRecSignal(GSN_SUB_SYNC_CONTINUE_CONF,
123 &Suma::execSUB_SYNC_CONTINUE_CONF);
124
125 /**
126 * Trigger stuff
127 */
128 addRecSignal(GSN_TRIG_ATTRINFO, &Suma::execTRIG_ATTRINFO);
129 addRecSignal(GSN_FIRE_TRIG_ORD, &Suma::execFIRE_TRIG_ORD);
130 addRecSignal(GSN_FIRE_TRIG_ORD_L, &Suma::execFIRE_TRIG_ORD_L);
131
132 addRecSignal(GSN_CREATE_TRIG_IMPL_REF, &Suma::execCREATE_TRIG_IMPL_REF);
133 addRecSignal(GSN_CREATE_TRIG_IMPL_CONF, &Suma::execCREATE_TRIG_IMPL_CONF);
134 addRecSignal(GSN_DROP_TRIG_IMPL_REF, &Suma::execDROP_TRIG_IMPL_REF);
135 addRecSignal(GSN_DROP_TRIG_IMPL_CONF, &Suma::execDROP_TRIG_IMPL_CONF);
136
137 addRecSignal(GSN_SUB_GCP_COMPLETE_REP,
138 &Suma::execSUB_GCP_COMPLETE_REP);
139
140 addRecSignal(GSN_CREATE_NODEGROUP_IMPL_REQ,
141 &Suma::execCREATE_NODEGROUP_IMPL_REQ);
142
143 addRecSignal(GSN_DROP_NODEGROUP_IMPL_REQ,
144 &Suma::execDROP_NODEGROUP_IMPL_REQ);
145
146 c_current_seq = 0;
147 c_outstanding_drop_trig_req = 0;
148 c_restart.m_ref = 0;
149 c_startup.m_restart_server_node_id = RNIL; // Server for my NR
150 c_shutdown.m_wait_handover = false;
151
152 #ifdef VM_TRACE
153 m_gcp_monitor = 0;
154 #endif
155 m_missing_data = false;
156 bzero(c_subscriber_per_node, sizeof(c_subscriber_per_node));
157
158 m_gcp_rep_cnt = getLqhWorkers();
159 m_min_gcp_rep_counter_index = 0;
160 m_max_gcp_rep_counter_index = 0;
161 bzero(m_gcp_rep_counter, sizeof(m_gcp_rep_counter));
162 }
163
~Suma()164 Suma::~Suma()
165 {
166 c_page_pool.clear();
167 }
168
169 bool
getParam(const char * param,Uint32 * retVal)170 Suma::getParam(const char * param, Uint32 * retVal)
171 {
172 if (param != NULL && retVal != NULL)
173 {
174 if (strcmp(param, "FragmentSendPool") == 0)
175 {
176 /* FragmentSendPool
177 * We increase the size of the fragment send pool
178 * to possibly handle max number of SQL nodes
179 * being subscribers
180 */
181
182 *retVal= MAX_NODES;
183 return true;
184 }
185 }
186 return false;
187 }
188
189 BLOCK_FUNCTIONS(Suma)
190
191