MySQL 8.4.0
Source Code Documentation
mysql_page_track_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by
5the Free Software Foundation; version 2 of the License.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_PAGE_TRACK_H
25#define MYSQL_PAGE_TRACK_H
26
29
30/**
31 An implementation of page tracking service.
32*/
34 public:
35 /**
36 Service API to start page tracking.
37
38 @param[in] opaque_thd Current thread context.
39 @param[in] se_type SE for which to enable tracking
40 @param[out] start_id SE specific sequence number [LSN for InnoDB]
41 indicating when the tracking was started
42
43 @return Operation status.
44 @retval 0 Success
45 @retval other ER_* mysql error. Get error details from THD.
46 */
47 static DEFINE_METHOD(int, start,
48 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
49 uint64_t *start_id));
50
51 /**
52 Service API to stop page tracking.
53
54 @param[in] opaque_thd Current thread context.
55 @param[in] se_type SE for which to enable tracking
56 @param[out] stop_id SE specific sequence number [LSN for InnoDB]
57 indicating when the tracking was stopped
58
59 @return Operation status.
60 @retval 0 Success
61 @retval other ER_* mysql error. Get error details from THD.
62 */
63 static DEFINE_METHOD(int, stop,
64 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
65 uint64_t *stop_id));
66
67 /**
68 Service API to purge page tracking data.
69
70 @param[in] opaque_thd Current thread context.
71 @param[in] se_type SE for which to enable tracking
72 @param[in,out] purge_id SE specific sequence number [LSN for Innodb]
73 initially indicating till where the data needs to be purged and finally
74 updated to until where it was actually purged
75
76 @return Operation status.
77 @retval 0 Success
78 @retval other ER_* mysql error. Get error details from THD.
79 */
80 static DEFINE_METHOD(int, purge,
81 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
82 uint64_t *purge_id));
83
84 /**
85 Service API to get tracked pages
86
87 @param[in] opaque_thd Current thread context.
88 @param[in] se_type SE for which to enable tracking
89 @param[in,out] start_id SE specific sequence number [LSN for InnoDB]
90 from where the pages tracked would be returned.
91 @note The range might get expanded and the actual start_id used for the
92 querying will be updated.
93 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
94 until where the pages tracked would be returned.
95 @note The range might get expanded and the actual stop_id used for the
96 querying will be updated.
97 @param[out] buffer allocated buffer to copy page IDs
98 @param[in] buffer_len length of buffer in bytes
99 @param[in] cbk_func callback function return page IDs
100 @param[in] cbk_ctx caller's context for callback
101
102 @return Operation status.
103 @retval 0 Success
104 @retval other ER_* mysql error. Get error details from THD.
105 */
106 static DEFINE_METHOD(int, get_page_ids,
107 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
108 uint64_t *start_id, uint64_t *stop_id,
109 unsigned char *buffer, size_t buffer_len,
110 Page_Track_Callback cbk_func, void *cbk_ctx));
111
112 /**
113 Service API to get approximate number of pages tracked in the given range.
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]
118 from 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] num_pages number of pages tracked
126
127 @return Operation status.
128 @retval 0 Success
129 @retval other ER_* mysql error. Get error details from THD.
130 */
132 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
133 uint64_t *start_id, uint64_t *stop_id,
134 uint64_t *num_pages));
135
136 /**
137 API to check if page tracking is active or not and to return start id if
138 it's active.
139
140 @param[in] opaque_thd Current thread context.
141 @param[in] se_type SE for which to enable tracking
142 @param[out] initial_start_id SE specific sequence number [LSN for
143 Innodb] which denotes the start id at which page tracking was started if
144 it's active
145 @param[out] last_start_id SE specific sequence number [LSN for
146 Innodb] which denotes the start id the last time the start request was
147 issued
148 @return if page tracking is active or not
149 @retval true if page tracking is active
150 @retval false if page tracking is not active
151 */
152 static DEFINE_METHOD(int, get_status,
153 (MYSQL_THD opaque_thd, Page_Track_SE se_type,
154 uint64_t *initial_start_id, uint64_t *last_start_id));
155};
156
157#endif /* MYSQL_PAGE_TRACK_H */
#define MYSQL_THD
Definition: backup_page_tracker.h:38
An implementation of page tracking service.
Definition: mysql_page_track_imp.h:33
static int get_status(THD *opaque_thd, Page_Track_SE se_type, uint64_t *initial_start_id, uint64_t *last_start_id) noexcept
API to check if page tracking is active or not and to return start id if it's active.
Definition: page_track_service.cc:156
static int get_page_ids(THD *opaque_thd, Page_Track_SE se_type, uint64_t *start_id, uint64_t *stop_id, unsigned char *buffer, size_t buffer_len, Page_Track_Callback cbk_func, void *cbk_ctx) noexcept
Service API to get tracked pages.
Definition: page_track_service.cc:111
static int purge(THD *opaque_thd, Page_Track_SE se_type, uint64_t *purge_id) noexcept
Service API to purge page tracking data.
Definition: page_track_service.cc:88
static int stop(THD *opaque_thd, Page_Track_SE se_type, uint64_t *stop_id) noexcept
Service API to stop page tracking.
Definition: page_track_service.cc:66
static int start(THD *opaque_thd, Page_Track_SE se_type, uint64_t *start_id) noexcept
Service API to start page tracking.
Definition: page_track_service.cc:44
static int get_num_page_ids(THD *opaque_thd, Page_Track_SE se_type, uint64_t *start_id, uint64_t *stop_id, uint64_t *num_pages) noexcept
Service API to get approximate number of pages tracked in the given range.
Definition: page_track_service.cc:134
Specifies macros to define Components.
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
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
#define DEFINE_METHOD(retval, name, args)
A macro to ensure method implementation has required properties, that is it does not throw exceptions...
Definition: service_implementation.h:79