MySQL  8.0.20
Source Code Documentation
page_track_service.h
Go to the documentation of this file.
1 /* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
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 <stdint.h>
31 
32 #ifdef __cplusplus
33 class THD;
34 #define MYSQL_THD THD *
35 #else
36 #define MYSQL_THD void *
37 #endif
38 
39 /**
40  SE for the page tracking. Currently supports only in InnoDB.
41 */
42 typedef enum { PAGE_TRACK_SE_INNODB = 1 } Page_Track_SE;
43 
44 /**
45  Page tracking callback function.
46 
47  @param[in] thd Current thread context
48  @param[in] buffer buffer filled with 8 byte page ids; the format is
49  specific to SE. For InnoDB it is space_id (4 bytes) followed by page number
50  (4 bytes)
51  @param[in] buf_len length of buffer in bytes
52  @param[in] num_pages number of valid page IDs in buffer
53  @param[in,out] user_ctx user context passed to page tracking function
54 
55  @return Operation status.
56 */
57 typedef int (*Page_Track_Callback)(MYSQL_THD thd, const unsigned char *buffer,
58  size_t buf_len, int num_pages,
59  void *user_ctx);
60 
61 BEGIN_SERVICE_DEFINITION(mysql_page_track)
62 
63 /**
64  Service API to start page tracking
65 
66  @param[in] opaque_thd Current thread context.
67  @param[in] se_type SE for which to enable tracking
68  @param[out] start_id SE specific sequence number [LSN for InnoDB]
69  indicating when the tracking was started
70 
71  @return Operation status.
72  @retval 0 Success
73  @retval other ER_* mysql error. Get error details from THD.
74 */
75 
77  (MYSQL_THD opaque_thd, Page_Track_SE se_type,
78  uint64_t *start_id));
79 
80 /**
81  Service API to stop page tracking
82 
83  @param[in] opaque_thd Current thread context.
84  @param[in] se_type SE for which to enable tracking
85  @param[out] stop_id SE specific sequence number [LSN for InnoDB]
86  indicating when the tracking was stopped
87 
88  @return Operation status.
89  @retval 0 Success
90  @retval other ER_* mysql error. Get error details from THD.
91 */
92 
93 DECLARE_METHOD(int, stop,
94  (MYSQL_THD opaque_thd, Page_Track_SE se_type,
95  uint64_t *stop_id));
96 
97 /**
98  Service API to purge page tracking data.
99 
100  @param[in] opaque_thd Current thread context.
101  @param[in] se_type SE for which to enable tracking
102  @param[in,out] purge_id SE specific sequence number [LSN for InnoDB]
103  initially indicating till where the data needs to be purged and finally
104  updated to until where it was actually purged
105 
106  @return Operation status.
107  @retval 0 Success
108  @retval other ER_* mysql error. Get error details from THD.
109 */
110 DECLARE_METHOD(int, purge,
111  (MYSQL_THD opaque_thd, Page_Track_SE se_type,
112  uint64_t *purge_id));
113 
114 /**
115  Service API to get tracked pages
116 
117  @param[in] opaque_thd Current thread context.
118  @param[in] se_type SE for which to enable tracking
119  @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
120  where the pages tracked would be returned.
121  @note The range might get expanded and the actual start_id used for the
122  querying will be updated.
123  @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
124  until where the pages tracked would be returned.
125  @note The range might get expanded and the actual stop_id used for the
126  querying will be updated.
127  @param[out] buffer allocated buffer to copy page IDs
128  @param[in] buffer_len length of buffer in bytes
129  @param[in] cbk_func callback function return page IDs
130  @param[in] cbk_ctx caller's context for callback
131 
132  @return Operation status.
133  @retval 0 Success
134  @retval other ER_* mysql error. Get error details from THD.
135 */
136 
137 DECLARE_METHOD(int, get_page_ids,
138  (MYSQL_THD opaque_thd, Page_Track_SE se_type, uint64_t *start_id,
139  uint64_t *stop_id, unsigned char *buffer, size_t buffer_len,
140  Page_Track_Callback cbk_func, void *cbk_ctx));
141 
142 /**
143  Service API to get approximate number of pages tracked in the given range.
144 
145  @param[in] opaque_thd Current thread context.
146  @param[in] se_type SE for which to enable tracking
147  @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
148  where the pages tracked would be returned.
149  @note the range might get expanded and the actual start_id used for the
150  querying will be updated.
151  @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
152  until where the pages tracked would be returned.
153  @note the range might get expanded and the actual stop_id used for the
154  querying will be updated.
155  @param[out] num_pages number of pages tracked
156 
157  @return Operation status.
158  @retval 0 Success
159  @retval other ER_* mysql error. Get error details from THD.
160 */
161 DECLARE_METHOD(int, get_num_page_ids,
162  (MYSQL_THD opaque_thd, Page_Track_SE se_type, uint64_t *start_id,
163  uint64_t *stop_id, uint64_t *num_pages));
164 
165 /**
166  API to check if the page tracking is active or not and to return start id if
167  it's active.
168 
169  @param[in] opaque_thd Current thread context.
170  @param[in] se_type SE for which to enable tracking
171  @param[out] initial_start_id SE specific sequence number [LSN for
172  InnoDB] which denotes the start id at which page tracking was started if it's
173  active
174  @param[out] last_start_id SE specific sequence number [LSN for
175  InnoDB] which denotes the start id the last time the start request was issued
176  @return if page tracking is active or not
177  @retval true if page tracking is active
178  @retval false if page tracking is not active
179 */
180 DECLARE_METHOD(int, get_status,
181  (MYSQL_THD opaque_thd, Page_Track_SE se_type,
182  uint64_t *initial_start_id, uint64_t *last_start_id));
183 
184 END_SERVICE_DEFINITION(mysql_page_track)
185 
186 #endif
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
Definition: page_track_service.h:42
#define MYSQL_THD
Definition: page_track_service.h:34
#define DECLARE_METHOD(retval, name, args)
static void stop(PluginFuncEnv *)
Definition: rest_mock_server.cc:277
#define END_SERVICE_DEFINITION(name)
Page_Track_SE
SE for the page tracking.
Definition: page_track_service.h:42
#define BEGIN_SERVICE_DEFINITION(name)
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 an LOB (either of compressed or uncompressed).
Definition: lob0purge.cc:369
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:765
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:57
static void start(PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:165