MySQL 8.4.2
Source Code Documentation
server_ongoing_transactions_handler.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 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 SERVER_ONGOING_TRANSACTIONS_HANDLER_INCLUDED
25#define SERVER_ONGOING_TRANSACTIONS_HANDLER_INCLUDED
26
29
30#include <queue>
31
33 public:
34 /** Initialize the class and get the server service */
36
37 /** Class destructor */
39
40 /**
41 Fetch the registry and the service for this class
42 @param stage_handler the stage handler to report progress
43
44 @returns false in case of success, or true otherwise
45 */
47
48 /**
49 Get the list of running transactions from the server
50 @param[out] ids an array of thread ids
51 @param[out] size the size of the array returned on ids
52 @returns 0 in case of success, 1 in case of error
53 */
54 bool get_server_running_transactions(ulong **ids, ulong *size);
55
56 /**
57 Gets running transactions and waits for its end
58
59 @param abort_flag cancel flag
60 @param id_to_ignore if different from 0, the method does not wait for it
61
62 @returns 0 in case of success, 1 in case of error
63 */
65 bool *abort_flag, my_thread_id id_to_ignore = 0);
66
67 /** Abort any running waiting process */
69
71 ulong gr_consistency_level, ulong hold_timeout,
72 enum_rpl_channel_type rpl_channel_type,
73 const THD *thd) override;
74
75 int before_commit(
78
82
84
86 rpl_gno gno) override;
87
88 private:
89 /** The transactions that finished while the service is running */
90 std::queue<my_thread_id> thread_ids_finished;
91
92 /** The lock for the query wait */
94
95 /** The server service handle */
97
98 /** A stage handler for reporting progress*/
100};
101
102#endif /* SERVER_ONGOING_TRANSACTIONS_HANDLER_INCLUDED */
Listener for transaction life cycle events.
Definition: group_transaction_observation_manager.h:33
enum_transaction_origin
Enum for transaction origins.
Definition: group_transaction_observation_manager.h:36
Definition: stage_monitor_handler.h:30
Definition: server_ongoing_transactions_handler.h:32
Plugin_stage_monitor_handler * stage_handler
A stage handler for reporting progress.
Definition: server_ongoing_transactions_handler.h:99
mysql_mutex_t query_wait_lock
The lock for the query wait.
Definition: server_ongoing_transactions_handler.h:93
bool get_server_running_transactions(ulong **ids, ulong *size)
Get the list of running transactions from the server.
Definition: server_ongoing_transactions_handler.cc:57
Server_ongoing_transactions_handler()
Initialize the class and get the server service.
Definition: server_ongoing_transactions_handler.cc:30
~Server_ongoing_transactions_handler() override
Class destructor.
Definition: server_ongoing_transactions_handler.cc:46
bool initialize_server_service(Plugin_stage_monitor_handler *stage_handler)
Fetch the registry and the service for this class.
Definition: server_ongoing_transactions_handler.cc:36
int before_commit(my_thread_id thread_id, Group_transaction_listener::enum_transaction_origin origin) override
Executed before commit.
Definition: server_ongoing_transactions_handler.cc:139
int before_transaction_begin(my_thread_id thread_id, ulong gr_consistency_level, ulong hold_timeout, enum_rpl_channel_type rpl_channel_type, const THD *thd) override
Executed before a transaction begins.
Definition: server_ongoing_transactions_handler.cc:134
std::queue< my_thread_id > thread_ids_finished
The transactions that finished while the service is running.
Definition: server_ongoing_transactions_handler.h:90
void abort_waiting_process()
Abort any running waiting process.
int after_rollback(my_thread_id thread_id) override
Executed after rollback.
Definition: server_ongoing_transactions_handler.cc:150
my_h_service generic_service
The server service handle.
Definition: server_ongoing_transactions_handler.h:96
int wait_for_current_transaction_load_execution(bool *abort_flag, my_thread_id id_to_ignore=0)
Gets running transactions and waits for its end.
Definition: server_ongoing_transactions_handler.cc:71
int after_commit(my_thread_id thread_id, rpl_sidno sidno, rpl_gno gno) override
Executed after commit.
Definition: server_ongoing_transactions_handler.cc:157
int before_rollback(my_thread_id thread_id, Group_transaction_listener::enum_transaction_origin origin) override
Executed before rollback.
Definition: server_ongoing_transactions_handler.cc:144
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:33
static my_thread_id thread_id
Definition: my_thr_init.cc:63
uint32 my_thread_id
Definition: my_thread_local.h:34
size_t size(const char *const c)
Definition: base64.h:46
enum_rpl_channel_type
Type of replication channel thread/transaction might be associated to.
Definition: rpl_context.h:50
mysql::gtid::gno_t rpl_gno
GNO, the second (numeric) component of a GTID, is an alias of mysql::gtid::gno_t.
Definition: rpl_gtid.h:112
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:108
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50