MySQL  8.0.22
Source Code Documentation
hold_transactions.h
Go to the documentation of this file.
1 /* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef HOLD_TRANSACTIONS_INCLUDE
24 #define HOLD_TRANSACTIONS_INCLUDE
25 
26 #include "my_inttypes.h"
27 #include "sql/sql_class.h"
28 
29 /**
30  @class Hold_transactions
31  Class that contains the logic to hold transactions when
32  group_replication_consistency is set to BEFORE_ON_PRIMARY_FAILOVER
33 */
34 
36  public:
37  /**
38  Class constructor for hold transaction logic
39  */
41 
42  /**
43  Class destructor for hold transaction logic
44  */
46 
47  /**
48  Method to enable the hold of transactions when a primary election is
49  occurring
50  */
51  void enable();
52 
53  /**
54  Method to resume transactions on hold, primary election ended
55  */
56  void disable();
57 
58  /**
59  Method to wait for a primary failover to be complete
60 
61  @param hold_timeout seconds to abort wait
62 
63  @return the operation status
64  @retval 0 if success
65  @retval !=0 mysqld error code
66  */
67  int wait_until_primary_failover_complete(ulong hold_timeout);
68 
69  private:
70  /**
71  Method to verify if thread is killed
72  */
74  return current_thd != nullptr && current_thd->is_killed();
75  }
76 
77  /** is plugin currently applying backlog */
78  bool applying_backlog = false;
79 
80  /** protect and notify changes on applying_backlog */
83 };
84 
85 #endif /* HOLD_TRANSACTIONS_INCLUDE */
void disable()
Method to resume transactions on hold, primary election ended.
Definition: hold_transactions.cc:51
mysql_mutex_t primary_promotion_policy_mutex
protect and notify changes on applying_backlog
Definition: hold_transactions.h:81
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
int is_killed() const final
Has the owner thread been killed?
Definition: sql_class.h:2710
Some integer typedefs for easier portability.
Hold_transactions()
Class constructor for hold transaction logic.
Definition: hold_transactions.cc:27
mysql_cond_t primary_promotion_policy_condition
Definition: hold_transactions.h:82
bool is_thread_killed()
Method to verify if thread is killed.
Definition: hold_transactions.h:73
~Hold_transactions()
Class destructor for hold transaction logic.
Definition: hold_transactions.cc:36
Class that contains the logic to hold transactions when group_replication_consistency is set to BEFOR...
Definition: hold_transactions.h:35
bool applying_backlog
is plugin currently applying backlog
Definition: hold_transactions.h:78
int wait_until_primary_failover_complete(ulong hold_timeout)
Method to wait for a primary failover to be complete.
Definition: hold_transactions.cc:62
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
void enable()
Method to enable the hold of transactions when a primary election is occurring.
Definition: hold_transactions.cc:41
thread_local THD * current_thd
Definition: current_thd.cc:25