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