1 /*
2    Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
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 #ifndef LCP_SIGNAL_DATA_HPP
26 #define LCP_SIGNAL_DATA_HPP
27 
28 #include "SignalData.hpp"
29 #include <NodeBitmask.hpp>
30 
31 #define JAM_FILE_ID 170
32 
33 
34 struct StartLcpReq {
35   /**
36    * Sender(s)
37    */
38   friend class Dbdih;
39 
40   /**
41    * Sender(s) / Receiver(s)
42    */
43 
44   /**
45    * Receiver(s)
46    */
47   friend class Dblqh;
48 
49   friend bool printSTART_LCP_REQ(FILE *, const Uint32 *, Uint32, Uint16);
50 public:
51 
52   STATIC_CONST( SignalLength = 2 + 2 * NdbNodeBitmask48::Size + 1 );
53   Uint32 senderRef;
54   Uint32 lcpId;
55 
56   NdbNodeBitmask48 participatingDIH_v1;
57   NdbNodeBitmask48 participatingLQH_v1;
58 
59   enum PauseStart
60   {
61     NormalLcpStart = 0,
62     PauseLcpStartFirst = 1,
63     PauseLcpStartSecond = 2
64   };
65 
66   /**
67    * pauseStart = 0 normal start
68    * pauseStart = 1 starting node into already running LCP,
69    *                bitmasks contains participants
70    * pauseStart = 2 starting node into already running LCP,
71    *                bitmasks contains completion bitmasks
72    * pauseStart = 1 requires no response since pauseStart = 2 will arrive
73    *                immediately after it.
74    */
75   PauseStart pauseStart;
76   NdbNodeBitmask participatingDIH; // Not part of signal, but first section
77   NdbNodeBitmask participatingLQH; // Not part of signal, but second section
78 };
79 
80 class StartLcpConf {
81   /**
82    * Sender(s)
83    */
84   friend class Dblqh;
85 
86   /**
87    * Sender(s) / Receiver(s)
88    */
89 
90   /**
91    * Receiver(s)
92    */
93   friend class Dbdih;
94 
95   friend bool printSTART_LCP_CONF(FILE *, const Uint32 *, Uint32, Uint16);
96 public:
97 
98   STATIC_CONST( SignalLength = 2 );
99 private:
100   Uint32 senderRef;
101   Uint32 lcpId;
102 };
103 
104 /**
105  * This signals is sent by Dbdih to Dblqh
106  * to order checkpointing of a certain
107  * fragment.
108  */
109 class LcpFragOrd {
110   /**
111    * Sender(s)
112    */
113   friend class Dbdih;
114   friend class Lgman;
115   friend class Pgman;
116   friend class Dbtup;
117   friend class Backup;
118 
119   /**
120    * Sender(s) / Receiver(s)
121    */
122 
123   /**
124    * Receiver(s)
125    */
126   friend class Dblqh;
127   friend class DblqhProxy;
128   friend class PgmanProxy;
129 
130   friend bool printLCP_FRAG_ORD(FILE *, const Uint32 *, Uint32, Uint16);
131 public:
132   STATIC_CONST( SignalLength = 6 );
133 private:
134 
135   Uint32 tableId;
136   Uint32 fragmentId;
137   Uint32 lcpNo;
138   Uint32 lcpId;
139   Uint32 lastFragmentFlag;
140   Uint32 keepGci;
141 };
142 
143 
144 struct LcpFragRep {
145   /**
146    * Sender(s) and receiver(s)
147    */
148   friend class Dbdih;
149 
150   /**
151    * Sender(s)
152    */
153   friend class Dblqh;
154   friend class DblqhProxy;
155 
156   friend bool printLCP_FRAG_REP(FILE *, const Uint32 *, Uint32, Uint16);
157 
158   STATIC_CONST( SignalLength = 7 );
159   STATIC_CONST( SignalLengthTQ = 8 );
160   STATIC_CONST( BROADCAST_REQ = 0 );
161 
162   Uint32 nodeId;
163   Uint32 lcpId;
164   Uint32 lcpNo;
165   Uint32 tableId;
166   Uint32 fragId;
167   Uint32 maxGciCompleted;
168   Uint32 maxGciStarted;
169   Uint32 fromTQ;
170 };
171 
172 class LcpCompleteRep {
173   /**
174    * Sender(s) and receiver(s)
175    */
176   friend class Dbdih;
177 
178   /**
179    * Sender(s)
180    */
181   friend class Dblqh;
182   friend class DblqhProxy;
183 
184   friend bool printLCP_COMPLETE_REP(FILE *, const Uint32 *, Uint32, Uint16);
185 public:
186   STATIC_CONST( SignalLength = 3 );
187   STATIC_CONST( SignalLengthTQ = 4 );
188 
189 private:
190   Uint32 nodeId;
191   Uint32 blockNo;
192   Uint32 lcpId;
193   Uint32 fromTQ;
194 };
195 
196 struct LcpPrepareReq
197 {
198   Uint32 senderData;
199   Uint32 senderRef;
200   Uint32 lcpNo;
201   Uint32 tableId;
202   Uint32 fragmentId;
203   Uint32 lcpId;
204   Uint32 backupPtr;
205   Uint32 backupId;
206   Uint32 createGci;
207   Uint32 localLcpId;
208 
209   STATIC_CONST( SignalLength = 10 );
210 };
211 
212 struct LcpPrepareRef
213 {
214   Uint32 senderData;
215   Uint32 senderRef;
216   Uint32 tableId;
217   Uint32 fragmentId;
218   Uint32 errorCode;
219 
220   STATIC_CONST( SignalLength = 5 );
221 };
222 
223 struct LcpPrepareConf
224 {
225   Uint32 senderData;
226   Uint32 senderRef;
227   Uint32 tableId;
228   Uint32 fragmentId;
229 
230   STATIC_CONST( SignalLength = 4 );
231 };
232 
233 struct SyncPageCacheReq
234 {
235   Uint32 senderData;
236   Uint32 senderRef;
237   Uint32 tableId;
238   Uint32 fragmentId;
239 
240   STATIC_CONST( SignalLength = 4 );
241 };
242 
243 struct SyncPageCacheConf
244 {
245   Uint32 senderData;
246   Uint32 senderRef;
247   Uint32 tableId;
248   Uint32 fragmentId;
249   Uint32 diskDataExistFlag;
250 
251   STATIC_CONST( SignalLength = 5 );
252 };
253 
254 struct SyncExtentPagesReq
255 {
256   enum LcpOrder
257   {
258     FIRST_LCP = 0,
259     END_LCP = 1,
260     RESTART_SYNC = 2,
261     FIRST_AND_END_LCP = 3
262   };
263   Uint32 senderData;
264   Uint32 senderRef;
265   LcpOrder lcpOrder;
266 
267   STATIC_CONST( SignalLength = 3 );
268 };
269 
270 struct SyncExtentPagesConf
271 {
272   Uint32 senderData;
273   Uint32 senderRef;
274 
275   STATIC_CONST( SignalLength = 2 );
276 };
277 
278 struct EndLcpReq
279 {
280   Uint32 senderData;
281   Uint32 senderRef;
282   Uint32 backupPtr;
283   Uint32 backupId;
284   // extra word for LQH worker to proxy
285   Uint32 proxyBlockNo;
286 
287   STATIC_CONST( SignalLength = 4 );
288 };
289 
290 struct EndLcpConf
291 {
292   Uint32 senderData;
293   Uint32 senderRef;
294 
295   STATIC_CONST( SignalLength = 2 );
296 };
297 
298 struct LcpStatusReq
299 {
300   /**
301    * Sender(s)
302    */
303   friend class Dblqh;
304 
305   /**
306    * Sender(s) / Receiver(s)
307    */
308 
309   /**
310    * Receiver(s)
311    */
312   friend class Backup;
313 
314   friend bool printLCP_STATUS_REQ(FILE *, const Uint32 *, Uint32, Uint16);
315 public:
316 
317   STATIC_CONST( SignalLength = 2 );
318 
319 private:
320   Uint32 senderRef;
321   Uint32 senderData;
322 };
323 
324 struct LcpStatusConf
325 {
326   /**
327    * Sender(s)
328    */
329   friend class Backup;
330 
331   /**
332    * Sender(s) / Receiver(s)
333    */
334 
335   /**
336    * Receiver(s)
337    */
338   friend class Dblqh;
339 
340   friend bool printLCP_STATUS_CONF(FILE *, const Uint32 *, Uint32, Uint16);
341 public:
342   STATIC_CONST( SignalLength = 12 );
343 
344   enum LcpState
345   {
346     LCP_IDLE       = 0,
347     LCP_PREPARED   = 1,
348     LCP_SCANNING   = 2,
349     LCP_SCANNED    = 3,
350     LCP_PREPARE_READ_CTL_FILES = 4,
351     LCP_PREPARE_OPEN_DATA_FILE = 5,
352     LCP_PREPARE_READ_TABLE_DESC = 6,
353     LCP_PREPARE_ABORTING = 7,
354     LCP_WAIT_END_LCP = 8,
355     LCP_PREPARE_WAIT_DROP_CASE = 9,
356     LCP_WAIT_SYNC_DISK = 10,
357     LCP_WAIT_SYNC_EXTENT = 11,
358     LCP_WAIT_WRITE_CTL_FILE = 12,
359     LCP_WAIT_CLOSE_EMPTY = 13,
360     LCP_WAIT_FINAL_SYNC_EXTENT = 14
361   };
362 private:
363   Uint32 senderRef;
364   Uint32 senderData;
365   /* Backup stuff */
366   Uint32 lcpState;
367   /* In lcpState == LCP_IDLE, refers to prev LCP
368    * otherwise, refers to current running LCP
369    */
370   Uint32 lcpDoneRowsHi;
371   Uint32 lcpDoneRowsLo;
372   Uint32 lcpDoneBytesHi;
373   Uint32 lcpDoneBytesLo;
374 
375   Uint32 tableId;
376   Uint32 fragId;
377   /* Backup stuff valid iff lcpState == LCP_SCANNING or
378    * LCP_SCANNED
379    * For LCP_SCANNING contains row count of rows scanned
380    *  (Increases as scan proceeds)
381    * For LCP_SCANNED contains bytes remaining to be flushed
382    * to file.
383    *  (Decreases as buffer drains to file)
384    *
385    * lcpScannedPages is number of pages scanned by TUP, it is possible
386    * to scan for a long while only finding LCP_SKIP records, so this
387    * is necessary to check as well for progress.
388    */
389   Uint32 completionStateHi;
390   Uint32 completionStateLo;
391 
392   Uint32 lcpScannedPages;
393 };
394 
395 struct LcpStatusRef
396 {
397   /**
398    * Sender(s)
399    */
400   friend class Backup;
401 
402   /**
403    * Sender(s) / Receiver(s)
404    */
405 
406   /**
407    * Receiver(s)
408    */
409   friend class Dblqh;
410 
411   friend bool printLCP_STATUS_REF(FILE *, const Uint32 *, Uint32, Uint16);
412 public:
413   STATIC_CONST( SignalLength = 3 );
414 
415   enum StatusFailCodes
416   {
417     NoLCPRecord    = 1,
418     NoTableRecord  = 2,
419     NoFileRecord   = 3
420   };
421 
422 private:
423   Uint32 senderRef;
424   Uint32 senderData;
425   Uint32 error;
426 };
427 
428 class PauseLcpReq
429 {
430 public:
431   STATIC_CONST (SignalLength = 3 );
432 
433   enum PauseAction
434   {
435     NoAction = 0,
436     Pause = 1,
437     UnPauseIncludedInLcp = 2,
438     UnPauseNotIncludedInLcp = 3
439   };
440   Uint32 senderRef;
441   Uint32 pauseAction;
442   Uint32 startNodeId;
443 };
444 
445 class PauseLcpConf
446 {
447 public:
448   STATIC_CONST (SignalLength = 2 );
449 
450   Uint32 senderRef;
451   Uint32 startNodeId;
452 };
453 
454 class FlushLcpRepReq
455 {
456 public:
457   STATIC_CONST (SignalLength = 2 );
458 
459   Uint32 senderRef;
460   Uint32 startNodeId;
461 };
462 
463 class FlushLcpRepConf
464 {
465 public:
466   STATIC_CONST (SignalLength = 2 );
467 
468   Uint32 senderRef;
469   Uint32 startNodeId;
470 };
471 
472 class WaitCompleteLcpConf
473 {
474 public:
475   STATIC_CONST (SignalLength = 5);
476 
477   Uint32 senderRef;
478   Uint32 lcpId;
479   Uint32 localLcpId;
480   Uint32 maxGciInLcp;
481   Uint32 maxKeepGci;
482 };
483 class LcpAllCompleteReq
484 {
485 public:
486   STATIC_CONST (SignalLength = 4);
487 
488   Uint32 senderRef;
489   Uint32 lcpId;
490   Uint32 maxGciInLcp;
491   Uint32 maxKeepGci;
492 };
493 
494 class GetLocalLcpIdConf
495 {
496 public:
497   STATIC_CONST (SignalLength = 2);
498 
499   Uint32 lcpId;
500   Uint32 localLcpId;
501 };
502 #undef JAM_FILE_ID
503 
504 #endif
505