MySQL 8.4.2
Source Code Documentation
log0consumer.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2021, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/**************************************************/ /**
29 @file include/log0consumer.h
30
31 Redo log functions and types related to the log consumption.
32
33 *******************************************************/
34
35#ifndef log0consumer_h
36#define log0consumer_h
37
38#include "log0types.h" /* lsn_t, log_t& */
39
41 public:
42 virtual ~Log_consumer() {}
43
44 /** @return Name of this consumer. */
45 virtual const std::string &get_name() const = 0;
46
47 /** @return Maximum LSN up to which this consumer has consumed redo. */
48 virtual lsn_t get_consumed_lsn() const = 0;
49
50 /** Request the log consumer to consume faster.
51 @remarks This is called whenever the redo log consumer
52 is the most lagging one and it is critical to consume
53 the oldest redo log file. */
54 virtual void consumption_requested() = 0;
55};
56
58 public:
59 explicit Log_user_consumer(const std::string &name);
60
61 const std::string &get_name() const override;
62
63 /** Set the lsn reported by get_consumed_lsn() to the given value.
64 It is required that the given value is greater or equal to the value
65 currently reported by the get_consumed_lsn().
66 @param[in] consumed_lsn the given lsn to report */
67 void set_consumed_lsn(lsn_t consumed_lsn);
68
69 lsn_t get_consumed_lsn() const override;
70
71 void consumption_requested() override;
72
73 private:
74 /** Name of this consumer (saved value from ctor). */
75 const std::string m_name;
76
77 /** Value reported by get_consumed_lsn().
78 Set by set_consumed_lsn(lsn). */
80};
81
83 public:
84 explicit Log_checkpoint_consumer(log_t &log);
85
86 const std::string &get_name() const override;
87
88 lsn_t get_consumed_lsn() const override;
89
90 void consumption_requested() override;
91
92 private:
94};
95
96/** Register the given redo log consumer.
97@param[in,out] log redo log
98@param[in] log_consumer redo log consumer to register */
99void log_consumer_register(log_t &log, Log_consumer *log_consumer);
100
101/** Unregister the given redo log consumer.
102@param[in,out] log redo log
103@param[in] log_consumer redo log consumer to unregister */
104void log_consumer_unregister(log_t &log, Log_consumer *log_consumer);
105
106/** Find the registered redo log consumer which has the smallest value
107reported by get_consumed_lsn() - ie. the most lagging consumer. When
108multiple consumers have the same value, any of them might be returned.
109@param[in] log the redo log
110@param[out] oldest_needed_lsn the oldest lsn needed by the most lagging consumer
111@return the most lagging consumer */
113 lsn_t &oldest_needed_lsn);
114
115#endif /* !log0consumer_h */
Definition: log0consumer.h:82
log_t & m_log
Definition: log0consumer.h:93
void consumption_requested() override
Request the log consumer to consume faster.
Definition: log0consumer.cc:69
const std::string & get_name() const override
Definition: log0consumer.cc:60
lsn_t get_consumed_lsn() const override
Definition: log0consumer.cc:65
Log_checkpoint_consumer(log_t &log)
Definition: log0consumer.cc:58
Definition: log0consumer.h:40
virtual ~Log_consumer()
Definition: log0consumer.h:42
virtual void consumption_requested()=0
Request the log consumer to consume faster.
virtual const std::string & get_name() const =0
virtual lsn_t get_consumed_lsn() const =0
Definition: log0consumer.h:57
void consumption_requested() override
Request the log consumer to consume faster.
Definition: log0consumer.cc:56
const std::string m_name
Name of this consumer (saved value from ctor).
Definition: log0consumer.h:75
Log_user_consumer(const std::string &name)
Definition: log0consumer.cc:42
void set_consumed_lsn(lsn_t consumed_lsn)
Set the lsn reported by get_consumed_lsn() to the given value.
Definition: log0consumer.cc:46
lsn_t get_consumed_lsn() const override
Definition: log0consumer.cc:54
const std::string & get_name() const override
Definition: log0consumer.cc:44
lsn_t m_consumed_lsn
Value reported by get_consumed_lsn().
Definition: log0consumer.h:79
void log_consumer_register(log_t &log, Log_consumer *log_consumer)
Register the given redo log consumer.
Definition: log0consumer.cc:73
void log_consumer_unregister(log_t &log, Log_consumer *log_consumer)
Unregister the given redo log consumer.
Definition: log0consumer.cc:79
Log_consumer * log_consumer_get_oldest(const log_t &log, lsn_t &oldest_needed_lsn)
Find the registered redo log consumer which has the smallest value reported by get_consumed_lsn() - i...
Definition: log0consumer.cc:86
Redo log basic types.
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:63
case opt name
Definition: sslopt-case.h:29
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:77