MySQL 8.1.0
Source Code Documentation
backup_page_tracker.h
Go to the documentation of this file.
1/************************************************************************
2 Mysql Enterprise Backup
3 Copyright (c) 2019, 2023, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8
9 This program is also distributed with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have included with MySQL.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 *************************************************************************/
25
26#ifndef BACKUP_PAGE_TRACKER_SERVICE_H
27#define BACKUP_PAGE_TRACKER_SERVICE_H
28
30
31#include <list>
32
33#include "mysqlbackup.h"
34
35#ifdef __cplusplus
36class THD;
37#define MYSQL_THD THD *
38#else
39#define MYSQL_THD void *
40#endif
41
42#define CHANGED_PAGES_BUFFER_SIZE (16 * 1024 * 1024)
43
44// InnoDB page tracking service
45extern REQUIRES_SERVICE_PLACEHOLDER(mysql_page_track);
46
47int page_track_callback(MYSQL_THD opaque_thd, const uchar *buffer,
48 size_t buffer_length, int page_count, void *context);
49
50struct udf_data_t {
51 std::string m_name;
57
58 udf_data_t(const std::string name, Item_result return_type,
59 Udf_func_any function, Udf_func_init init_function,
60 Udf_func_deinit deinit_function)
61 : m_name(name),
62 m_return_type(return_type),
63 m_function(function),
64 m_init_function(init_function),
65 m_deinit_function(deinit_function),
66 m_is_registered(false) {}
67};
68
70 private:
72 static std::list<udf_data_t *> m_udf_list;
73 static void initialize_udf_list();
74
75 public:
78
79 // Page track UDF functions
82
83 static bool set_page_tracking_init(UDF_INIT *initid, UDF_ARGS *, char *);
84 static void set_page_tracking_deinit(UDF_INIT *initid [[maybe_unused]]);
85 static long long set_page_tracking(UDF_INIT *initid, UDF_ARGS *,
86 unsigned char *is_null,
87 unsigned char *error);
88
90 char *);
92 [[maybe_unused]]);
93 static long long page_track_get_changed_pages(UDF_INIT *initid, UDF_ARGS *,
94 unsigned char *is_null,
95 unsigned char *error);
96
97 static bool page_track_get_start_lsn_init(UDF_INIT *initid, UDF_ARGS *,
98 char *);
100 [[maybe_unused]]);
101 static long long page_track_get_start_lsn(UDF_INIT *initid, UDF_ARGS *,
102 unsigned char *is_null,
103 unsigned char *error);
104
106 UDF_ARGS *, char *);
108 [[maybe_unused]]);
109 static long long page_track_get_changed_page_count(UDF_INIT *initid,
110 UDF_ARGS *,
111 unsigned char *is_null,
112 unsigned char *error);
113
114 static bool page_track_purge_up_to_init(UDF_INIT *initid, UDF_ARGS *, char *);
115 static void page_track_purge_up_to_deinit(UDF_INIT *initid [[maybe_unused]]);
116 static long long page_track_purge_up_to(UDF_INIT *initid, UDF_ARGS *,
117 unsigned char *is_null,
118 unsigned char *error);
119
120 // method to act on a changed backup-id
121 static bool backup_id_update();
122
123 /// Method to de-allocate the memory allocated for the buffer holding
124 /// path value for the page-track file, if not done before.
125 static void deinit();
126};
127
128#endif /* INC_PAGE_TRACKER_SERVICE_H */
#define MYSQL_THD
Definition: backup_page_tracker.h:37
int page_track_callback(MYSQL_THD opaque_thd, const uchar *buffer, size_t buffer_length, int page_count, void *context)
Callback method from InnoDB page-tracking to return the changed pages.
Definition: backup_page_tracker.cc:506
REQUIRES_SERVICE_PLACEHOLDER(mysql_page_track)
Definition: backup_page_tracker.h:69
static void page_track_get_changed_page_count_deinit(UDF_INIT *initid)
Callback method for initialization of UDF "mysqlbackup_page_track_get_changed_page_count".
Definition: backup_page_tracker.cc:298
static void page_track_get_start_lsn_deinit(UDF_INIT *initid)
Callback method for initialization of UDF "mysqlbackup_page_track_get_start_lsn".
Definition: backup_page_tracker.cc:254
static uchar * m_changed_pages_buf
Definition: backup_page_tracker.h:71
static void page_track_purge_up_to_deinit(UDF_INIT *initid)
Callback method for deinitialization of UDF "mysqlbackup_page_track_purge_up_to".
Definition: backup_page_tracker.cc:458
static void page_track_get_changed_pages_deinit(UDF_INIT *initid)
Callback method for initialization of UDF "mysqlbackup_page_track_get_changed_pages".
Definition: backup_page_tracker.cc:349
static long long page_track_get_start_lsn(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, unsigned char *error)
UDF for "mysqlbackup_page_track_get_start_lsn" See include/mysql/udf_registration_types....
Definition: backup_page_tracker.cc:263
static bool page_track_get_changed_page_count_init(UDF_INIT *initid, UDF_ARGS *, char *)
Callback function for initialization of UDF "mysqlbackup_page_track_get_changed_page_count".
Definition: backup_page_tracker.cc:288
static mysql_service_status_t register_udfs()
Register backup page-track UDFs.
Definition: backup_page_tracker.cc:113
static bool m_receive_changed_page_data
Definition: backup_page_tracker.h:76
static void deinit()
Method to de-allocate the memory allocated for the buffer holding path value for the page-track file,...
Definition: backup_page_tracker.cc:63
static void initialize_udf_list()
Make a list of the UDFs exposed by mysqlbackup page_tracking.
Definition: backup_page_tracker.cc:73
static long long page_track_get_changed_pages(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, unsigned char *error)
UDF for "mysqlbackup_page_track_get_changed_pages" See include/mysql/udf_registration_types....
Definition: backup_page_tracker.cc:361
static bool page_track_purge_up_to_init(UDF_INIT *initid, UDF_ARGS *, char *)
Callback function for initialization of UDF "mysqlbackup_page_track_purge_up_to".
Definition: backup_page_tracker.cc:440
static std::list< udf_data_t * > m_udf_list
Definition: backup_page_tracker.h:72
static bool page_track_get_start_lsn_init(UDF_INIT *initid, UDF_ARGS *, char *)
Callback function for initialization of UDF "mysqlbackup_page_track_get_start_lsn".
Definition: backup_page_tracker.cc:245
static long long page_track_purge_up_to(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, unsigned char *error)
UDF for "mysqlbackup_page_track_purge_up_to" See include/mysql/udf_registration_types....
Definition: backup_page_tracker.cc:473
static void set_page_tracking_deinit(UDF_INIT *initid)
Callback method for initialization of UDF "mysqlbackup_page_track_set".
Definition: backup_page_tracker.cc:201
static mysql_service_status_t unregister_udfs()
Un-Register backup page-track UDFs.
Definition: backup_page_tracker.cc:156
static long long set_page_tracking(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, unsigned char *error)
UDF for "mysqlbackup_page_track_set" See include/mysql/udf_registration_types.h.
Definition: backup_page_tracker.cc:210
static long long page_track_get_changed_page_count(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, unsigned char *error)
UDF for "mysqlbackup_page_track_get_changed_page_count" See include/mysql/udf_registration_types....
Definition: backup_page_tracker.cc:307
static bool set_page_tracking_init(UDF_INIT *initid, UDF_ARGS *, char *)
Callback function for initialization of UDF "mysqlbackup_page_track_set".
Definition: backup_page_tracker.cc:193
static char * m_changed_pages_file
Definition: backup_page_tracker.h:77
static bool page_track_get_changed_pages_init(UDF_INIT *initid, UDF_ARGS *, char *)
Callback function for initialization of UDF "mysqlbackup_page_track_get_changed_pages".
Definition: backup_page_tracker.cc:338
static bool backup_id_update()
Definition: backup_page_tracker.cc:48
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
unsigned char uchar
Definition: my_inttypes.h:51
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:419
int mysql_service_status_t
Specific type for the service status return values.
Definition: service.h:33
case opt name
Definition: sslopt-case.h:32
Definition: udf_registration_types.h:47
Information about the result of a user defined function.
Definition: udf_registration_types.h:65
Contains all the necessary data to register an UDF in MySQL.
Definition: backup_page_tracker.h:50
Item_result m_return_type
Definition: backup_page_tracker.h:52
udf_data_t(const std::string name, Item_result return_type, Udf_func_any function, Udf_func_init init_function, Udf_func_deinit deinit_function)
Definition: backup_page_tracker.h:58
bool m_is_registered
Definition: backup_page_tracker.h:56
std::string m_name
Definition: backup_page_tracker.h:51
Udf_func_init m_init_function
Definition: backup_page_tracker.h:54
Udf_func_deinit m_deinit_function
Definition: backup_page_tracker.h:55
Udf_func_any m_function
Definition: backup_page_tracker.h:53
void(* Udf_func_deinit)(UDF_INIT *)
Definition: udf_registration_types.h:79
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38
bool(* Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *)
Definition: udf_registration_types.h:80
void(* Udf_func_any)(void)
Definition: udf_registration_types.h:81