47using Alter_stages = std::vector<Alter_stage *, ut::allocator<Alter_stage *>>;
49#ifdef HAVE_PSI_STAGE_INTERFACE
114 void inc(uint64_t inc_val);
157 using Counter = std::pair<uint64_t, uint64_t>;
158 using Progress = std::pair<PSI_stage_progress *, Counter>;
159 using Stage = std::pair<const PSI_stage_info *, Progress>;
160 using Stages = std::vector<Stage, ut::allocator<Stage>>;
226 : m_pk(rhs.m_pk), m_cur_phase(NOT_STARTED) {}
229 auto progress =
m_stage.second.first;
231 if (progress ==
nullptr) {
253 uint64_t multi_factor{1};
254 bool should_proceed{
true};
256 switch (m_cur_phase) {
281 const uint64_t k =
static_cast<uint64_t
>(round(
m_n_inserted / every_nth));
282 const uint64_t nth =
static_cast<uint64_t
>(round(k * every_nth));
296 if (should_proceed) {
297 auto progress =
m_stages.back().second.first;
313 if (stage.second.first !=
nullptr) {
316 auto progress = stage.second.first;
333 static_cast<double>(
m_n_pk_recs.load(std::memory_order_relaxed)) /
340 if (sort_multi_factor <= 1.0) {
381 auto progress =
m_stages.back().second.first;
414 auto progress =
m_stages.back().second.first;
444 auto progress =
m_stages.back().second.first;
451 if (stage.second.first !=
nullptr) {
465 if (alter_stages.empty()) {
469 ut_a(m_cur_phase == NOT_STARTED);
473 for (
auto alter_stage : alter_stages) {
474 alter_stage->begin_phase_end();
476 for (
auto stage : alter_stage->m_stages) {
482 if (progress ==
nullptr) {
492 const auto &
counter = stage.second.second;
501 if ((
int)m_cur_phase < (
int)READ_PK) {
502 m_cur_phase = READ_PK;
503 cur_stage.first = stage.first;
504 cur_stage.second.first = progress;
507 if ((
int)m_cur_phase < (
int)NOT_STARTED) {
509 cur_stage.first = stage.first;
510 cur_stage.second.first = progress;
513 if ((
int)m_cur_phase < (
int)SORT) {
514 m_cur_phase = INSERT;
515 cur_stage.first = stage.first;
516 cur_stage.second.first = progress;
519 if ((
int)m_cur_phase < (
int)LOG_INDEX) {
520 m_cur_phase = LOG_INDEX;
521 cur_stage.first = stage.first;
522 cur_stage.second.first = progress;
531 if (cur_stage.first !=
nullptr) {
532 ut_a(cur_stage.second.first !=
nullptr);
533 m_stages.push_back(cur_stage);
680 void inc(uint64_t inc_val = 1) {}
uint32_t page_no_t
Page number.
Definition: api0api.h:45
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:539
void set_estimate(uint64_t units)
Set estimate.
Definition: ut0stage.h:573
page_no_t m_work_done
Number of pages already (un)encrypted .
Definition: ut0stage.h:643
void change_phase()
Change phase.
Definition: ut0stage.h:605
void update_work(uint64_t units)
Update the progress.
Definition: ut0stage.h:587
Alter_stage_ts()
Constructor.
Definition: ut0stage.h:542
void init(int key)
Initialize.
Definition: ut0stage.h:558
PSI_stage_progress * m_progress
Performance schema accounting object.
Definition: ut0stage.h:637
enum Alter_stage_ts::@204 m_cur_phase
Current phase.
@ INITIATED
Initialised.
Definition: ut0stage.h:651
@ WORK_ESTIMATED
Work estimated phase.
Definition: ut0stage.h:654
@ WORK_COMPLETED
Work completed phase.
Definition: ut0stage.h:657
@ NOT_STARTED
Not open phase.
Definition: ut0stage.h:648
page_no_t m_work_estimated
Number of pages to be (un)encrypted .
Definition: ut0stage.h:640
~Alter_stage_ts()
Destructor.
Definition: ut0stage.h:549
bool is_completed()
Definition: ut0stage.h:627
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:421
page_no_t m_n_flush_pages
Number of pages to flush.
Definition: ut0stage.h:195
void begin_phase_end()
Flag the beginning of the end phase.
Definition: ut0stage.h:369
void begin_phase_sort(double sort_multi_factor)
Flag the beginning of the sort phase.
Definition: ut0stage.h:339
void n_pk_recs_inc()
Increment the number of records in PK (table) with 1.
Definition: ut0stage.h:246
void begin_phase_read_pk(size_t n_sort_indexes)
Flag an ALTER TABLE start (read primary key phase).
Definition: ut0stage.h:303
uint64_t m_n_inserted
Number of records processed during sort & insert phases.
Definition: ut0stage.h:192
std::pair< PSI_stage_progress *, Counter > Progress
Definition: ut0stage.h:158
size_t m_n_sort_indexes
Number of indexes that are being added.
Definition: ut0stage.h:182
double m_n_recs_per_page
Estimated number of records per page in the primary key.
Definition: ut0stage.h:179
void begin_phase_flush(page_no_t n_flush_pages)
Flag the beginning of the flush phase.
Definition: ut0stage.h:353
void aggregate(const Alter_stages &alter_stages) noexcept
Aggregate the results of the build from the sub builds.
Definition: ut0stage.h:464
Stages m_stages
Collection of previous stages.
Definition: ut0stage.h:166
void reestimate()
Update the estimate of total work to be done.
Definition: ut0stage.h:373
uint64_t m_sort_multi_factor
During the sort phase, increment the counter once per this many pages processed.
Definition: ut0stage.h:187
const dict_index_t * m_pk
Old table PK.
Definition: ut0stage.h:169
void end_phase_read_pk()
Flag the end of reading of the primary key.
Definition: ut0stage.h:323
void begin_phase_log_table()
Flag the beginning of the log table phase.
Definition: ut0stage.h:365
page_no_t m_n_pk_pages
Number of leaf pages in the primary key.
Definition: ut0stage.h:176
Stage m_stage
Progress counters for the various stages.
Definition: ut0stage.h:163
@ FLUSH
Flush non-redo logged pages phase.
Definition: ut0stage.h:212
@ END
End/Stop.
Definition: ut0stage.h:221
@ READ_PK
Scan phase.
Definition: ut0stage.h:203
@ LOG_TABLE
Apply entries from the row log to the table after the build.
Definition: ut0stage.h:218
@ SORT
Sort phase.
Definition: ut0stage.h:206
@ INSERT
Bulk load/insert phase.
Definition: ut0stage.h:209
@ LOG_INDEX
Apply entries from the row log to the index after creation.
Definition: ut0stage.h:215
void begin_phase_insert()
Flag the beginning of the insert phase.
Definition: ut0stage.h:349
std::atomic< uint64_t > m_n_pk_recs
Number of records in the primary key (table), including delete marked records.
Definition: ut0stage.h:173
enum Alter_stage::@203 NOT_STARTED
Current phase.
void begin_phase_log_index()
Flag the beginning of the log index phase.
Definition: ut0stage.h:361
Alter_stage(const dict_index_t *pk) noexcept
Constructor.
Definition: ut0stage.h:85
std::vector< Stage, ut::allocator< Stage > > Stages
Definition: ut0stage.h:160
void inc(uint64_t inc_val)
Flag either one record or one page processed, depending on the current phase.
Definition: ut0stage.h:248
std::pair< const PSI_stage_info *, Progress > Stage
Definition: ut0stage.h:159
~Alter_stage()
Destructor.
Definition: ut0stage.h:228
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
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
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
#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