MySQL 26.7.0
Source Code Documentation
ut0stage.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2014, 2026, 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
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 {
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->stats.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 ut_a_ne(m_cur_phase, LOG_INDEX);
457 m_cur_phase = LOG_INDEX;
458 } else if (new_stage == &srv_stage_alter_table_log_table) {
459 m_cur_phase = LOG_TABLE;
460 } else if (new_stage == &srv_stage_alter_table_end) {
461 m_cur_phase = END;
462 } else {
463 ut_error;
464 }
465
466 auto progress = m_stages.back().second.first;
467
468 const auto c = mysql_stage_get_work_completed(progress);
469 const auto e = mysql_stage_get_work_estimated(progress);
470
471 Stage stage{new_stage, {mysql_set_stage(new_stage->m_key), {}}};
472
473 if (stage.second.first != nullptr) {
474 m_stages.push_back(stage);
475
476 auto &counter = m_stages.back().second.second;
477
478 counter.first = c;
479 counter.second = e;
480
481 mysql_stage_set_work_completed(stage.second.first, c);
482 mysql_stage_set_work_estimated(stage.second.first, e);
483 }
484}
485
486inline void Alter_stage::aggregate(const Alter_stages &alter_stages) noexcept {
487 if (alter_stages.empty()) {
488 return;
489 }
490
491 ut_a(m_cur_phase == NOT_STARTED);
492
493 Stage cur_stage{};
494
495 for (auto alter_stage : alter_stages) {
496 alter_stage->begin_phase_end();
497
498 for (auto stage : alter_stage->m_stages) {
499 if (stage.first == &srv_stage_alter_table_end) {
500 continue;
501 }
502 auto progress = mysql_set_stage(stage.first->m_key);
503
504 if (progress == nullptr) {
505 /* The user can disable the instrument clas and that can return
506 nullptr. That forces us to skip and will break the state transitions
507 and counts.*/
508 return;
509 }
510
511 auto c = mysql_stage_get_work_completed(progress);
512 auto e = mysql_stage_get_work_estimated(progress);
513
514 const auto &counter = stage.second.second;
515
516 c += counter.first;
517 e += counter.second;
518
521
523 if ((int)m_cur_phase < (int)READ_PK) {
524 m_cur_phase = READ_PK;
525 cur_stage.first = stage.first;
526 cur_stage.second.first = progress;
527 }
528 } else if (stage.first == &srv_stage_alter_table_merge_sort) {
529 if ((int)m_cur_phase < (int)NOT_STARTED) {
530 m_cur_phase = SORT;
531 cur_stage.first = stage.first;
532 cur_stage.second.first = progress;
533 }
534 } else if (stage.first == &srv_stage_alter_table_insert) {
535 if ((int)m_cur_phase < (int)SORT) {
536 m_cur_phase = INSERT;
537 cur_stage.first = stage.first;
538 cur_stage.second.first = progress;
539 }
540 } else if (stage.first == &srv_stage_alter_table_log_index) {
541 if ((int)m_cur_phase < (int)LOG_INDEX) {
542 m_cur_phase = LOG_INDEX;
543 cur_stage.first = stage.first;
544 cur_stage.second.first = progress;
545 }
546 }
547
548 ut_a(stage.first != &srv_stage_alter_table_flush);
549 ut_a(stage.first != &srv_stage_alter_table_log_table);
550 }
551 }
552
553 if (cur_stage.first != nullptr) {
554 ut_a(cur_stage.second.first != nullptr);
555 m_stages.push_back(cur_stage);
556 }
557}
558
559/** class to monitor the progress of 'ALTER TABLESPACE ENCRYPTION' in terms
560of number of pages operated upon. */
562 public:
563 /** Constructor. */
567 m_work_done(0),
569
570 /** Destructor. */
572 if (m_progress == nullptr) {
573 return;
574 }
576 }
577
578 /** Initialize.
579 @param[in] key PFS key. */
580 void init(int key) {
581 ut_ad(key != -1);
583
584 m_progress = nullptr;
586 m_work_done = 0;
587
589 /* Change phase to INITIATED */
590 change_phase();
591 }
592
593 /** Set estimate.
594 @param[in] units Units. */
595 void set_estimate(uint64_t units) {
596 if (m_progress == nullptr) {
597 return;
598 }
599
603 /* Change phase to WORK_ESTIMATED */
604 change_phase();
605 }
606
607 /** Update the progress.
608 @param[in] units Update delta. */
609 void update_work(uint64_t units) {
610 if (m_progress == nullptr) {
611 return;
612 }
613
615
619
621 /* Change phase to WORK_COMPLETED */
622 change_phase();
623 }
624 }
625
626 /** Change phase. */
628 if (m_progress == nullptr) {
630 return;
631 }
632
633 switch (m_cur_phase) {
634 case NOT_STARTED:
636 break;
637 case INITIATED:
639 break;
640 case WORK_ESTIMATED:
642 break;
643 case WORK_COMPLETED:
644 default:
645 ut_error;
646 }
647 }
648
650 if (m_progress == nullptr) {
651 return true;
652 } else {
653 return (m_cur_phase == WORK_COMPLETED);
654 }
655 }
656
657 private:
658 /** Performance schema accounting object. */
660
661 /** Number of pages to be (un)encrypted . */
663
664 /** Number of pages already (un)encrypted . */
666
667 /** Current phase. */
668 enum {
669 /** Not open phase. */
671
672 /** Initialised. */
674
675 /** Work estimated phase. */
677
678 /** Work completed phase. */
681};
682
683#else /* HAVE_PSI_STAGE_INTERFACE */
684
685/** Dummy alter stage. */
686class Alter_stage {
687 public:
688 /** Constructor. */
689 explicit Alter_stage(const dict_index_t *pk) {}
690
691 /** Setup the number of indexes to read.
692 @param[in] n_sort_indexes Number of indexe.s */
693 void begin_phase_read_pk(size_t n_sort_indexes) {}
694
695 /** Increments the number of rows read so far. */
696 void n_pk_recs_inc() {}
697
698 /** Increments the number of rows read so far. */
699 void n_pk_recs_inc(uint64_t) {}
700
701 /** Increment depending on stage. */
702 void inc(uint64_t inc_val = 1) {}
703
704 /** Increment the progress if we have crossed the threshold
705 for unreported records. */
706 void inc_progress_if_needed(uint64_t &unreported_recs,
707 bool is_last_report = false) {}
708
709 /** End scan phase. */
710 void end_phase_read_pk() {}
711
712 /** Begin merge sort phase. */
713 void begin_phase_sort(double sort_multi_factor) {}
714
715 /** Begin insert phase. */
716 void begin_phase_insert() {}
717
718 /** Begin flushing of non-redo logged pages.
719 @param[in] n_flush_pages Number of pages to flush. */
720 void begin_phase_flush(page_no_t n_flush_pages) {}
721
722 /** Begin row log apply phase to the index. */
723 void begin_phase_log_index() {}
724
725 /** Begin row log apply phase to the table. */
726 void begin_phase_log_table() {}
727
728 /** Build end phase. */
729 void begin_phase_end() {}
730
731 /** Aggregate the sub stages..
732 @param[in] stages Stages to aggregate. */
733 void aggregate(const Alter_stages &alter_stages) noexcept {}
734};
735
736class Alter_stage_ts {
737 public:
738 /** Constructor. */
739 Alter_stage_ts() {}
740
741 /** Destructor. */
742 inline ~Alter_stage_ts() {}
743
744 /** Initialize.
745 @param[in] key PFS key. */
746 void init(int key) {}
747
748 /** Set estimate.
749 @param[in] units Units. */
750 void set_estimate(uint units) {}
751
752 /** Update the progress.
753 @param[in] units Update delta. */
754 void update_work(uint units) {}
755
756 /** Change phase. */
757 void change_phase() {}
758};
759#endif /* HAVE_PSI_STAGE_INTERFACE */
760
761#endif /* ut0stage_h */
uint32_t page_no_t
Page number.
Definition: api0api.h:47
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
class to monitor the progress of 'ALTER TABLESPACE ENCRYPTION' in terms of number of pages operated u...
Definition: ut0stage.h:561
void set_estimate(uint64_t units)
Set estimate.
Definition: ut0stage.h:595
page_no_t m_work_done
Number of pages already (un)encrypted .
Definition: ut0stage.h:665
enum Alter_stage_ts::@209 m_cur_phase
Current phase.
void change_phase()
Change phase.
Definition: ut0stage.h:627
void update_work(uint64_t units)
Update the progress.
Definition: ut0stage.h:609
Alter_stage_ts()
Constructor.
Definition: ut0stage.h:564
void init(int key)
Initialize.
Definition: ut0stage.h:580
PSI_stage_progress * m_progress
Performance schema accounting object.
Definition: ut0stage.h:659
page_no_t m_work_estimated
Number of pages to be (un)encrypted .
Definition: ut0stage.h:662
@ INITIATED
Initialised.
Definition: ut0stage.h:673
@ WORK_ESTIMATED
Work estimated phase.
Definition: ut0stage.h:676
@ WORK_COMPLETED
Work completed phase.
Definition: ut0stage.h:679
@ NOT_STARTED
Not open phase.
Definition: ut0stage.h:670
~Alter_stage_ts()
Destructor.
Definition: ut0stage.h:571
bool is_completed()
Definition: ut0stage.h:649
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
enum Alter_stage::@208 NOT_STARTED
Current phase.
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
@ 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
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:486
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
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
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:253
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
ValueType max(X &&first)
Definition: gtid.h:103
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
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:2720
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:818
PSI_stage_info srv_stage_alter_table_flush
Performance schema stage event for monitoring ALTER TABLE progress pages_persistence->request_sharp_c...
Definition: srv0srv.cc:803
PSI_stage_info srv_stage_alter_table_end
Performance schema stage event for monitoring ALTER TABLE progress everything after flush pages_persi...
Definition: srv0srv.cc:798
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:827
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:807
PSI_stage_info srv_stage_alter_table_merge_sort
Performance schema stage event for monitoring ALTER TABLE progress row_merge_sort().
Definition: srv0srv.cc:823
PSI_stage_info srv_stage_alter_table_log_index
Performance schema stage event for monitoring ALTER TABLE progress row_log_apply().
Definition: srv0srv.cc:812
Definition: ut0mutex.h:127
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
ulint n_leaf_pages
approximate number of leaf pages in the index tree
Definition: dict0mem.h:1048
Data structure for an index.
Definition: dict0mem.h:1069
dict_index_stats_t stats
Statistics for query optimization.
Definition: dict0mem.h:1216
@ LATCH_ID_ALTER_STAGE
Definition: sync0types.h:345
#define UT_LOCATION_HERE
Definition: ut0core.h:73
#define ut_error
Abort execution.
Definition: ut0dbg.h:105
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:109
#define ut_a_ne(LHS, RHS)
Assert that LHS != RHS.
Definition: ut0dbg.h:93
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:97
std::vector< Alter_stage *, ut::allocator< Alter_stage * > > Alter_stages
Definition: ut0stage.h:47
int n
Definition: xcom_base.cc:509