MySQL 8.0.40
Source Code Documentation
page_track_service.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
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 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/**
25 @brief
26
27 This defines the API used to call functions to the page tracking service.
28 When implementing such a service, refer to mysql_page_track.h instead!
29
30*/
31
32#ifndef MYSQL_PAGE_TRACK_SERVICE_H
33#define MYSQL_PAGE_TRACK_SERVICE_H
34
36#include <functional>
37
38#include <stddef.h>
39#include <stdint.h>
40
41#ifdef __cplusplus
42class THD;
43#define MYSQL_THD THD *
44#else
45#define MYSQL_THD void *
46#endif
47
48/**
49 SE for the page tracking. Currently supports only in InnoDB.
50*/
52
53/**
54 Page tracking callback function.
55
56 @param[in] thd Current thread context
57 @param[in] buffer buffer filled with 8 byte page ids; the format is
58 specific to SE. For InnoDB it is space_id (4 bytes) followed by page number
59 (4 bytes)
60 @param[in] buf_len length of buffer in bytes
61 @param[in] num_pages number of valid page IDs in buffer
62 @param[in,out] user_ctx user context passed to page tracking function
63
64 @return Operation status.
65*/
66typedef int (*Page_Track_Callback)(MYSQL_THD thd, const unsigned char *buffer,
67 size_t buf_len, int num_pages,
68 void *user_ctx);
69
70BEGIN_SERVICE_DEFINITION(mysql_page_track)
71
72/**
73 Service API to start page tracking
74
75 @param[in] opaque_thd Current thread context.
76 @param[in] se_type SE for which to enable tracking
77 @param[out] start_id SE specific sequence number [LSN for InnoDB]
78 indicating when the tracking was started
79
80 @return Operation status.
81 @retval 0 Success
82 @retval other ER_* mysql error. Get error details from THD.
83*/
84
86 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
87 uint64_t *start_id));
88
89/**
90 Service API to stop page tracking
91
92 @param[in] opaque_thd Current thread context.
93 @param[in] se_type SE for which to enable tracking
94 @param[out] stop_id SE specific sequence number [LSN for InnoDB]
95 indicating when the tracking was stopped
96
97 @return Operation status.
98 @retval 0 Success
99 @retval other ER_* mysql error. Get error details from THD.
100*/
101
102DECLARE_METHOD(int, stop,
103 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
104 uint64_t *stop_id));
105
106/**
107 Service API to purge page tracking data.
108
109 @param[in] opaque_thd Current thread context.
110 @param[in] se_type SE for which to enable tracking
111 @param[in,out] purge_id SE specific sequence number [LSN for InnoDB]
112 initially indicating till where the data needs to be purged and finally
113 updated to until where it was actually purged
114
115 @return Operation status.
116 @retval 0 Success
117 @retval other ER_* mysql error. Get error details from THD.
118*/
120 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
121 uint64_t *purge_id));
122
123/**
124 Service API to get tracked pages
125
126 @param[in] opaque_thd Current thread context.
127 @param[in] se_type SE for which to enable tracking
128 @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
129 where the pages tracked would be returned.
130 @note The range might get expanded and the actual start_id used for the
131 querying will be updated.
132 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
133 until where the pages tracked would be returned.
134 @note The range might get expanded and the actual stop_id used for the
135 querying will be updated.
136 @param[out] buffer allocated buffer to copy page IDs
137 @param[in] buffer_len length of buffer in bytes
138 @param[in] cbk_func callback function return page IDs
139 @param[in] cbk_ctx caller's context for callback
140
141 @return Operation status.
142 @retval 0 Success
143 @retval other ER_* mysql error. Get error details from THD.
144*/
145
146DECLARE_METHOD(int, get_page_ids,
147 (MYSQL_THD opaque_thd, Page_Track_SE se_type, uint64_t *start_id,
148 uint64_t *stop_id, unsigned char *buffer, size_t buffer_len,
149 Page_Track_Callback cbk_func, void *cbk_ctx));
150
151/**
152 Service API to get approximate number of pages tracked in the given range.
153
154 @param[in] opaque_thd Current thread context.
155 @param[in] se_type SE for which to enable tracking
156 @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
157 where the pages tracked would be returned.
158 @note the range might get expanded and the actual start_id used for the
159 querying will be updated.
160 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
161 until where the pages tracked would be returned.
162 @note the range might get expanded and the actual stop_id used for the
163 querying will be updated.
164 @param[out] num_pages number of pages tracked
165
166 @return Operation status.
167 @retval 0 Success
168 @retval other ER_* mysql error. Get error details from THD.
169*/
170DECLARE_METHOD(int, get_num_page_ids,
171 (MYSQL_THD opaque_thd, Page_Track_SE se_type, uint64_t *start_id,
172 uint64_t *stop_id, uint64_t *num_pages));
173
174/**
175 API to check if the page tracking is active or not and to return start id if
176 it's active.
177
178 @param[in] opaque_thd Current thread context.
179 @param[in] se_type SE for which to enable tracking
180 @param[out] initial_start_id SE specific sequence number [LSN for
181 InnoDB] which denotes the start id at which page tracking was started if it's
182 active
183 @param[out] last_start_id SE specific sequence number [LSN for
184 InnoDB] which denotes the start id the last time the start request was issued
185 @return if page tracking is active or not
186 @retval true if page tracking is active
187 @retval false if page tracking is not active
188*/
189DECLARE_METHOD(int, get_status,
190 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
191 uint64_t *initial_start_id, uint64_t *last_start_id));
192
193END_SERVICE_DEFINITION(mysql_page_track)
194
195#endif
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:177
void purge(lob::DeleteContext *ctx, dict_index_t *index, trx_id_t trxid, undo_no_t undo_no, ulint rec_type, const upd_field_t *uf, purge_node_t *node)
Purge an LOB (either of compressed or uncompressed).
Definition: lob0purge.cc:414
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420
#define MYSQL_THD
Definition: page_track_service.h:43
int(* Page_Track_Callback)(MYSQL_THD thd, const unsigned char *buffer, size_t buf_len, int num_pages, void *user_ctx)
Page tracking callback function.
Definition: page_track_service.h:66
Page_Track_SE
SE for the page tracking.
Definition: page_track_service.h:51
@ PAGE_TRACK_SE_INNODB
Definition: page_track_service.h:51
#define DECLARE_METHOD(retval, name, args)
Declares a method as a part of the Service definition.
Definition: service.h:103
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86