MySQL  8.0.21
Source Code Documentation
semisync_slave.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License, version 2.0,
6  as published by the Free Software Foundation.
7 
8  This program is also distributed with certain software (including
9  but not limited to OpenSSL) that is licensed under separate terms,
10  as designated in a particular file or component or in included license
11  documentation. The authors of MySQL hereby grant you an additional
12  permission to link the program and your derivative works with the
13  separately licensed software that they have included with MySQL.
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 SEMISYNC_SLAVE_H
25 #define SEMISYNC_SLAVE_H
26 
27 #include "my_inttypes.h"
29 
30 /**
31  The extension class for the slave of semi-synchronous replication
32 */
34  public:
37 
38  void setTraceLevel(unsigned long trace_level) { trace_level_ = trace_level; }
39 
40  /* Initialize this class after MySQL parameters are initialized. this
41  * function should be called once at bootstrap time.
42  */
43  int initObject();
44 
45  bool getSlaveEnabled() { return slave_enabled_; }
47 
48  /* A slave reads the semi-sync packet header and separate the metadata
49  * from the payload data.
50  *
51  * Input:
52  * header - (IN) packet header pointer
53  * total_len - (IN) total packet length: metadata + payload
54  * need_reply - (IN) whether the master is waiting for the reply
55  * payload - (IN) payload: the replication event
56  * payload_len - (IN) payload length
57  *
58  * Return:
59  * 0: success; non-zero: error
60  */
61  int slaveReadSyncHeader(const char *header, unsigned long total_len,
62  bool *need_reply, const char **payload,
63  unsigned long *payload_len);
64 
65  /* A slave replies to the master indicating its replication process. It
66  * indicates that the slave has received all events before the specified
67  * binlog position.
68  *
69  * Input:
70  * mysql - (IN) the mysql network connection
71  * binlog_filename - (IN) the reply point's binlog file name
72  * binlog_filepos - (IN) the reply point's binlog file offset
73  *
74  * Return:
75  * 0: success; non-zero: error
76  */
77  int slaveReply(MYSQL *mysql, const char *binlog_filename,
78  my_off_t binlog_filepos);
79 
81  int slaveStop(Binlog_relay_IO_param *param);
82 
83  private:
84  /* True when initObject has been called */
85  bool init_done_ = false;
86  bool slave_enabled_ = false; /* semi-sycn is enabled on the slave */
87  MYSQL *mysql_reply = nullptr; /* connection to send reply */
88 };
89 
90 /* System and status variables for the slave component */
91 extern bool rpl_semi_sync_slave_enabled;
92 extern unsigned long rpl_semi_sync_slave_trace_level;
93 extern char rpl_semi_sync_slave_status;
94 
95 #endif /* SEMISYNC_SLAVE_H */
unsigned long trace_level_
Definition: semisync.h:49
bool slave_enabled_
Definition: semisync_slave.h:86
int slaveStop(Binlog_relay_IO_param *param)
Definition: semisync_slave.cc:93
The extension class for the slave of semi-synchronous replication.
Definition: semisync_slave.h:33
Some integer typedefs for easier portability.
char rpl_semi_sync_slave_status
Definition: semisync_slave.cc:35
void setSlaveEnabled(bool enabled)
Definition: semisync_slave.h:46
bool enabled
true if enabled.
Definition: buf0dblwr.cc:81
bool init_done_
Definition: semisync_slave.h:85
unsigned long rpl_semi_sync_slave_trace_level
Definition: semisync_slave.cc:36
bool rpl_semi_sync_slave_enabled
Definition: semisync_slave.cc:34
bool getSlaveEnabled()
Definition: semisync_slave.h:45
ReplSemiSyncSlave()
Definition: semisync_slave.h:35
void setTraceLevel(unsigned long trace_level)
Definition: semisync_slave.h:38
int slaveReply(MYSQL *mysql, const char *binlog_filename, my_off_t binlog_filepos)
Definition: semisync_slave.cc:100
Replication binlog relay IO observer parameter.
Definition: replication.h:581
int slaveReadSyncHeader(const char *header, unsigned long total_len, bool *need_reply, const char **payload, unsigned long *payload_len)
Definition: semisync_slave.cc:55
~ReplSemiSyncSlave()
Definition: semisync_slave.h:36
ulonglong my_off_t
Definition: my_inttypes.h:71
MYSQL * mysql_reply
Definition: semisync_slave.h:87
Base class for semi-sync master and slave classes.
Definition: semisync.h:82
static MYSQL mysql
Definition: mysql.cc:152
int initObject()
Definition: semisync_slave.cc:38
Definition: mysql.h:296
int slaveStart(Binlog_relay_IO_param *param)
Definition: semisync_slave.cc:80
#define false
Definition: config_static.h:43