MySQL 8.4.3
Source Code Documentation
ut0stage.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2014, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/ut0stage.h
29 Supplementary code to performance schema stage instrumentation.
30
31 Created Nov 12, 2014 Vasil Dimov
32 *******************************************************/
33
34#ifndef ut0stage_h
35#define ut0stage_h
36
37#include <math.h>
38#include <algorithm>
39
40#include "dict0mem.h" /* dict_index_t */
41#include "mysql/psi/mysql_stage.h" /* mysql_stage_inc_work_completed */
42#include "row0log.h" /* row_log_estimate_work() */
43#include "srv0srv.h" /* Alter_stage */
44
45// Forward declaration.
46class Alter_stage;
47using Alter_stages = std::vector<Alter_stage *, ut::allocator<Alter_stage *>>;
48
49#ifdef HAVE_PSI_STAGE_INTERFACE
50
51/** Class used to report ALTER TABLE progress via performance_schema.
52The only user of this class is the ALTER TABLE code and it calls the methods
53in the following order
54constructor
55begin_phase_read_pk()
56 multiple times:
57 n_pk_recs_inc() // once per record read
58 inc(1) // once per page read
59end_phase_read_pk()
60if any new indexes are being added, for each one:
61 begin_phase_sort()
62 multiple times:
63 inc(1) // once per every m_recs_req_for_prog records sorted
64 begin_phase_insert()
65 multiple times:
66 inc(1) // once per every m_recs_req_for_prog records inserted
67 being_phase_log_index()
68 multiple times:
69 inc() // once per log-block applied
70begin_phase_flush()
71 multiple times:
72 inc() // once per page flushed
73begin_phase_log_table()
74 multiple times:
75 inc() // once per log-block applied
76begin_phase_end()
77destructor
78
79This class knows the specifics of each phase and tries to increment the
80progress in an even manner across the entire ALTER TABLE lifetime. */
82 public:
83 /** Constructor.
84 @param[in] pk primary key of the old table */
85 explicit Alter_stage(const dict_index_t *pk) noexcept
86 : m_pk(pk), m_recs_req_for_prog(1), m_cur_phase(NOT_STARTED) {}
87
88 /** Copy constructor. "Inherits" the current state of rhs.
89 @param[in] rhs Instance to copy current state from. */
90 explicit Alter_stage(const Alter_stage &rhs) noexcept;
91
92 /** Destructor. */
94
95 /** Flag an ALTER TABLE start (read primary key phase).
96 @param[in] n_sort_indexes number of indexes that will be sorted
97 during ALTER TABLE, used for estimating the total work to be done */
98 void begin_phase_read_pk(size_t n_sort_indexes);
99
100 /** Increment the number of records in PK (table) with 1.
101 This is used to get more accurate estimate about the number of
102 records per page which is needed because some phases work on
103 per-page basis while some work on per-record basis and we want
104 to get the progress as even as possible.
105 @param[in] n Number of new records to report. */
106 void n_pk_recs_inc(uint64_t n = 1);
107
108 /** Flag either one record or one page processed, depending on the
109 current phase.
110 @param[in] inc_val flag this many units processed at once */
111 void inc(uint64_t inc_val);
112
113 /** Increment the progress if we have crossed the threshold
114 for unreported records, or if it is the last report.
115 @param[in, out] unreported_recs Number of records not updated to
116 Alter_stage up till now.
117 After reporting sets itself to 0.
118 @param[in] is_last_report if true, update the status irrespective
119 of number of unreported_recs.
120 */
121 void inc_progress_if_needed(uint64_t &unreported_recs,
122 bool is_last_report = false);
123
124 /** Flag the end of reading of the primary key.
125 Here we know the exact number of pages and records and calculate
126 the number of records per page and refresh the estimate. */
127 void end_phase_read_pk();
128
129 /** Flag the beginning of the sort phase.
130 @param[in] sort_multi_factor since merge sort processes
131 one page more than once we only update the estimate once per this
132 many pages processed. */
133 void begin_phase_sort(double sort_multi_factor);
134
135 /** Flag the beginning of the insert phase. */
136 void begin_phase_insert();
137
138 /** Flag the beginning of the flush phase.
139 @param[in] n_flush_pages this many pages are going to be
140 flushed */
141 void begin_phase_flush(page_no_t n_flush_pages);
142
143 /** Flag the beginning of the log index phase. */
145
146 /** Flag the beginning of the log table phase. */
148
149 /** Flag the beginning of the end phase. */
150 void begin_phase_end();
151
152 /** Aggregate the results of the build from the sub builds.
153 @param[in] alter_stages Sub stages to aggregate. */
154 void aggregate(const Alter_stages &alter_stages) noexcept;
155
156 private:
157 /** Check whether we have seen enough records to increment the progress.
158 @param[in] inc_val this many units processed up til now
159 @return true, if we have seen records as much to increment the progress. */
160 bool should_inc_progress(uint64_t inc_val) const;
161
162 /** Update the estimate of total work to be done. */
163 void reestimate();
164
165 /** Change the current phase.
166 @param[in] new_stage pointer to the new stage to change to */
167 void change_phase(const PSI_stage_info *new_stage);
168
169 private:
170 using Counter = std::pair<uint64_t, uint64_t>;
171 using Progress = std::pair<PSI_stage_progress *, Counter>;
172 using Stage = std::pair<const PSI_stage_info *, Progress>;
173 using Stages = std::vector<Stage, ut::allocator<Stage>>;
174
175 /** Progress counters for the various stages. */
177
178 /** Collection of all [previous + current] stages.
179 Can only be modified between stages. */
181
182 /** Mutex required to update values for m_n_pk_pages
183 and m_n_flush_pages.
184 We also use this mutex for reestimating & updating the progress,
185 as it is done parallelly by multiple threads.*/
187
188 /** Old table PK. Used for calculating the estimate. */
190
191 /** Number of records in the primary key (table), including delete
192 marked records. */
193 std::atomic<uint64_t> m_n_pk_recs{};
194
195 /** Number of leaf pages in the primary key. Protected by m_mutex. */
197
198 /** Estimated number of records per page in the primary key.
199 Can only be modified between stages. */
201
202 /** Number of records for which we increment the progress.
203 For READ_PK phase 1
204 For SORT phase m_n_recs_per_page * m_sort_multi_factor
205 For INSERT phase m_n_recs_per_page
206 Can only be modified between stages. */
208
209 /** Number of indexes that are being added.
210 Is only set during begin_phase_read_pk(). */
212
213 /** During the sort phase, increment the counter once per this
214 many pages processed. This is because sort processes one page more
215 than once. Can only be modified between stages. */
217
218 /** Number of pages to flush. Protected by m_mutex. */
220
221 /** Current phase. */
222 enum {
223 /** Init phase. */
225
226 /** Scan phase. */
228
229 /** Sort phase. */
230 SORT = 2,
231
232 /** Bulk load/insert phase. */
234
235 /** Flush non-redo logged pages phase. */
236 FLUSH = 4,
237
238 /** Apply entries from the row log to the index after creation. */
240
241 /** Apply entries from the row log to the table after the build. */
243
244 /** End/Stop. */
245 END = 7,
246 } m_cur_phase{NOT_STARTED};
247};
248
249inline Alter_stage::Alter_stage(const Alter_stage &rhs) noexcept
250 : m_pk(rhs.m_pk), m_recs_req_for_prog(1), m_cur_phase(NOT_STARTED) {}
251
253 auto progress = m_stage.second.first;
254
255 if (progress == nullptr) {
256 return;
257 }
258
259 /* Set completed = estimated before we quit. */
262
264}
265
266inline void Alter_stage::n_pk_recs_inc(uint64_t n) {
267 m_n_pk_recs.fetch_add(n, std::memory_order_relaxed);
268}
269
270inline void Alter_stage::inc(uint64_t inc_val) {
271 if (m_stages.empty()) {
272 return;
273 }
274
275 ut_a(m_cur_phase != NOT_STARTED);
276 {
278 if (m_cur_phase == READ_PK) {
279 ut_ad(inc_val == 1);
280 ++m_n_pk_pages;
281
282 /* Overall the read pk phase will read all the pages from the
283 PK and will do work, proportional to the number of added
284 indexes, thus when this is called once per read page we
285 increment with 1 + m_n_sort_indexes */
286 inc_val = 1 + m_n_sort_indexes;
287 }
288
289 auto progress = m_stages.back().second.first;
290 mysql_stage_inc_work_completed(progress, inc_val);
291 }
292 reestimate();
293}
294
295inline void Alter_stage::inc_progress_if_needed(uint64_t &unreported_recs,
296 bool is_last_report) {
297 if (m_stages.empty()) {
298 return;
299 }
300
301 if (should_inc_progress(unreported_recs) || is_last_report) {
302 /* Total estimate is based on pages. See reestimate()
303 Now that we have done task equivalent to 1 page,
304 increment progress by 1 */
305 inc(1);
306 /* All the rows have been updated to the progress. */
307 unreported_recs = 0;
308 }
309}
310
311inline void Alter_stage::begin_phase_read_pk(size_t n_sort_indexes) {
312 m_cur_phase = READ_PK;
313
314 m_n_sort_indexes = n_sort_indexes;
315
316 Stage stage{};
317
319 stage.second.first = mysql_set_stage(stage.first->m_key);
320
321 if (stage.second.first != nullptr) {
322 m_stages.push_back(stage);
323
324 auto progress = stage.second.first;
326
327 reestimate();
328 }
329}
330
332 reestimate();
333
334 /* PK reading is complete, and we have the final value for
335 m_n_pk_recs & m_n_pk_pages to calculate m_n_recs_per_page. */
336 if (m_n_pk_pages == 0) {
337 /* The number of pages in the PK could be 0 if the tree is
338 empty. In this case we set m_n_recs_per_page to 1 to avoid
339 division by zero later. */
340 m_n_recs_per_page = 1.0;
341 } else {
342 m_n_recs_per_page = std::max(
343 static_cast<double>(m_n_pk_recs.load(std::memory_order_relaxed)) /
345 1.0);
346 }
347}
348
349inline void Alter_stage::begin_phase_sort(double sort_multi_factor) {
350 if (sort_multi_factor <= 1.0) {
352 } else {
353 m_sort_multi_factor = static_cast<uint64_t>(round(sort_multi_factor));
354 }
356 static_cast<uint64_t>(m_sort_multi_factor * m_n_recs_per_page);
358}
359
362 m_recs_req_for_prog = static_cast<uint64_t>(m_n_recs_per_page);
363}
364
365inline void Alter_stage::begin_phase_flush(page_no_t n_flush_pages) {
366 {
368 m_n_flush_pages = n_flush_pages;
369 }
370
371 reestimate();
373}
374
377}
378
381}
382
385}
386
387inline bool Alter_stage::should_inc_progress(uint64_t inc_val) const {
388 /* We only need to increment the progress when we have seen
389 m_recs_req_for_prog. */
390 return inc_val >= m_recs_req_for_prog;
391}
392
394 if (m_stages.empty()) {
395 return;
396 }
397
399 /* During the log table phase we calculate the estimate as
400 work done so far + log size remaining. */
401 if (m_cur_phase == LOG_TABLE) {
402 auto progress = m_stages.back().second.first;
403
405 progress,
407
408 return;
409 }
410
411 /* During the other phases we use a formula, regardless of
412 how much work has been done so far. */
413
414 /* For number of pages in the PK - if the PK has not been
415 read yet, use stat_n_leaf_pages (approximate), otherwise
416 use the exact number we gathered. */
417 const page_no_t n_pk_pages =
418 m_cur_phase != READ_PK ? m_n_pk_pages : m_pk->stat_n_leaf_pages;
419
420 /* If flush phase has not started yet and we do not know how
421 many pages are to be flushed, then use a wild guess - the
422 number of pages in the PK / 2. */
423 if (m_n_flush_pages == 0) {
424 m_n_flush_pages = n_pk_pages / 2;
425 }
426
427 uint64_t estimate =
428 n_pk_pages *
429 (1 /* read PK */
430 + m_n_sort_indexes /* row_merge_buf_sort() inside the
431 read PK per created index */
432 + m_n_sort_indexes * 2 /* sort & insert per created index */) +
434
435 auto progress = m_stages.back().second.first;
436 const auto completed = (uint64_t)mysql_stage_get_work_completed(progress);
437
438 /* Prevent estimate < completed */
439 mysql_stage_set_work_estimated(progress, std::max(estimate, completed));
440}
441
442inline void Alter_stage::change_phase(const PSI_stage_info *new_stage) {
443 if (m_stages.empty()) {
444 return;
445 }
446
448
449 if (new_stage == &srv_stage_alter_table_merge_sort) {
450 m_cur_phase = SORT;
451 } else if (new_stage == &srv_stage_alter_table_insert) {
452 m_cur_phase = INSERT;
453 } else if (new_stage == &srv_stage_alter_table_flush) {
454 m_cur_phase = FLUSH;
455 } else if (new_stage == &srv_stage_alter_table_log_index) {
456 m_cur_phase = LOG_INDEX;
457 } else if (new_stage == &srv_stage_alter_table_log_table) {
458 m_cur_phase = LOG_TABLE;
459 } else if (new_stage == &srv_stage_alter_table_end) {
460 m_cur_phase = END;
461 } else {
462 ut_error;
463 }
464
465 auto progress = m_stages.back().second.first;
466
467 const auto c = mysql_stage_get_work_completed(progress);
468 const auto e = mysql_stage_get_work_estimated(progress);
469
470 Stage stage{new_stage, {mysql_set_stage(new_stage->m_key), {}}};
471
472 if (stage.second.first != nullptr) {
473 m_stages.push_back(stage);
474
475 auto &counter = m_stages.back().second.second;
476
477 counter.first = c;
478 counter.second = e;
479
480 mysql_stage_set_work_completed(stage.second.first, c);
481 mysql_stage_set_work_estimated(stage.second.first, e);
482 }
483}
484
485inline void Alter_stage::aggregate(const Alter_stages &alter_stages) noexcept {
486 if (alter_stages.empty()) {
487 return;
488 }
489
490 ut_a(m_cur_phase == NOT_STARTED);
491
492 Stage cur_stage{};
493
494 for (auto alter_stage : alter_stages) {
495 alter_stage->begin_phase_end();
496
497 for (auto stage : alter_stage->m_stages) {
498 if (stage.first == &srv_stage_alter_table_end) {
499 continue;
500 }
501 auto progress = mysql_set_stage(stage.first->m_key);
502
503 if (progress == nullptr) {
504 /* The user can disable the instrument clas and that can return
505 nullptr. That forces us to skip and will break the state transitions
506 and counts.*/
507 return;
508 }
509
510 auto c = mysql_stage_get_work_completed(progress);
511 auto e = mysql_stage_get_work_estimated(progress);
512
513 const auto &counter = stage.second.second;
514
515 c += counter.first;
516 e += counter.second;
517
520
522 if ((int)m_cur_phase < (int)READ_PK) {
523 m_cur_phase = READ_PK;
524 cur_stage.first = stage.first;
525 cur_stage.second.first = progress;
526 }
527 } else if (stage.first == &srv_stage_alter_table_merge_sort) {
528 if ((int)m_cur_phase < (int)NOT_STARTED) {
529 m_cur_phase = SORT;
530 cur_stage.first = stage.first;
531 cur_stage.second.first = progress;
532 }
533 } else if (stage.first == &srv_stage_alter_table_insert) {
534 if ((int)m_cur_phase < (int)SORT) {
535 m_cur_phase = INSERT;
536 cur_stage.first = stage.first;
537 cur_stage.second.first = progress;
538 }
539 } else if (stage.first == &srv_stage_alter_table_log_index) {
540 if ((int)m_cur_phase < (int)LOG_INDEX) {
541 m_cur_phase = LOG_INDEX;
542 cur_stage.first = stage.first;
543 cur_stage.second.first = progress;
544 }
545 }
546
547 ut_a(stage.first != &srv_stage_alter_table_flush);
548 ut_a(stage.first != &srv_stage_alter_table_log_table);
549 }
550 }
551
552 if (cur_stage.first != nullptr) {
553 ut_a(cur_stage.second.first != nullptr);
554 m_stages.push_back(cur_stage);
555 }
556}
557
558/** class to monitor the progress of 'ALTER TABLESPACE ENCRYPTION' in terms
559of number of pages operated upon. */
561 public:
562 /** Constructor. */
566 m_work_done(0),
568
569 /** Destructor. */
571 if (m_progress == nullptr) {
572 return;
573 }
575 }
576
577 /** Initialize.
578 @param[in] key PFS key. */
579 void init(int key) {
580 ut_ad(key != -1);
582
583 m_progress = nullptr;
585 m_work_done = 0;
586
588 /* Change phase to INITIATED */
589 change_phase();
590 }
591
592 /** Set estimate.
593 @param[in] units Units. */
594 void set_estimate(uint64_t units) {
595 if (m_progress == nullptr) {
596 return;
597 }
598
602 /* Change phase to WORK_ESTIMATED */
603 change_phase();
604 }
605
606 /** Update the progress.
607 @param[in] units Update delta. */
608 void update_work(uint64_t units) {
609 if (m_progress == nullptr) {
610 return;
611 }
612
614
618
620 /* Change phase to WORK_COMPLETED */
621 change_phase();
622 }
623 }
624
625 /** Change phase. */
627 if (m_progress == nullptr) {
629 return;
630 }
631
632 switch (m_cur_phase) {
633 case NOT_STARTED:
635 break;
636 case INITIATED:
638 break;
639 case WORK_ESTIMATED:
641 break;
642 case WORK_COMPLETED:
643 default:
644 ut_error;
645 }
646 }
647
649 if (m_progress == nullptr) {
650 return true;
651 } else {
652 return (m_cur_phase == WORK_COMPLETED);
653 }
654 }
655
656 private:
657 /** Performance schema accounting object. */
659
660 /** Number of pages to be (un)encrypted . */
662
663 /** Number of pages already (un)encrypted . */
665
666 /** Current phase. */
667 enum {
668 /** Not open phase. */
670
671 /** Initialised. */
673
674 /** Work estimated phase. */
676
677 /** Work completed phase. */
680};
681
682#else /* HAVE_PSI_STAGE_INTERFACE */
683
684/** Dummy alter stage. */
685class Alter_stage {
686 public:
687 /** Constructor. */
688 explicit Alter_stage(const dict_index_t *pk) {}
689
690 /** Setup the number of indexes to read.
691 @param[in] n_sort_indexes Number of indexe.s */
692 void begin_phase_read_pk(size_t n_sort_indexes) {}
693
694 /** Increments the number of rows read so far. */
695 void n_pk_recs_inc() {}
696
697 /** Increments the number of rows read so far. */
698 void n_pk_recs_inc(uint64_t) {}
699
700 /** Increment depending on stage. */
701 void inc(uint64_t inc_val = 1) {}
702
703 /** Increment the progress if we have crossed the threshold
704 for unreported records. */
705 void inc_progress_if_needed(uint64_t &unreported_recs,
706 bool is_last_report = false) {}
707
708 /** End scan phase. */
709 void end_phase_read_pk() {}
710
711 /** Begin merge sort phase. */
712 void begin_phase_sort(double sort_multi_factor) {}
713
714 /** Begin insert phase. */
715 void begin_phase_insert() {}
716
717 /** Begin flushing of non-redo logged pages.
718 @param[in] n_flush_pages Number of pages to flush. */
719 void begin_phase_flush(page_no_t n_flush_pages) {}
720
721 /** Begin row log apply phase to the index. */
722 void begin_phase_log_index() {}
723
724 /** Begin row log apply phase to the table. */
725 void begin_phase_log_table() {}
726
727 /** Build end phase. */
728 void begin_phase_end() {}
729
730 /** Aggregate the sub stages..
731 @param[in] stages Stages to aggregate. */
732 void aggregate(const Alter_stages &alter_stages) noexcept {}
733};
734
735class Alter_stage_ts {
736 public:
737 /** Constructor. */
738 Alter_stage_ts() {}
739
740 /** Destructor. */
741 inline ~Alter_stage_ts() {}
742
743 /** Initialize.
744 @param[in] key PFS key. */
745 void init(int key) {}
746
747 /** Set estimate.
748 @param[in] units Units. */
749 void set_estimate(uint units) {}
750
751 /** Update the progress.
752 @param[in] units Update delta. */
753 void update_work(uint units) {}
754
755 /** Change phase. */
756 void change_phase() {}
757};
758#endif /* HAVE_PSI_STAGE_INTERFACE */
759
760#endif /* ut0stage_h */
uint32_t page_no_t
Page number.
Definition: api0api.h:46
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
class to monitor the progress of 'ALTER TABLESPACE ENCRYPTION' in terms of number of pages operated u...
Definition: ut0stage.h:560
void set_estimate(uint64_t units)
Set estimate.
Definition: ut0stage.h:594
page_no_t m_work_done
Number of pages already (un)encrypted .
Definition: ut0stage.h:664
void change_phase()
Change phase.
Definition: ut0stage.h:626
void update_work(uint64_t units)
Update the progress.
Definition: ut0stage.h:608
Alter_stage_ts()
Constructor.
Definition: ut0stage.h:563
void init(int key)
Initialize.
Definition: ut0stage.h:579
PSI_stage_progress * m_progress
Performance schema accounting object.
Definition: ut0stage.h:658
enum Alter_stage_ts::@204 m_cur_phase
Current phase.
@ INITIATED
Initialised.
Definition: ut0stage.h:672
@ WORK_ESTIMATED
Work estimated phase.
Definition: ut0stage.h:675
@ WORK_COMPLETED
Work completed phase.
Definition: ut0stage.h:678
@ NOT_STARTED
Not open phase.
Definition: ut0stage.h:669
page_no_t m_work_estimated
Number of pages to be (un)encrypted .
Definition: ut0stage.h:661
~Alter_stage_ts()
Destructor.
Definition: ut0stage.h:570
bool is_completed()
Definition: ut0stage.h:648
Class used to report ALTER TABLE progress via performance_schema.
Definition: ut0stage.h:81
void change_phase(const PSI_stage_info *new_stage)
Change the current phase.
Definition: ut0stage.h:442
IB_mutex m_mutex
Mutex required to update values for m_n_pk_pages and m_n_flush_pages.
Definition: ut0stage.h:186
page_no_t m_n_flush_pages
Number of pages to flush.
Definition: ut0stage.h:219
void begin_phase_end()
Flag the beginning of the end phase.
Definition: ut0stage.h:383
void n_pk_recs_inc(uint64_t n=1)
Increment the number of records in PK (table) with 1.
Definition: ut0stage.h:266
void begin_phase_sort(double sort_multi_factor)
Flag the beginning of the sort phase.
Definition: ut0stage.h:349
bool should_inc_progress(uint64_t inc_val) const
Check whether we have seen enough records to increment the progress.
Definition: ut0stage.h:387
void begin_phase_read_pk(size_t n_sort_indexes)
Flag an ALTER TABLE start (read primary key phase).
Definition: ut0stage.h:311
std::pair< PSI_stage_progress *, Counter > Progress
Definition: ut0stage.h:171
size_t m_n_sort_indexes
Number of indexes that are being added.
Definition: ut0stage.h:211
double m_n_recs_per_page
Estimated number of records per page in the primary key.
Definition: ut0stage.h:200
void begin_phase_flush(page_no_t n_flush_pages)
Flag the beginning of the flush phase.
Definition: ut0stage.h:365
void aggregate(const Alter_stages &alter_stages) noexcept
Aggregate the results of the build from the sub builds.
Definition: ut0stage.h:485
Stages m_stages
Collection of all [previous + current] stages.
Definition: ut0stage.h:180
void reestimate()
Update the estimate of total work to be done.
Definition: ut0stage.h:393
uint64_t m_sort_multi_factor
During the sort phase, increment the counter once per this many pages processed.
Definition: ut0stage.h:216
const dict_index_t * m_pk
Old table PK.
Definition: ut0stage.h:189
void end_phase_read_pk()
Flag the end of reading of the primary key.
Definition: ut0stage.h:331
void begin_phase_log_table()
Flag the beginning of the log table phase.
Definition: ut0stage.h:379
page_no_t m_n_pk_pages
Number of leaf pages in the primary key.
Definition: ut0stage.h:196
Stage m_stage
Progress counters for the various stages.
Definition: ut0stage.h:176
@ FLUSH
Flush non-redo logged pages phase.
Definition: ut0stage.h:236
@ END
End/Stop.
Definition: ut0stage.h:245
@ READ_PK
Scan phase.
Definition: ut0stage.h:227
@ LOG_TABLE
Apply entries from the row log to the table after the build.
Definition: ut0stage.h:242
@ SORT
Sort phase.
Definition: ut0stage.h:230
@ INSERT
Bulk load/insert phase.
Definition: ut0stage.h:233
@ LOG_INDEX
Apply entries from the row log to the index after creation.
Definition: ut0stage.h:239
void begin_phase_insert()
Flag the beginning of the insert phase.
Definition: ut0stage.h:360
void inc_progress_if_needed(uint64_t &unreported_recs, bool is_last_report=false)
Increment the progress if we have crossed the threshold for unreported records, or if it is the last ...
Definition: ut0stage.h:295
std::atomic< uint64_t > m_n_pk_recs
Number of records in the primary key (table), including delete marked records.
Definition: ut0stage.h:193
enum Alter_stage::@203 NOT_STARTED
Current phase.
void begin_phase_log_index()
Flag the beginning of the log index phase.
Definition: ut0stage.h:375
Alter_stage(const dict_index_t *pk) noexcept
Constructor.
Definition: ut0stage.h:85
std::vector< Stage, ut::allocator< Stage > > Stages
Definition: ut0stage.h:173
void inc(uint64_t inc_val)
Flag either one record or one page processed, depending on the current phase.
Definition: ut0stage.h:270
std::pair< const PSI_stage_info *, Progress > Stage
Definition: ut0stage.h:172
uint64_t m_recs_req_for_prog
Number of records for which we increment the progress.
Definition: ut0stage.h:207
~Alter_stage()
Destructor.
Definition: ut0stage.h:252
Definition: ut0mutex.h:252
Data dictionary memory object creation.
#define mysql_set_stage(K)
Set the current stage.
Definition: mysql_stage.h:80
#define mysql_stage_inc_work_completed(P1, P2)
Definition: mysql_stage.h:131
#define mysql_end_stage
End the last stage.
Definition: mysql_stage.h:86
#define mysql_stage_get_work_completed(P1)
Definition: mysql_stage.h:118
#define mysql_stage_set_work_completed(P1, P2)
Definition: mysql_stage.h:115
#define mysql_stage_get_work_estimated(P1)
Definition: mysql_stage.h:143
#define mysql_stage_set_work_estimated(P1, P2)
Definition: mysql_stage.h:140
Instrumentation helpers for stages.
uint counter
Definition: mysqlimport.cc:58
Sharded atomic counter.
Definition: ut0counter.h:221
collation_unordered_map< std::string, Unit > units()
A function to obtaint the supported units for the gis module.
Definition: st_units_of_measure.cc:29
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Modification log for online index creation and online table rebuild.
ulint row_log_estimate_work(const dict_index_t *index)
Estimate how much work is to be done by the log apply phase of an ALTER TABLE for this index.
Definition: row0log.cc:2700
The server main program.
PSI_stage_info srv_stage_alter_table_log_table
Performance schema stage event for monitoring ALTER TABLE progress row_log_table_apply().
Definition: srv0srv.cc:828
PSI_stage_info srv_stage_alter_table_flush
Performance schema stage event for monitoring ALTER TABLE progress log_make_latest_checkpoint().
Definition: srv0srv.cc:813
PSI_stage_info srv_stage_alter_table_end
Performance schema stage event for monitoring ALTER TABLE progress everything after flush log_make_la...
Definition: srv0srv.cc:808
PSI_stage_info srv_stage_alter_table_read_pk_internal_sort
Performance schema stage event for monitoring ALTER TABLE progress row_merge_read_clustered_index().
Definition: srv0srv.cc:837
PSI_stage_info srv_stage_alter_table_insert
Performance schema stage event for monitoring ALTER TABLE progress row_merge_insert_index_tuples().
Definition: srv0srv.cc:817
PSI_stage_info srv_stage_alter_table_merge_sort
Performance schema stage event for monitoring ALTER TABLE progress row_merge_sort().
Definition: srv0srv.cc:833
PSI_stage_info srv_stage_alter_table_log_index
Performance schema stage event for monitoring ALTER TABLE progress row_log_apply().
Definition: srv0srv.cc:822
Definition: ut0mutex.h:128
Stage instrument information.
Definition: psi_stage_bits.h:74
PSI_stage_key m_key
The registered stage key.
Definition: psi_stage_bits.h:76
Interface for an instrumented stage progress.
Definition: psi_stage_bits.h:63
Data structure for an index.
Definition: dict0mem.h:1046
ulint stat_n_leaf_pages
approximate number of leaf pages in the index tree
Definition: dict0mem.h:1211
@ LATCH_ID_ALTER_STAGE
Definition: sync0types.h:348
#define UT_LOCATION_HERE
Definition: ut0core.h:73
#define ut_error
Abort execution.
Definition: ut0dbg.h:101
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:93
std::vector< Alter_stage *, ut::allocator< Alter_stage * > > Alter_stages
Definition: ut0stage.h:47
int n
Definition: xcom_base.cc:509