MySQL 8.0.40
Source Code Documentation
backup_page_tracker.h
Go to the documentation of this file.
1/************************************************************************
2 Mysql Enterprise Backup
3 Copyright (c) 2019, 2024, 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 designed to work 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 either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 *************************************************************************/
26
27#ifndef BACKUP_PAGE_TRACKER_SERVICE_H
28#define BACKUP_PAGE_TRACKER_SERVICE_H
29
31
32#include <list>
33
34#include "mysqlbackup.h"
35
36#ifdef __cplusplus
37class THD;
38#define MYSQL_THD THD *
39#else
40#define MYSQL_THD void *
41#endif
42
43#define CHANGED_PAGES_BUFFER_SIZE (16 * 1024 * 1024)
44
45// InnoDB page tracking service
46extern REQUIRES_SERVICE_PLACEHOLDER(mysql_page_track);
47
48int page_track_callback(MYSQL_THD opaque_thd, const uchar *buffer,
49 size_t buffer_length, int page_count, void *context);
50
51struct udf_data_t {
52 std::string m_name;
58
59 udf_data_t(const std::string name, Item_result return_type,
60 Udf_func_any function, Udf_func_init init_function,
61 Udf_func_deinit deinit_function)
62 : m_name(name),
63 m_return_type(return_type),
64 m_function(function),
65 m_init_function(init_function),
66 m_deinit_function(deinit_function),
67 m_is_registered(false) {}
68};
69
71 private:
73 static std::list<udf_data_t *> m_udf_list;
74 static void initialize_udf_list();
75
76 public:
79
80 // Page track UDF functions
83
84 static bool set_page_tracking_init(UDF_INIT *initid, UDF_ARGS *, char *);
85 static void set_page_tracking_deinit(UDF_INIT *initid [[maybe_unused]]);
86 static long long set_page_tracking(UDF_INIT *initid, UDF_ARGS *,
87 unsigned char *is_null,
88 unsigned char *error);
89
91 char *);
93 [[maybe_unused]]);
94 static long long page_track_get_changed_pages(UDF_INIT *initid, UDF_ARGS *,
95 unsigned char *is_null,
96 unsigned char *error);
97
98 static bool page_track_get_start_lsn_init(UDF_INIT *initid, UDF_ARGS *,
99 char *);
100 static void page_track_get_start_lsn_deinit(UDF_INIT *initid
101 [[maybe_unused]]);
102 static long long page_track_get_start_lsn(UDF_INIT *initid, UDF_ARGS *,
103 unsigned char *is_null,
104 unsigned char *error);
105
107 UDF_ARGS *, char *);
109 [[maybe_unused]]);
110 static long long page_track_get_changed_page_count(UDF_INIT *initid,
111 UDF_ARGS *,
112 unsigned char *is_null,
113 unsigned char *error);
114
115 static bool page_track_purge_up_to_init(UDF_INIT *initid, UDF_ARGS *, char *);
116 static void page_track_purge_up_to_deinit(UDF_INIT *initid [[maybe_unused]]);
117 static long long page_track_purge_up_to(UDF_INIT *initid, UDF_ARGS *,
118 unsigned char *is_null,
119 unsigned char *error);
120
121 // method to act on a changed backup-id
122 static bool backup_id_update();
123
124 /// Method to de-allocate the memory allocated for the buffer holding
125 /// path value for the page-track file, if not done before.
126 static void deinit();
127};
128
129#endif /* INC_PAGE_TRACKER_SERVICE_H */
#define MYSQL_THD
Definition: backup_page_tracker.h:38
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:507
REQUIRES_SERVICE_PLACEHOLDER(mysql_page_track)
Definition: backup_page_tracker.h:70
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:299
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:255
static uchar * m_changed_pages_buf
Definition: backup_page_tracker.h:72
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:459
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:350
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:264
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:289
static mysql_service_status_t register_udfs()
Register backup page-track UDFs.
Definition: backup_page_tracker.cc:114
static bool m_receive_changed_page_data
Definition: backup_page_tracker.h:77
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:64
static void initialize_udf_list()
Make a list of the UDFs exposed by mysqlbackup page_tracking.
Definition: backup_page_tracker.cc:74
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:362
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:441
static std::list< udf_data_t * > m_udf_list
Definition: backup_page_tracker.h:73
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:246
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:474
static void set_page_tracking_deinit(UDF_INIT *initid)
Callback method for initialization of UDF "mysqlbackup_page_track_set".
Definition: backup_page_tracker.cc:202
static mysql_service_status_t unregister_udfs()
Un-Register backup page-track UDFs.
Definition: backup_page_tracker.cc:157
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:211
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:308
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:194
static char * m_changed_pages_file
Definition: backup_page_tracker.h:78
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:339
static bool backup_id_update()
Definition: backup_page_tracker.cc:49
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
unsigned char uchar
Definition: my_inttypes.h:52
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420
int mysql_service_status_t
Specific type for the service status return values.
Definition: service.h:34
case opt name
Definition: sslopt-case.h:33
Definition: udf_registration_types.h:48
Information about the result of a user defined function.
Definition: udf_registration_types.h:66
Contains all the necessary data to register an UDF in MySQL.
Definition: backup_page_tracker.h:51
Item_result m_return_type
Definition: backup_page_tracker.h:53
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:59
bool m_is_registered
Definition: backup_page_tracker.h:57
std::string m_name
Definition: backup_page_tracker.h:52
Udf_func_init m_init_function
Definition: backup_page_tracker.h:55
Udf_func_deinit m_deinit_function
Definition: backup_page_tracker.h:56
Udf_func_any m_function
Definition: backup_page_tracker.h:54
void(* Udf_func_deinit)(UDF_INIT *)
Definition: udf_registration_types.h:80
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:39
bool(* Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *)
Definition: udf_registration_types.h:81
void(* Udf_func_any)(void)
Definition: udf_registration_types.h:82