46using Alter_stages = std::vector<Alter_stage *, ut::allocator<Alter_stage *>>;
48#ifdef HAVE_PSI_STAGE_INTERFACE
113 void inc(uint64_t inc_val);
156 using Counter = std::pair<uint64_t, uint64_t>;
157 using Progress = std::pair<PSI_stage_progress *, Counter>;
158 using Stage = std::pair<const PSI_stage_info *, Progress>;
159 using Stages = std::vector<Stage, ut::allocator<Stage>>;
225 : m_pk(rhs.m_pk), m_cur_phase(NOT_STARTED) {}
228 auto progress =
m_stage.second.first;
230 if (progress ==
nullptr) {
252 uint64_t multi_factor{1};
253 bool should_proceed{
true};
255 switch (m_cur_phase) {
280 const uint64_t k =
static_cast<uint64_t
>(round(
m_n_inserted / every_nth));
281 const uint64_t nth =
static_cast<uint64_t
>(round(k * every_nth));
295 if (should_proceed) {
296 auto progress =
m_stages.back().second.first;
312 if (stage.second.first !=
nullptr) {
315 auto progress = stage.second.first;
332 static_cast<double>(
m_n_pk_recs.load(std::memory_order_relaxed)) /
339 if (sort_multi_factor <= 1.0) {
380 auto progress =
m_stages.back().second.first;
413 auto progress =
m_stages.back().second.first;
443 auto progress =
m_stages.back().second.first;
450 if (stage.second.first !=
nullptr) {
464 if (alter_stages.empty()) {
468 ut_a(m_cur_phase == NOT_STARTED);
472 for (
auto alter_stage : alter_stages) {
473 alter_stage->begin_phase_end();
475 for (
auto stage : alter_stage->m_stages) {
481 if (progress ==
nullptr) {
491 const auto &
counter = stage.second.second;
500 if ((
int)m_cur_phase < (
int)READ_PK) {
501 m_cur_phase = READ_PK;
502 cur_stage.first = stage.first;
503 cur_stage.second.first = progress;
506 if ((
int)m_cur_phase < (
int)NOT_STARTED) {
508 cur_stage.first = stage.first;
509 cur_stage.second.first = progress;
512 if ((
int)m_cur_phase < (
int)SORT) {
513 m_cur_phase = INSERT;
514 cur_stage.first = stage.first;
515 cur_stage.second.first = progress;
518 if ((
int)m_cur_phase < (
int)LOG_INDEX) {
519 m_cur_phase = LOG_INDEX;
520 cur_stage.first = stage.first;
521 cur_stage.second.first = progress;
530 if (cur_stage.first !=
nullptr) {
531 ut_a(cur_stage.second.first !=
nullptr);
532 m_stages.push_back(cur_stage);
679 void inc(uint64_t inc_val = 1) {}
uint32_t page_no_t
Page number.
Definition: api0api.h:48
class to monitor the progress of 'ALTER TABLESPACE ENCRYPTION' in terms of number of pages operated u...
Definition: ut0stage.h:538
void set_estimate(uint64_t units)
Set estimate.
Definition: ut0stage.h:572
@ INITIATED
Initialised.
Definition: ut0stage.h:650
@ WORK_ESTIMATED
Work estimated phase.
Definition: ut0stage.h:653
@ WORK_COMPLETED
Work completed phase.
Definition: ut0stage.h:656
@ NOT_STARTED
Not open phase.
Definition: ut0stage.h:647
page_no_t m_work_done
Number of pages already (un)encrypted .
Definition: ut0stage.h:642
enum Alter_stage_ts::@196 m_cur_phase
Current phase.
void change_phase()
Change phase.
Definition: ut0stage.h:604
void update_work(uint64_t units)
Update the progress.
Definition: ut0stage.h:586
Alter_stage_ts()
Constructor.
Definition: ut0stage.h:541
void init(int key)
Initialize.
Definition: ut0stage.h:557
PSI_stage_progress * m_progress
Performance schema accounting object.
Definition: ut0stage.h:636
page_no_t m_work_estimated
Number of pages to be (un)encrypted .
Definition: ut0stage.h:639
~Alter_stage_ts()
Destructor.
Definition: ut0stage.h:548
bool is_completed()
Definition: ut0stage.h:626
Class used to report ALTER TABLE progress via performance_schema.
Definition: ut0stage.h:80
void change_phase(const PSI_stage_info *new_stage)
Change the current phase.
Definition: ut0stage.h:420
@ FLUSH
Flush non-redo logged pages phase.
Definition: ut0stage.h:211
@ END
End/Stop.
Definition: ut0stage.h:220
@ READ_PK
Scan phase.
Definition: ut0stage.h:202
@ LOG_TABLE
Apply entries from the row log to the table after the build.
Definition: ut0stage.h:217
@ SORT
Sort phase.
Definition: ut0stage.h:205
@ INSERT
Bulk load/insert phase.
Definition: ut0stage.h:208
@ LOG_INDEX
Apply entries from the row log to the index after creation.
Definition: ut0stage.h:214
page_no_t m_n_flush_pages
Number of pages to flush.
Definition: ut0stage.h:194
void begin_phase_end()
Flag the beginning of the end phase.
Definition: ut0stage.h:368
void begin_phase_sort(double sort_multi_factor)
Flag the beginning of the sort phase.
Definition: ut0stage.h:338
void n_pk_recs_inc()
Increment the number of records in PK (table) with 1.
Definition: ut0stage.h:245
void begin_phase_read_pk(size_t n_sort_indexes)
Flag an ALTER TABLE start (read primary key phase).
Definition: ut0stage.h:302
uint64_t m_n_inserted
Number of records processed during sort & insert phases.
Definition: ut0stage.h:191
std::pair< PSI_stage_progress *, Counter > Progress
Definition: ut0stage.h:157
size_t m_n_sort_indexes
Number of indexes that are being added.
Definition: ut0stage.h:181
double m_n_recs_per_page
Estimated number of records per page in the primary key.
Definition: ut0stage.h:178
void begin_phase_flush(page_no_t n_flush_pages)
Flag the beginning of the flush phase.
Definition: ut0stage.h:352
void aggregate(const Alter_stages &alter_stages) noexcept
Aggregate the results of the build from the sub builds.
Definition: ut0stage.h:463
Stages m_stages
Collection of previous stages.
Definition: ut0stage.h:165
void reestimate()
Update the estimate of total work to be done.
Definition: ut0stage.h:372
uint64_t m_sort_multi_factor
During the sort phase, increment the counter once per this many pages processed.
Definition: ut0stage.h:186
const dict_index_t * m_pk
Old table PK.
Definition: ut0stage.h:168
void end_phase_read_pk()
Flag the end of reading of the primary key.
Definition: ut0stage.h:322
void begin_phase_log_table()
Flag the beginning of the log table phase.
Definition: ut0stage.h:364
page_no_t m_n_pk_pages
Number of leaf pages in the primary key.
Definition: ut0stage.h:175
Stage m_stage
Progress counters for the various stages.
Definition: ut0stage.h:162
void begin_phase_insert()
Flag the beginning of the insert phase.
Definition: ut0stage.h:348
std::atomic< uint64_t > m_n_pk_recs
Number of records in the primary key (table), including delete marked records.
Definition: ut0stage.h:172
void begin_phase_log_index()
Flag the beginning of the log index phase.
Definition: ut0stage.h:360
Alter_stage(const dict_index_t *pk) noexcept
Constructor.
Definition: ut0stage.h:84
std::vector< Stage, ut::allocator< Stage > > Stages
Definition: ut0stage.h:159
void inc(uint64_t inc_val)
Flag either one record or one page processed, depending on the current phase.
Definition: ut0stage.h:247
enum Alter_stage::@195 NOT_STARTED
Current phase.
std::pair< const PSI_stage_info *, Progress > Stage
Definition: ut0stage.h:158
~Alter_stage()
Destructor.
Definition: ut0stage.h:227
Data dictionary memory object creation.
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
#define mysql_set_stage(K)
Set the current stage.
Definition: mysql_stage.h:79
#define mysql_stage_inc_work_completed(P1, P2)
Definition: mysql_stage.h:130
#define mysql_end_stage
End the last stage.
Definition: mysql_stage.h:85
#define mysql_stage_get_work_completed(P1)
Definition: mysql_stage.h:117
#define mysql_stage_set_work_completed(P1, P2)
Definition: mysql_stage.h:114
#define mysql_stage_get_work_estimated(P1)
Definition: mysql_stage.h:142
#define mysql_stage_set_work_estimated(P1, P2)
Definition: mysql_stage.h:139
Instrumentation helpers for stages.
uint counter
Definition: mysqlimport.cc:53
Sharded atomic counter.
Definition: ut0counter.h:220
collation_unordered_map< std::string, Unit > units()
A function to obtaint the supported units for the gis module.
Definition: st_units_of_measure.cc:28
required string key
Definition: replication_asynchronous_connection_failover.proto:59
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:2699
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:825
PSI_stage_info srv_stage_alter_table_flush
Performance schema stage event for monitoring ALTER TABLE progress log_make_latest_checkpoint().
Definition: srv0srv.cc:810
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:805
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:834
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:814
PSI_stage_info srv_stage_alter_table_merge_sort
Performance schema stage event for monitoring ALTER TABLE progress row_merge_sort().
Definition: srv0srv.cc:830
PSI_stage_info srv_stage_alter_table_log_index
Performance schema stage event for monitoring ALTER TABLE progress row_log_apply().
Definition: srv0srv.cc:819
Stage instrument information.
Definition: psi_stage_bits.h:73
PSI_stage_key m_key
The registered stage key.
Definition: psi_stage_bits.h:75
Interface for an instrumented stage progress.
Definition: psi_stage_bits.h:62
Data structure for an index.
Definition: dict0mem.h:1045
ulint stat_n_leaf_pages
approximate number of leaf pages in the index tree
Definition: dict0mem.h:1210
unsigned int uint
Definition: uca9-dump.cc:74
#define ut_error
Abort execution.
Definition: ut0dbg.h:64
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:56
std::vector< Alter_stage *, ut::allocator< Alter_stage * > > Alter_stages
Definition: ut0stage.h:46
int n
Definition: xcom_base.cc:508