MySQL 8.3.0
Source Code Documentation
table_replication_applier_status_by_worker.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2013, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef TABLE_REPLICATION_APPLIER_STATUS_BY_WORKER_H
25#define TABLE_REPLICATION_APPLIER_STATUS_BY_WORKER_H
26
27/**
28 @file storage/perfschema/table_replication_applier_status_by_worker.h
29 Table replication_applier_status_by_worker (declarations).
30*/
31
32#include <sys/types.h>
33
34#include "my_base.h"
35#include "my_inttypes.h"
36#include "sql/rpl_gtid.h"
37#include "sql/rpl_info.h" /*CHANNEL_NAME_LENGTH*/
38#include "sql/rpl_reporting.h"
41
42class Field;
43class Master_info;
44class Plugin_table;
45class Slave_worker;
46struct TABLE;
47struct THR_LOCK;
48struct mysql_mutex_t;
49
50/**
51 @addtogroup performance_schema_tables
52 @{
53*/
54
55#ifndef ENUM_RPL_YES_NO
56#define ENUM_RPL_YES_NO
57/** enumerated values for service_state of worker thread*/
59 PS_RPL_YES = 1, /* service_state= on */
60 PS_RPL_NO /* service_state= off */
61};
62#endif
63
64/*
65 A row in worker's table. The fields with string values have an additional
66 length field denoted by <field_name>_length.
67*/
71 /*
72 worker_id is added to the table because thread is killed at STOP SLAVE
73 but the status needs to show up, so worker_id is used as a permanent
74 identifier.
75 */
105};
106
107/**
108 Position in table replication_applier_status_by_worker.
109 Index 1 for replication channel.
110 Index 2 for worker:
111 - position [0] is for Single Thread Slave (Master_info)
112 - position [1] .. [N] is for Multi Thread Slave (Slave_worker)
113*/
116
117 inline void reset() {
118 m_index_1 = 0;
119 m_index_2 = 0;
120 }
121
122 inline bool has_more_channels(uint num) { return (m_index_1 < num); }
123
124 inline void next_channel() {
125 m_index_1++;
126 m_index_2 = 0;
127 }
128
129 inline void next_worker() { m_index_2++; }
130
131 inline void set_channel_after(
133 m_index_1 = other->m_index_1 + 1;
134 m_index_2 = 0;
135 }
136};
137
139 public:
142
144 PFS_engine_key *key_2)
145 : PFS_engine_index(key_1, key_2) {}
146
148
149 virtual bool match(Master_info *mi) = 0;
150 virtual bool match(Master_info *mi, Slave_worker *w) = 0;
151};
152
155 public:
158 m_key_1("CHANNEL_NAME"),
159 m_key_2("WORKER_ID") {}
160
162
163 bool match(Master_info *mi) override;
164 bool match(Master_info *mi, Slave_worker *w) override;
165
166 private:
169};
170
173 public:
176
178
179 bool match(Master_info *mi) override;
180 bool match(Master_info *mi, Slave_worker *w) override;
181
182 private:
184};
185
186/** Table PERFORMANCE_SCHEMA.replication_applier_status_by_worker */
189
190 private:
191 int make_row(Slave_worker *);
192 /*
193 Master_info to construct a row to display SQL Thread's status
194 information in STS mode
195 */
196 int make_row(Master_info *);
197 void populate_trx_info(Trx_monitoring_info const &applying_trx,
198 Trx_monitoring_info const &last_applied_trx);
199
200 /** Table share lock. */
202 /** Table definition. */
204
205 /** current row. */
207 /** Current position. */
209 /** Next position. */
211
212 protected:
213 /**
214 Read the current row values.
215 @param table Table handle
216 @param buf row buffer
217 @param fields Table fields
218 @param read_all true if all columns are read.
219 */
220
221 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
222 bool read_all) override;
223
225
226 public:
228
229 /** Table share. */
232 static ha_rows get_row_count();
233 void reset_position() override;
234
235 int rnd_next() override;
236 int rnd_pos(const void *pos) override;
237
238 int index_init(uint idx, bool sorted) override;
239 int index_next() override;
240
241 private:
243};
244
245/** @} */
246#endif
Definition: field.h:574
Definition: rpl_mi.h:86
Definition: pfs_engine_table.h:299
Definition: pfs_engine_table.h:267
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:69
Definition: table_replication_applier_status_by_worker.h:154
PFS_index_rpl_applier_status_by_worker_by_channel()
Definition: table_replication_applier_status_by_worker.h:156
PFS_key_name m_key_1
Definition: table_replication_applier_status_by_worker.h:167
bool match(Master_info *mi) override
Definition: table_replication_applier_status_by_worker.cc:115
~PFS_index_rpl_applier_status_by_worker_by_channel() override=default
PFS_key_worker_id m_key_2
Definition: table_replication_applier_status_by_worker.h:168
Definition: table_replication_applier_status_by_worker.h:172
PFS_key_thread_id m_key
Definition: table_replication_applier_status_by_worker.h:183
~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:162
PFS_index_rpl_applier_status_by_worker_by_thread()
Definition: table_replication_applier_status_by_worker.h:174
Definition: table_replication_applier_status_by_worker.h:138
~PFS_index_rpl_applier_status_by_worker() override=default
virtual bool match(Master_info *mi)=0
virtual bool match(Master_info *mi, Slave_worker *w)=0
PFS_index_rpl_applier_status_by_worker(PFS_engine_key *key)
Definition: table_replication_applier_status_by_worker.h:140
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:143
Definition: table_helper.h:1553
Definition: table_helper.h:1278
Definition: table_helper.h:1345
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:39
Definition: rpl_rli_pdb.h:497
Table PERFORMANCE_SCHEMA.replication_applier_status_by_worker.
Definition: table_replication_applier_status_by_worker.h:187
pos_replication_applier_status_by_worker pos_t
Definition: table_replication_applier_status_by_worker.h:188
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_replication_applier_status_by_worker.cc:242
static Plugin_table m_table_def
Table definition.
Definition: table_replication_applier_status_by_worker.h:203
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_replication_applier_status_by_worker.cc:218
static THR_LOCK m_table_lock
Table share lock.
Definition: table_replication_applier_status_by_worker.h:201
PFS_index_rpl_applier_status_by_worker * m_opened_index
Definition: table_replication_applier_status_by_worker.h:242
static ha_rows get_row_count()
Definition: table_replication_applier_status_by_worker.cc:235
pos_t m_next_pos
Next position.
Definition: table_replication_applier_status_by_worker.h:210
int index_init(uint idx, bool sorted) override
Definition: table_replication_applier_status_by_worker.cc:329
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:544
pos_t m_pos
Current position.
Definition: table_replication_applier_status_by_worker.h:208
st_row_worker m_row
current row.
Definition: table_replication_applier_status_by_worker.h:206
table_replication_applier_status_by_worker()
Definition: table_replication_applier_status_by_worker.cc:224
static PFS_engine_table_share m_share
Table share.
Definition: table_replication_applier_status_by_worker.h:230
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_replication_applier_status_by_worker.cc:230
int index_next() override
Find key in index, read record.
Definition: table_replication_applier_status_by_worker.cc:348
int make_row(Slave_worker *)
Definition: table_replication_applier_status_by_worker.cc:479
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_replication_applier_status_by_worker.cc:290
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:572
@ PS_RPL_NO
Definition: table_replication_applier_status_by_worker.h:60
@ PS_RPL_YES
Definition: table_replication_applier_status_by_worker.h:59
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
Definition: buf0block_hint.cc:29
Performance schema tables (declarations).
required string key
Definition: replication_asynchronous_connection_failover.proto:59
#define CHANNEL_NAME_LENGTH
Definition: rpl_info.h:40
#define MAX_SLAVE_ERRMSG
Maximum size of an error message from a slave thread.
Definition: rpl_reporting.h:41
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:1136
Position of a double cursor, for iterations using 2 nested loops.
Definition: pfs_engine_table.h:592
uint m_index_1
Outer index.
Definition: pfs_engine_table.h:594
uint m_index_2
Current index within index_1.
Definition: pfs_engine_table.h:596
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:357
Definition: table.h:1403
Definition: thr_lock.h:138
Structure to store the GTID and timing information.
Definition: rpl_gtid.h:1261
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Position in table replication_applier_status_by_worker.
Definition: table_replication_applier_status_by_worker.h:114
void next_channel()
Definition: table_replication_applier_status_by_worker.h:124
bool has_more_channels(uint num)
Definition: table_replication_applier_status_by_worker.h:122
pos_replication_applier_status_by_worker()
Definition: table_replication_applier_status_by_worker.h:115
void set_channel_after(const pos_replication_applier_status_by_worker *other)
Definition: table_replication_applier_status_by_worker.h:131
void reset()
Definition: table_replication_applier_status_by_worker.h:117
void next_worker()
Definition: table_replication_applier_status_by_worker.h:129
Definition: table_replication_applier_status_by_worker.h:68
char channel_name[CHANNEL_NAME_LENGTH]
Definition: table_replication_applier_status_by_worker.h:69
ulonglong applying_trx_start_apply_timestamp
Definition: table_replication_applier_status_by_worker.h:94
ulonglong last_error_timestamp
Definition: table_replication_applier_status_by_worker.h:83
ulonglong last_applied_trx_immediate_commit_timestamp
Definition: table_replication_applier_status_by_worker.h:87
ulonglong applying_trx_last_retry_timestamp
Definition: table_replication_applier_status_by_worker.h:104
char applying_trx[Gtid::MAX_TEXT_LENGTH+1]
Definition: table_replication_applier_status_by_worker.h:90
char last_applied_trx_last_retry_err_msg[MAX_SLAVE_ERRMSG]
Definition: table_replication_applier_status_by_worker.h:97
char applying_trx_last_retry_err_msg[MAX_SLAVE_ERRMSG]
Definition: table_replication_applier_status_by_worker.h:102
ulonglong worker_id
Definition: table_replication_applier_status_by_worker.h:76
ulonglong thread_id
Definition: table_replication_applier_status_by_worker.h:77
uint last_applied_trx_length
Definition: table_replication_applier_status_by_worker.h:85
ulonglong last_applied_trx_last_retry_timestamp
Definition: table_replication_applier_status_by_worker.h:99
uint last_error_number
Definition: table_replication_applier_status_by_worker.h:80
ulong applying_trx_retries_count
Definition: table_replication_applier_status_by_worker.h:100
ulonglong last_applied_trx_end_apply_timestamp
Definition: table_replication_applier_status_by_worker.h:89
uint applying_trx_last_retry_err_number
Definition: table_replication_applier_status_by_worker.h:101
uint channel_name_length
Definition: table_replication_applier_status_by_worker.h:70
ulonglong last_applied_trx_start_apply_timestamp
Definition: table_replication_applier_status_by_worker.h:88
ulonglong last_applied_trx_original_commit_timestamp
Definition: table_replication_applier_status_by_worker.h:86
ulong last_applied_trx_retries_count
Definition: table_replication_applier_status_by_worker.h:95
uint applying_trx_last_retry_err_msg_length
Definition: table_replication_applier_status_by_worker.h:103
uint last_applied_trx_last_retry_err_msg_length
Definition: table_replication_applier_status_by_worker.h:98
uint applying_trx_length
Definition: table_replication_applier_status_by_worker.h:91
uint last_error_message_length
Definition: table_replication_applier_status_by_worker.h:82
char last_error_message[MAX_SLAVE_ERRMSG]
Definition: table_replication_applier_status_by_worker.h:81
uint last_applied_trx_last_retry_err_number
Definition: table_replication_applier_status_by_worker.h:96
ulonglong applying_trx_original_commit_timestamp
Definition: table_replication_applier_status_by_worker.h:92
ulonglong applying_trx_immediate_commit_timestamp
Definition: table_replication_applier_status_by_worker.h:93
enum_rpl_yes_no service_state
Definition: table_replication_applier_status_by_worker.h:79
uint thread_id_is_null
Definition: table_replication_applier_status_by_worker.h:78
char last_applied_trx[Gtid::MAX_TEXT_LENGTH+1]
Definition: table_replication_applier_status_by_worker.h:84
Helpers to implement a performance schema table.
enum_rpl_yes_no
Definition: table_replication_applier_configuration.h:49