MySQL 8.4.0
Source Code Documentation
semisync_replica.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2006, 2024, Oracle and/or its affiliates.
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 designed to work 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 either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25#ifndef SEMISYNC_REPLICA_H
26#define SEMISYNC_REPLICA_H
27
28#include "my_inttypes.h"
30
31/**
32 The extension class for the slave of semi-synchronous replication
33*/
35 public:
37 ~ReplSemiSyncSlave() = default;
38
39 void setTraceLevel(unsigned long trace_level) { trace_level_ = trace_level; }
40
41 /* Initialize this class after MySQL parameters are initialized. this
42 * function should be called once at bootstrap time.
43 */
44 int initObject();
45
48
49 /* A slave reads the semi-sync packet header and separate the metadata
50 * from the payload data.
51 *
52 * Input:
53 * header - (IN) packet header pointer
54 * total_len - (IN) total packet length: metadata + payload
55 * need_reply - (IN) whether the master is waiting for the reply
56 * payload - (IN) payload: the replication event
57 * payload_len - (IN) payload length
58 *
59 * Return:
60 * 0: success; non-zero: error
61 */
62 int slaveReadSyncHeader(const char *header, unsigned long total_len,
63 bool *need_reply, const char **payload,
64 unsigned long *payload_len);
65
66 /* A slave replies to the master indicating its replication process. It
67 * indicates that the slave has received all events before the specified
68 * binlog position.
69 *
70 * Input:
71 * mysql - (IN) the mysql network connection
72 * binlog_filename - (IN) the reply point's binlog file name
73 * binlog_filepos - (IN) the reply point's binlog file offset
74 *
75 * Return:
76 * 0: success; non-zero: error
77 */
78 int slaveReply(MYSQL *mysql, const char *binlog_filename,
79 my_off_t binlog_filepos);
80
83
84 private:
85 /* True when initObject has been called */
86 bool init_done_ = false;
87 bool slave_enabled_ = false; /* semi-sycn is enabled on the slave */
88 MYSQL *mysql_reply = nullptr; /* connection to send reply */
89};
90
91/* System and status variables for the slave component */
93extern unsigned long rpl_semi_sync_replica_trace_level;
95
96#endif /* SEMISYNC_REPLICA_H */
Base class for semi-sync master and slave classes.
Definition: semisync.h:83
The extension class for the slave of semi-synchronous replication.
Definition: semisync_replica.h:34
int slaveReadSyncHeader(const char *header, unsigned long total_len, bool *need_reply, const char **payload, unsigned long *payload_len)
Definition: semisync_replica.cc:57
bool getSlaveEnabled()
Definition: semisync_replica.h:46
MYSQL * mysql_reply
Definition: semisync_replica.h:88
void setSlaveEnabled(bool enabled)
Definition: semisync_replica.h:47
int slaveStop(Binlog_relay_IO_param *param)
Definition: semisync_replica.cc:96
bool init_done_
Definition: semisync_replica.h:86
int slaveStart(Binlog_relay_IO_param *param)
Definition: semisync_replica.cc:82
int initObject()
Definition: semisync_replica.cc:40
void setTraceLevel(unsigned long trace_level)
Definition: semisync_replica.h:39
bool slave_enabled_
Definition: semisync_replica.h:87
~ReplSemiSyncSlave()=default
int slaveReply(MYSQL *mysql, const char *binlog_filename, my_off_t binlog_filepos)
Definition: semisync_replica.cc:103
ReplSemiSyncSlave()
Definition: semisync_replica.h:36
unsigned long trace_level_
Definition: semisync.h:50
Some integer typedefs for easier portability.
ulonglong my_off_t
Definition: my_inttypes.h:72
Definition: instrumented_condition_variable.h:32
required bool enabled
Definition: replication_group_member_actions.proto:33
unsigned long rpl_semi_sync_replica_trace_level
Definition: semisync_replica.cc:38
bool rpl_semi_sync_replica_enabled
Definition: semisync_replica.cc:36
char rpl_semi_sync_replica_status
Definition: semisync_replica.cc:37
Replication binlog relay IO observer parameter.
Definition: replication.h:590
Definition: mysql.h:300