47using Alter_stages = std::vector<Alter_stage *, ut::allocator<Alter_stage *>>;
49#ifdef HAVE_PSI_STAGE_INTERFACE
111 void inc(uint64_t inc_val);
122 bool is_last_report =
false);
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>>;
250 : m_pk(rhs.m_pk), m_recs_req_for_prog(1), m_cur_phase(NOT_STARTED) {}
253 auto progress =
m_stage.second.first;
255 if (progress ==
nullptr) {
289 auto progress =
m_stages.back().second.first;
296 bool is_last_report) {
321 if (stage.second.first !=
nullptr) {
324 auto progress = stage.second.first;
343 static_cast<double>(
m_n_pk_recs.load(std::memory_order_relaxed)) /
350 if (sort_multi_factor <= 1.0) {
402 auto progress =
m_stages.back().second.first;
435 auto progress =
m_stages.back().second.first;
465 auto progress =
m_stages.back().second.first;
472 if (stage.second.first !=
nullptr) {
486 if (alter_stages.empty()) {
490 ut_a(m_cur_phase == NOT_STARTED);
494 for (
auto alter_stage : alter_stages) {
495 alter_stage->begin_phase_end();
497 for (
auto stage : alter_stage->m_stages) {
503 if (progress ==
nullptr) {
513 const auto &
counter = stage.second.second;
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;
528 if ((
int)m_cur_phase < (
int)NOT_STARTED) {
530 cur_stage.first = stage.first;
531 cur_stage.second.first = progress;
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;
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;
552 if (cur_stage.first !=
nullptr) {
553 ut_a(cur_stage.second.first !=
nullptr);
554 m_stages.push_back(cur_stage);
701 void inc(uint64_t inc_val = 1) {}
706 bool is_last_report =
false) {}
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
enum Alter_stage_ts::@206 m_cur_phase
Current phase.
void init(int key)
Initialize.
Definition: ut0stage.h:579
PSI_stage_progress * m_progress
Performance schema accounting object.
Definition: ut0stage.h:658
@ 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
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
@ 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
uint64_t m_recs_req_for_prog
Number of records for which we increment the progress.
Definition: ut0stage.h:207
enum Alter_stage::@205 NOT_STARTED
Current phase.
~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:2701
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:1041
ulint stat_n_leaf_pages
approximate number of leaf pages in the index tree
Definition: dict0mem.h:1206
@ 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