MySQL 8.1.0
Source Code Documentation
page_track_service.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 2023, 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 distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16/**
17 @brief
18
19 This defines the API used to call functions to the page tracking service.
20 When implementing such a service, refer to mysql_page_track.h instead!
21
22*/
23
24#ifndef MYSQL_PAGE_TRACK_SERVICE_H
25#define MYSQL_PAGE_TRACK_SERVICE_H
26
28#include <functional>
29
30#include <stddef.h>
31#include <stdint.h>
32
33#ifdef __cplusplus
34class THD;
35#define MYSQL_THD THD *
36#else
37#define MYSQL_THD void *
38#endif
39
40/**
41 SE for the page tracking. Currently supports only in InnoDB.
42*/
44
45/**
46 Page tracking callback function.
47
48 @param[in] thd Current thread context
49 @param[in] buffer buffer filled with 8 byte page ids; the format is
50 specific to SE. For InnoDB it is space_id (4 bytes) followed by page number
51 (4 bytes)
52 @param[in] buf_len length of buffer in bytes
53 @param[in] num_pages number of valid page IDs in buffer
54 @param[in,out] user_ctx user context passed to page tracking function
55
56 @return Operation status.
57*/
58typedef int (*Page_Track_Callback)(MYSQL_THD thd, const unsigned char *buffer,
59 size_t buf_len, int num_pages,
60 void *user_ctx);
61
62BEGIN_SERVICE_DEFINITION(mysql_page_track)
63
64/**
65 Service API to start page tracking
66
67 @param[in] opaque_thd Current thread context.
68 @param[in] se_type SE for which to enable tracking
69 @param[out] start_id SE specific sequence number [LSN for InnoDB]
70 indicating when the tracking was started
71
72 @return Operation status.
73 @retval 0 Success
74 @retval other ER_* mysql error. Get error details from THD.
75*/
76
78 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
79 uint64_t *start_id));
80
81/**
82 Service API to stop page tracking
83
84 @param[in] opaque_thd Current thread context.
85 @param[in] se_type SE for which to enable tracking
86 @param[out] stop_id SE specific sequence number [LSN for InnoDB]
87 indicating when the tracking was stopped
88
89 @return Operation status.
90 @retval 0 Success
91 @retval other ER_* mysql error. Get error details from THD.
92*/
93
94DECLARE_METHOD(int, stop,
95 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
96 uint64_t *stop_id));
97
98/**
99 Service API to purge page tracking data.
100
101 @param[in] opaque_thd Current thread context.
102 @param[in] se_type SE for which to enable tracking
103 @param[in,out] purge_id SE specific sequence number [LSN for InnoDB]
104 initially indicating till where the data needs to be purged and finally
105 updated to until where it was actually purged
106
107 @return Operation status.
108 @retval 0 Success
109 @retval other ER_* mysql error. Get error details from THD.
110*/
112 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
113 uint64_t *purge_id));
114
115/**
116 Service API to get tracked pages
117
118 @param[in] opaque_thd Current thread context.
119 @param[in] se_type SE for which to enable tracking
120 @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
121 where the pages tracked would be returned.
122 @note The range might get expanded and the actual start_id used for the
123 querying will be updated.
124 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
125 until where the pages tracked would be returned.
126 @note The range might get expanded and the actual stop_id used for the
127 querying will be updated.
128 @param[out] buffer allocated buffer to copy page IDs
129 @param[in] buffer_len length of buffer in bytes
130 @param[in] cbk_func callback function return page IDs
131 @param[in] cbk_ctx caller's context for callback
132
133 @return Operation status.
134 @retval 0 Success
135 @retval other ER_* mysql error. Get error details from THD.
136*/
137
138DECLARE_METHOD(int, get_page_ids,
139 (MYSQL_THD opaque_thd, Page_Track_SE se_type, uint64_t *start_id,
140 uint64_t *stop_id, unsigned char *buffer, size_t buffer_len,
141 Page_Track_Callback cbk_func, void *cbk_ctx));
142
143/**
144 Service API to get approximate number of pages tracked in the given range.
145
146 @param[in] opaque_thd Current thread context.
147 @param[in] se_type SE for which to enable tracking
148 @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
149 where the pages tracked would be returned.
150 @note the range might get expanded and the actual start_id used for the
151 querying will be updated.
152 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
153 until where the pages tracked would be returned.
154 @note the range might get expanded and the actual stop_id used for the
155 querying will be updated.
156 @param[out] num_pages number of pages tracked
157
158 @return Operation status.
159 @retval 0 Success
160 @retval other ER_* mysql error. Get error details from THD.
161*/
162DECLARE_METHOD(int, get_num_page_ids,
163 (MYSQL_THD opaque_thd, Page_Track_SE se_type, uint64_t *start_id,
164 uint64_t *stop_id, uint64_t *num_pages));
165
166/**
167 API to check if the page tracking is active or not and to return start id if
168 it's active.
169
170 @param[in] opaque_thd Current thread context.
171 @param[in] se_type SE for which to enable tracking
172 @param[out] initial_start_id SE specific sequence number [LSN for
173 InnoDB] which denotes the start id at which page tracking was started if it's
174 active
175 @param[out] last_start_id SE specific sequence number [LSN for
176 InnoDB] which denotes the start id the last time the start request was issued
177 @return if page tracking is active or not
178 @retval true if page tracking is active
179 @retval false if page tracking is not active
180*/
181DECLARE_METHOD(int, get_status,
182 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
183 uint64_t *initial_start_id, uint64_t *last_start_id));
184
185END_SERVICE_DEFINITION(mysql_page_track)
186
187#endif
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:176
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:413
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:419
#define MYSQL_THD
Definition: page_track_service.h:35
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:58
Page_Track_SE
SE for the page tracking.
Definition: page_track_service.h:43
@ PAGE_TRACK_SE_INNODB
Definition: page_track_service.h:43
#define DECLARE_METHOD(retval, name, args)
Declares a method as a part of the Service definition.
Definition: service.h:102
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:90
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:85