MySQL 9.4.0
Source Code Documentation
log0consumer.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2021, 2025, 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 The caller should acquire log.files_mutex. */
49 virtual lsn_t get_consumed_lsn() const = 0;
50
51 /** Request the log consumer to consume faster.
52 @remarks This is called whenever the redo log consumer is the most lagging one
53 and it is critical to consume up to the request_lsn. The caller has to hold
54 log.files_mutex and log.limits_mutex. */
55 virtual void consumption_requested(lsn_t request_lsn) = 0;
56};
57
59 public:
60 explicit Log_user_consumer(const std::string &name);
61
62 const std::string &get_name() const override;
63
64 /** Set the lsn reported by get_consumed_lsn() to the given value.
65 It is required that the given value is greater or equal to the value
66 currently reported by the get_consumed_lsn().
67 @param[in] consumed_lsn the given lsn to report */
68 void set_consumed_lsn(lsn_t consumed_lsn);
69
70 lsn_t get_consumed_lsn() const override;
71
72 void consumption_requested(lsn_t request_lsn) override;
73
74 private:
75 /** Name of this consumer (saved value from ctor). */
76 const std::string m_name;
77
78 /** Value reported by get_consumed_lsn().
79 Set by set_consumed_lsn(lsn). */
81};
82
84 public:
85 explicit Log_checkpoint_consumer(log_t &log);
86
87 const std::string &get_name() const override;
88
89 lsn_t get_consumed_lsn() const override;
90
91 void consumption_requested(lsn_t request_lsn) override;
92
93 private:
95};
96
97/** Register the given redo log consumer.
98@param[in,out] log redo log
99@param[in] log_consumer redo log consumer to register */
100void log_consumer_register(log_t &log, Log_consumer *log_consumer);
101
102/** Unregister the given redo log consumer.
103@param[in,out] log redo log
104@param[in] log_consumer redo log consumer to unregister */
105void log_consumer_unregister(log_t &log, Log_consumer *log_consumer);
106
107/** Find the registered redo log consumer which has the smallest value
108reported by get_consumed_lsn() - ie. the most lagging consumer. When
109multiple consumers have the same value, any of them might be returned.
110@param[in] log the redo log
111@param[out] oldest_needed_lsn the oldest lsn needed by the most lagging consumer
112@return the most lagging consumer */
114 lsn_t &oldest_needed_lsn);
115
116#endif /* !log0consumer_h */
Definition: log0consumer.h:83
void consumption_requested(lsn_t request_lsn) override
Request the log consumer to consume faster.
Definition: log0consumer.cc:69
log_t & m_log
Definition: log0consumer.h:94
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(lsn_t request_lsn)=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:58
const std::string m_name
Name of this consumer (saved value from ctor).
Definition: log0consumer.h:76
void consumption_requested(lsn_t request_lsn) override
Request the log consumer to consume faster.
Definition: log0consumer.cc:56
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:80
void log_consumer_register(log_t &log, Log_consumer *log_consumer)
Register the given redo log consumer.
Definition: log0consumer.cc:77
void log_consumer_unregister(log_t &log, Log_consumer *log_consumer)
Unregister the given redo log consumer.
Definition: log0consumer.cc:83
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:90
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