MySQL 26.7.0
Source Code Documentation
table_replication_applier_status_by_worker.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2013, 2026, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25#ifndef TABLE_REPLICATION_APPLIER_STATUS_BY_WORKER_H
26#define TABLE_REPLICATION_APPLIER_STATUS_BY_WORKER_H
27
28/**
29 @file storage/perfschema/table_replication_applier_status_by_worker.h
30 Table replication_applier_status_by_worker (declarations).
31*/
32
33#include <sys/types.h>
34
35#include <optional>
36#include "my_base.h"
37#include "my_inttypes.h"
39#include "sql/rpl_gtid.h"
40#include "sql/rpl_info.h" /*CHANNEL_NAME_LENGTH*/
41#include "sql/rpl_reporting.h"
44
45class Field;
46class Master_info;
47class Plugin_table;
48class Slave_worker;
49struct TABLE;
50struct THR_LOCK;
51struct mysql_mutex_t;
52
53/**
54 @addtogroup performance_schema_tables
55 @{
56*/
57
58#ifndef ENUM_RPL_YES_NO
59#define ENUM_RPL_YES_NO
60/** enumerated values for service_state of worker thread*/
62 PS_RPL_YES = 1, /* service_state= on */
63 PS_RPL_NO /* service_state= off */
64};
65#endif
66
67/*
68 A row in worker's table. The fields with string values have an additional
69 length field denoted by <field_name>_length.
70*/
74 /*
75 worker_id is added to the table because thread is killed at STOP REPLICA
76 but the status needs to show up, so worker_id is used as a permanent
77 identifier.
78 */
108};
109
110/**
111 Position in table replication_applier_status_by_worker.
112 Index 1 for replication channel.
113 Index 2 for worker:
114 - position [0] is for Single Thread Slave (Master_info)
115 - position [1] .. [N] is for Multi Thread Slave (Slave_worker)
116*/
119
120 inline void reset() {
121 m_index_1 = 0;
122 m_index_2 = 0;
123 }
124
125 inline bool has_more_channels(uint num) { return (m_index_1 < num); }
126
127 inline void next_channel() {
128 m_index_1++;
129 m_index_2 = 0;
130 }
131
132 inline void next_worker() { m_index_2++; }
133
134 inline void set_channel_after(
136 m_index_1 = other->m_index_1 + 1;
137 m_index_2 = 0;
138 }
139};
140
142 public:
145
147 PFS_engine_key *key_2)
148 : PFS_engine_index(key_1, key_2) {}
149
151
152 virtual bool match(Master_info *mi) = 0;
153 virtual bool match(Master_info *mi, std::optional<ulonglong> internal_id) = 0;
154 virtual std::optional<ulonglong> extract_id(Slave_worker *worker) = 0;
155 virtual std::optional<ulonglong> extract_id(
157};
158
161 public:
164 m_key_1("CHANNEL_NAME"),
165 m_key_2("WORKER_ID") {}
166
168
169 bool match(Master_info *mi) override;
170 bool match(Master_info *mi, std::optional<ulonglong> internal_id) override;
171 std::optional<ulonglong> extract_id(Slave_worker *worker) override;
172 std::optional<ulonglong> extract_id(
174
175 private:
178};
179
182 public:
185
187
188 bool match(Master_info *mi) override;
189 bool match(Master_info *mi, std::optional<ulonglong> internal_id) override;
190 std::optional<ulonglong> extract_id(Slave_worker *worker) override;
191 std::optional<ulonglong> extract_id(
193
194 private:
196};
197
198/** Table PERFORMANCE_SCHEMA.replication_applier_status_by_worker */
201
202 private:
203 int make_row(Slave_worker *);
204 /*
205 Master_info to construct a row to display SQL Thread's status
206 information in STS mode
207 */
208 int make_row(Master_info *);
209
210 /// @brief Constructs row from CSA data
211 /// @param stats Extracted statistics
213
214 void populate_trx_info(Trx_monitoring_info const &applying_trx,
215 Trx_monitoring_info const &last_applied_trx);
216
217 /** Table share lock. */
219 /** Table definition. */
221
222 /** current row. */
224 /** Current position. */
226 /** Next position. */
228
229 protected:
230 /**
231 Read the current row values.
232 @param table Table handle
233 @param buf row buffer
234 @param fields Table fields
235 @param read_all true if all columns are read.
236 */
237
238 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
239 bool read_all) override;
240
242
243 public:
245
246 /** Table share. */
249 static ha_rows get_row_count();
250 void reset_position() override;
251
252 int rnd_next() override;
253 int rnd_pos(const void *pos) override;
254
255 int index_init(uint idx, bool sorted) override;
256 int index_next() override;
257
258 private:
260};
261
262/** @} */
263#endif
Definition: field.h:573
Definition: rpl_mi.h:87
Definition: pfs_engine_table.h:301
Definition: pfs_engine_table.h:268
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:70
Definition: table_replication_applier_status_by_worker.h:160
PFS_index_rpl_applier_status_by_worker_by_channel()
Definition: table_replication_applier_status_by_worker.h:162
PFS_key_name m_key_1
Definition: table_replication_applier_status_by_worker.h:176
bool match(Master_info *mi) override
Definition: table_replication_applier_status_by_worker.cc:127
~PFS_index_rpl_applier_status_by_worker_by_channel() override=default
std::optional< ulonglong > extract_id(Slave_worker *worker) override
Definition: table_replication_applier_status_by_worker.cc:151
PFS_key_worker_id m_key_2
Definition: table_replication_applier_status_by_worker.h:177
Definition: table_replication_applier_status_by_worker.h:181
PFS_key_thread_id m_key
Definition: table_replication_applier_status_by_worker.h:195
~PFS_index_rpl_applier_status_by_worker_by_thread() override=default
bool match(Master_info *mi) override
Definition: table_replication_applier_status_by_worker.cc:190
std::optional< ulonglong > extract_id(Slave_worker *worker) override
Definition: table_replication_applier_status_by_worker.cc:219
PFS_index_rpl_applier_status_by_worker_by_thread()
Definition: table_replication_applier_status_by_worker.h:183
Definition: table_replication_applier_status_by_worker.h:141
virtual bool match(Master_info *mi, std::optional< ulonglong > internal_id)=0
~PFS_index_rpl_applier_status_by_worker() override=default
virtual bool match(Master_info *mi)=0
virtual std::optional< ulonglong > extract_id(const mysql::csa::Session_legacy_stats &stats)=0
PFS_index_rpl_applier_status_by_worker(PFS_engine_key *key)
Definition: table_replication_applier_status_by_worker.h:143
PFS_index_rpl_applier_status_by_worker(PFS_engine_key *key_1, PFS_engine_key *key_2)
Definition: table_replication_applier_status_by_worker.h:146
virtual std::optional< ulonglong > extract_id(Slave_worker *worker)=0
Definition: table_helper.h:1573
Definition: table_helper.h:1281
Definition: table_helper.h:1348
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Definition: rpl_rli_pdb.h:470
Table PERFORMANCE_SCHEMA.replication_applier_status_by_worker.
Definition: table_replication_applier_status_by_worker.h:199
pos_replication_applier_status_by_worker pos_t
Definition: table_replication_applier_status_by_worker.h:200
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_replication_applier_status_by_worker.cc:282
static Plugin_table m_table_def
Table definition.
Definition: table_replication_applier_status_by_worker.h:220
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_replication_applier_status_by_worker.cc:258
static THR_LOCK m_table_lock
Table share lock.
Definition: table_replication_applier_status_by_worker.h:218
PFS_index_rpl_applier_status_by_worker * m_opened_index
Definition: table_replication_applier_status_by_worker.h:259
static ha_rows get_row_count()
Definition: table_replication_applier_status_by_worker.cc:275
pos_t m_next_pos
Next position.
Definition: table_replication_applier_status_by_worker.h:227
int index_init(uint idx, bool sorted) override
Definition: table_replication_applier_status_by_worker.cc:398
void populate_trx_info(Trx_monitoring_info const &applying_trx, Trx_monitoring_info const &last_applied_trx)
Auxiliary function to populate the transaction information fields.
Definition: table_replication_applier_status_by_worker.cc:669
pos_t m_pos
Current position.
Definition: table_replication_applier_status_by_worker.h:225
st_row_worker m_row
current row.
Definition: table_replication_applier_status_by_worker.h:223
table_replication_applier_status_by_worker()
Definition: table_replication_applier_status_by_worker.cc:264
static PFS_engine_table_share m_share
Table share.
Definition: table_replication_applier_status_by_worker.h:247
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_replication_applier_status_by_worker.cc:270
int index_next() override
Find key in index, read record.
Definition: table_replication_applier_status_by_worker.cc:417
int make_row(Slave_worker *)
Definition: table_replication_applier_status_by_worker.cc:604
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_replication_applier_status_by_worker.cc:344
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_replication_applier_status_by_worker.cc:697
@ PS_RPL_NO
Definition: table_replication_applier_status_by_worker.h:63
@ PS_RPL_YES
Definition: table_replication_applier_status_by_worker.h:62
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1228
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: buf0block_hint.cc:30
Performance schema tables (declarations).
required string key
Definition: replication_asynchronous_connection_failover.proto:60
#define CHANNEL_NAME_LENGTH
Definition: rpl_info.h:41
#define MAX_SLAVE_ERRMSG
Maximum size of an error message from a slave thread.
Definition: rpl_reporting.h:43
static const int MAX_TEXT_LENGTH
The maximal length of the textual representation of a TSID, not including the terminating '\0'.
Definition: rpl_gtid.h:1139
Position of a double cursor, for iterations using 2 nested loops.
Definition: pfs_engine_table.h:602
uint m_index_1
Outer index.
Definition: pfs_engine_table.h:604
uint m_index_2
Current index within index_1.
Definition: pfs_engine_table.h:606
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:359
Definition: table.h:1456
Definition: thr_lock.h:139
Structure to store the GTID and timing information.
Definition: rpl_gtid.h:1264
Aggregates MTA legacy statistics.
Definition: session_legacy_stats.h:34
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
Position in table replication_applier_status_by_worker.
Definition: table_replication_applier_status_by_worker.h:117
void next_channel()
Definition: table_replication_applier_status_by_worker.h:127
bool has_more_channels(uint num)
Definition: table_replication_applier_status_by_worker.h:125
pos_replication_applier_status_by_worker()
Definition: table_replication_applier_status_by_worker.h:118
void set_channel_after(const pos_replication_applier_status_by_worker *other)
Definition: table_replication_applier_status_by_worker.h:134
void reset()
Definition: table_replication_applier_status_by_worker.h:120
void next_worker()
Definition: table_replication_applier_status_by_worker.h:132
Definition: table_replication_applier_status_by_worker.h:71
char channel_name[CHANNEL_NAME_LENGTH]
Definition: table_replication_applier_status_by_worker.h:72
ulonglong applying_trx_start_apply_timestamp
Definition: table_replication_applier_status_by_worker.h:97
ulonglong last_error_timestamp
Definition: table_replication_applier_status_by_worker.h:86
ulonglong last_applied_trx_immediate_commit_timestamp
Definition: table_replication_applier_status_by_worker.h:90
ulonglong applying_trx_last_retry_timestamp
Definition: table_replication_applier_status_by_worker.h:107
char applying_trx[Gtid::MAX_TEXT_LENGTH+1]
Definition: table_replication_applier_status_by_worker.h:93
char last_applied_trx_last_retry_err_msg[MAX_SLAVE_ERRMSG]
Definition: table_replication_applier_status_by_worker.h:100
char applying_trx_last_retry_err_msg[MAX_SLAVE_ERRMSG]
Definition: table_replication_applier_status_by_worker.h:105
ulonglong worker_id
Definition: table_replication_applier_status_by_worker.h:79
ulonglong thread_id
Definition: table_replication_applier_status_by_worker.h:80
uint last_applied_trx_length
Definition: table_replication_applier_status_by_worker.h:88
ulonglong last_applied_trx_last_retry_timestamp
Definition: table_replication_applier_status_by_worker.h:102
uint last_error_number
Definition: table_replication_applier_status_by_worker.h:83
ulong applying_trx_retries_count
Definition: table_replication_applier_status_by_worker.h:103
ulonglong last_applied_trx_end_apply_timestamp
Definition: table_replication_applier_status_by_worker.h:92
uint applying_trx_last_retry_err_number
Definition: table_replication_applier_status_by_worker.h:104
uint channel_name_length
Definition: table_replication_applier_status_by_worker.h:73
ulonglong last_applied_trx_start_apply_timestamp
Definition: table_replication_applier_status_by_worker.h:91
ulonglong last_applied_trx_original_commit_timestamp
Definition: table_replication_applier_status_by_worker.h:89
ulong last_applied_trx_retries_count
Definition: table_replication_applier_status_by_worker.h:98
uint applying_trx_last_retry_err_msg_length
Definition: table_replication_applier_status_by_worker.h:106
uint last_applied_trx_last_retry_err_msg_length
Definition: table_replication_applier_status_by_worker.h:101
uint applying_trx_length
Definition: table_replication_applier_status_by_worker.h:94
uint last_error_message_length
Definition: table_replication_applier_status_by_worker.h:85
char last_error_message[MAX_SLAVE_ERRMSG]
Definition: table_replication_applier_status_by_worker.h:84
uint last_applied_trx_last_retry_err_number
Definition: table_replication_applier_status_by_worker.h:99
ulonglong applying_trx_original_commit_timestamp
Definition: table_replication_applier_status_by_worker.h:95
ulonglong applying_trx_immediate_commit_timestamp
Definition: table_replication_applier_status_by_worker.h:96
enum_rpl_yes_no service_state
Definition: table_replication_applier_status_by_worker.h:82
uint thread_id_is_null
Definition: table_replication_applier_status_by_worker.h:81
char last_applied_trx[Gtid::MAX_TEXT_LENGTH+1]
Definition: table_replication_applier_status_by_worker.h:87
Definition: mysqlslap.cc:243
Helpers to implement a performance schema table.
enum_rpl_yes_no
Definition: table_replication_applier_configuration.h:51