MySQL 9.0.0
Source Code Documentation
rpl_relay_log_sanitizer.h
Go to the documentation of this file.
1// Copyright (c) 2024, Oracle and/or its affiliates.
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, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
24#ifndef RPL_RELAY_LOG_SANITIZER_H
25#define RPL_RELAY_LOG_SANITIZER_H
26
27#include <functional>
29#include "sql/binlog.h"
30#include "sql/binlog/decompressing_event_object_istream.h" // binlog::Decompressing_event_object_istream
32#include "sql/binlog_ostream.h" // binlog::tools::Iterator
33#include "sql/binlog_reader.h" // Binlog_file_reader
34#include "sql/log_event.h" // Log_event
35#include "sql/xa.h" // XID
36
37namespace rpl {
38
39/// @brief Class used to recover relay log files
40/// @details Recovery of the relay log files is:
41/// - finding the last valid position outside of a transaction boundary
42/// (analyze_logs)
43/// - removing relay logs appearing after the relay log with the last valid
44/// position (analyze_logs)
45/// - truncation of the relay log file containing the last valid position
46/// to remove partially written transaction from the log (sanitize log)
48 public:
49 /// @brief Ctor
51
52 /// @brief Dtor
53 ~Relay_log_sanitizer() override = default;
54
55 /// @brief Given specific log, performs sanitization. Reads log list obtained
56 /// from the MYSQL_BIN_LOG object and searches for last, fully written
57 /// transaction. Removes log files that are created after last finished
58 /// transaction
59 /// @param log Handle to MYSQL_BIN_LOG object, which does not need to be
60 /// open. We need specific functions from the MYSQL_BIN_LOG, e.g.
61 /// reading of the index file
62 /// @param checksum_validation True if we need to perform relay log file
63 /// checksum validation
64 void analyze_logs(MYSQL_BIN_LOG &log, bool checksum_validation);
65
66 /// @brief Sanitize opened log
67 /// @param log Handle to MYSQL_BIN_LOG object, which we will truncate
68 /// if needed
69 /// @return false on no error or when no truncation was done, true otherwise
70 bool sanitize_log(MYSQL_BIN_LOG &log);
71
72 /// @brief Updates source position if a valid source position has been
73 /// found whilst reading the relay log files
74 /// @param mi Master_info for the receiver thread.
76
77 protected:
78 /// @brief Function used to obtain memory key for derived classes
79 /// @returns Reference to a memory key
80 PSI_memory_key &get_memory_key() const override {
82 }
83};
84
85} // namespace rpl
86
87#endif // RPL_RELAY_LOG_SANITIZER_H
Contains the classes representing events occurring in the replication stream.
Definition: binlog.h:107
Definition: rpl_mi.h:87
Class used to recover binary / relay log file.
Definition: log_sanitizer.h:62
bool m_validation_started
Indicates whether validation has started.
Definition: log_sanitizer.h:179
Class used to recover relay log files.
Definition: rpl_relay_log_sanitizer.h:47
void analyze_logs(MYSQL_BIN_LOG &log, bool checksum_validation)
Given specific log, performs sanitization.
Definition: rpl_relay_log_sanitizer.cc:32
~Relay_log_sanitizer() override=default
Dtor.
bool sanitize_log(MYSQL_BIN_LOG &log)
Sanitize opened log.
Definition: rpl_relay_log_sanitizer.cc:38
void update_source_position(Master_info *mi)
Updates source position if a valid source position has been found whilst reading the relay log files.
Definition: rpl_relay_log_sanitizer.cc:54
PSI_memory_key & get_memory_key() const override
Function used to obtain memory key for derived classes.
Definition: rpl_relay_log_sanitizer.h:80
Relay_log_sanitizer()
Ctor.
Definition: rpl_relay_log_sanitizer.h:50
Stream class that yields Log_event objects, including events contained in Transaction_payload_log_eve...
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
Binary log event definitions.
Definition: rpl_relay_log_sanitizer.cc:30
PSI_memory_key key_memory_relaylog_recovery
Definition: psi_memory_key.cc:80