MySQL 8.3.0
Source Code Documentation
semisync_replica.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2006, 2023, 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 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_REPLICA_H
25#define SEMISYNC_REPLICA_H
26
27#include "my_inttypes.h"
29
30/**
31 The extension class for the slave of semi-synchronous replication
32*/
34 public:
36 ~ReplSemiSyncSlave() = default;
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
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
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 */
92extern unsigned long rpl_semi_sync_replica_trace_level;
94
95#endif /* SEMISYNC_REPLICA_H */
Base class for semi-sync master and slave classes.
Definition: semisync.h:82
The extension class for the slave of semi-synchronous replication.
Definition: semisync_replica.h:33
int slaveReadSyncHeader(const char *header, unsigned long total_len, bool *need_reply, const char **payload, unsigned long *payload_len)
Definition: semisync_replica.cc:56
bool getSlaveEnabled()
Definition: semisync_replica.h:45
MYSQL * mysql_reply
Definition: semisync_replica.h:87
void setSlaveEnabled(bool enabled)
Definition: semisync_replica.h:46
int slaveStop(Binlog_relay_IO_param *param)
Definition: semisync_replica.cc:95
bool init_done_
Definition: semisync_replica.h:85
int slaveStart(Binlog_relay_IO_param *param)
Definition: semisync_replica.cc:81
int initObject()
Definition: semisync_replica.cc:39
void setTraceLevel(unsigned long trace_level)
Definition: semisync_replica.h:38
bool slave_enabled_
Definition: semisync_replica.h:86
~ReplSemiSyncSlave()=default
int slaveReply(MYSQL *mysql, const char *binlog_filename, my_off_t binlog_filepos)
Definition: semisync_replica.cc:102
ReplSemiSyncSlave()
Definition: semisync_replica.h:35
unsigned long trace_level_
Definition: semisync.h:49
Some integer typedefs for easier portability.
ulonglong my_off_t
Definition: my_inttypes.h:71
Definition: instrumented_condition_variable.h:31
required bool enabled
Definition: replication_group_member_actions.proto:32
unsigned long rpl_semi_sync_replica_trace_level
Definition: semisync_replica.cc:37
bool rpl_semi_sync_replica_enabled
Definition: semisync_replica.cc:35
char rpl_semi_sync_replica_status
Definition: semisync_replica.cc:36
Replication binlog relay IO observer parameter.
Definition: replication.h:588
Definition: mysql.h:297