MySQL 26.7.0
Source Code Documentation
binlog_tc_log_processing.h
Go to the documentation of this file.
1/* Copyright (c) 2025, 2026, 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#ifndef BINLOG_TC_LOG_PROCESSING_INCLUDED
24#define BINLOG_TC_LOG_PROCESSING_INCLUDED
25
26#include "my_inttypes.h"
27
28class MYSQL_BIN_LOG;
29class THD;
30
31/**
32 * An interface to delegate responsibility from MYSQL_BIN_LOG class.
33 * Specific implementation is injected into an instance of MYSQL_BIN_LOG class
34 * using `set_tc_log_processing` method. See Binlog_tc_log class for
35 * specific generic implementation of the below interface.
36 */
38 public:
40 virtual ~Binlog_tc_log_processing() = default;
41
42 /**
43 * Prepare the transaction in the transaction coordinator.
44 *
45 * @param binlog An instance of MYSQL_BIN_LOG upon which the prepare method
46 * executes
47 * @param thd The THD session object holding the transaction to be prepared.
48 * @param all Whether or not the prepare regards a full transaction or the
49 * statement being executed..
50 * @retval 0 success
51 * @retval 1 error
52 */
53 [[nodiscard]] virtual int prepare(MYSQL_BIN_LOG *binlog, THD *thd,
54 bool all) = 0;
55
56 /**
57 * Fetch and empty BINLOG_FLUSH_STAGE and COMMIT_ORDER_FLUSH_STAGE flush
58 * queues and flush transactions to the disk, and unblock threads executing
59 * slave preserve commit order.
60 *
61 * @param[in] check_and_skip_flush_logs
62 * if false then flush prepared records of transactions to the
63 * log of storage engine. if true then flush prepared records of transactions
64 * to the log of storage engine only if COMMIT_ORDER_FLUSH_STAGE queue is
65 * non-empty.
66 * @return Pointer to the first session of the BINLOG_FLUSH_STAGE stage
67 * queue.
68 */
70 bool check_and_skip_flush_logs) = 0;
71
72 /**
73 * Execute the flush stage.
74 *
75 * @param binlog An instance of MYSQL_BIN_LOG upon which the
76 * process_flush_stage_queue method executes
77 * @param[out] total_bytes_var Pointer to variable that will be set to total
78 * number of bytes flushed, or NULL.
79 *
80 * @param[out] out_queue_var Pointer to the sessions queue in flush stage.
81 * @return Error code on error, zero on success
82 */
84 my_off_t *total_bytes_var,
85 THD **out_queue_var) = 0;
86
87 /**
88 * Rolls back the underlying transaction in storage engines.
89 * Determines if the transaction to rollback is attached to the `thd`
90 * parameter or, instead, the `thd` parameter holds the XID for a detached
91 * transaction to be rolled back.
92 *
93 * @param thd THD session object.
94 * @param all Is set in case of explicit commit (COMMIT statement), or
95 * implicit commit issued by DDL. Is not set when called at the
96 * end of statement, even if autocommit=1.
97 * @return false if the transaction was rolled back, true if an error
98 * occurred.
99 */
100 [[nodiscard]] virtual bool rollback_in_engines(THD *thd, bool all) = 0;
101
102 /**
103 * Finishes the transaction in the engines. If the `commit_low` flag is set,
104 * will commit in the engines, otherwise, if the underlying statement is an
105 * `XA ROLLBACK`, it will rollback in the engines.
106 *
107 * @param thd The THD session object holding the transaction to finalize.
108 * @param all Finalizing a transaction (i.e. true) or a statement
109 * (i.e. false).
110 * @param run_after_commit In the case of a commit being issued, whether or
111 * not to run the `after_commit` hook.
112 */
113 virtual void finish_transaction_in_engines(THD *thd, bool all,
114 bool run_after_commit) = 0;
115
116 /**
117 * Register binlog observer
118 *
119 * @retval true It was possible to register binlog observer
120 * @retval false It was not possible to register binlog observer
121 */
122 [[nodiscard]] virtual bool binlog_register_observer() = 0;
123
124 /**
125 * Unregister binlog observer
126 */
127 virtual void binlog_unregister_observer() = 0;
128
129 /**
130 * Is persistence enabled
131 *
132 * @retval true Persistence is enabled
133 * @retval false Persistence is disabled
134 */
135 [[nodiscard]] virtual bool is_persistence_enabled() = 0;
136};
137
138#endif /* BINLOG_TC_LOG_PROCESSING_INCLUDED */
An interface to delegate responsibility from MYSQL_BIN_LOG class.
Definition: binlog_tc_log_processing.h:37
virtual bool is_persistence_enabled()=0
Is persistence enabled.
virtual bool rollback_in_engines(THD *thd, bool all)=0
Rolls back the underlying transaction in storage engines.
virtual void finish_transaction_in_engines(THD *thd, bool all, bool run_after_commit)=0
Finishes the transaction in the engines.
virtual ~Binlog_tc_log_processing()=default
virtual int process_flush_stage_queue(MYSQL_BIN_LOG *binlog, my_off_t *total_bytes_var, THD **out_queue_var)=0
Execute the flush stage.
Binlog_tc_log_processing()=default
virtual THD * fetch_and_process_flush_stage_queue(bool check_and_skip_flush_logs)=0
Fetch and empty BINLOG_FLUSH_STAGE and COMMIT_ORDER_FLUSH_STAGE flush queues and flush transactions t...
virtual bool binlog_register_observer()=0
Register binlog observer.
virtual int prepare(MYSQL_BIN_LOG *binlog, THD *thd, bool all)=0
Prepare the transaction in the transaction coordinator.
virtual void binlog_unregister_observer()=0
Unregister binlog observer.
Definition: binlog.h:108
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Some integer typedefs for easier portability.
ulonglong my_off_t
Definition: my_inttypes.h:72
Definition: pfs.cc:38