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