MySQL 8.4.0
Source Code Documentation
semisync.h
Go to the documentation of this file.
1/* Copyright (C) 2007 Google Inc.
2 Copyright (c) 2000, 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_H
26#define SEMISYNC_H
27
28#include <mysql/plugin.h>
29
31#include "my_io.h"
32#include "my_thread.h"
33#include "mysqld_error.h"
34#include "sql/replication.h"
35
36struct SHOW_VAR;
37struct SYS_VAR;
38
39/**
40 This class is used to trace function calls and other process
41 information
42*/
43class Trace {
44 public:
45 static const unsigned long kTraceFunction;
46 static const unsigned long kTraceGeneral;
47 static const unsigned long kTraceDetail;
48 static const unsigned long kTraceNetWait;
49
50 unsigned long trace_level_; /* the level for tracing */
51
52 inline void function_enter(const char *func_name) {
54 LogErr(INFORMATION_LEVEL, ER_SEMISYNC_TRACE_ENTER_FUNC, func_name);
55 }
56
57 inline int function_exit(const char *func_name, int exit_code) {
59 LogErr(INFORMATION_LEVEL, ER_SEMISYNC_TRACE_EXIT_WITH_INT_EXIT_CODE,
60 func_name, exit_code);
61 return exit_code;
62 }
63
64 inline bool function_exit(const char *func_name, bool exit_code) {
66 LogErr(INFORMATION_LEVEL, ER_SEMISYNC_TRACE_EXIT_WITH_BOOL_EXIT_CODE,
67 func_name, exit_code ? "True" : "False");
68 return exit_code;
69 }
70
71 inline void function_exit(const char *func_name) {
73 LogErr(INFORMATION_LEVEL, ER_SEMISYNC_TRACE_EXIT, func_name);
74 }
75
77 Trace(unsigned long trace_level) : trace_level_(trace_level) {}
78};
79
80/**
81 Base class for semi-sync master and slave classes
82*/
83class ReplSemiSyncBase : public Trace {
84 public:
85 static const unsigned char kSyncHeader[2]; /* three byte packet header */
86
87 /* Constants in network packet header. */
88 static const unsigned char kPacketMagicNum;
89 static const unsigned char kPacketFlagSync;
90};
91
92/* The layout of a semisync slave reply packet:
93 1 byte for the magic num
94 8 bytes for the binlog position
95 n bytes for the binlog filename, terminated with a '\0'
96*/
97#define REPLY_MAGIC_NUM_LEN 1
98#define REPLY_BINLOG_POS_LEN 8
99#define REPLY_BINLOG_NAME_LEN (FN_REFLEN + 1)
100#define REPLY_MESSAGE_MAX_LENGTH \
101 (REPLY_MAGIC_NUM_LEN + REPLY_BINLOG_POS_LEN + REPLY_BINLOG_NAME_LEN)
102#define REPLY_MAGIC_NUM_OFFSET 0
103#define REPLY_BINLOG_POS_OFFSET (REPLY_MAGIC_NUM_OFFSET + REPLY_MAGIC_NUM_LEN)
104#define REPLY_BINLOG_NAME_OFFSET \
105 (REPLY_BINLOG_POS_OFFSET + REPLY_BINLOG_POS_LEN)
106
107/**
108 Return true if the named sysvar has been defined in the server.
109
110 @retval true The sysvar is defined.
111 @retval false Otherwise.
112*/
113bool is_sysvar_defined(const char *name);
114
115#endif /* SEMISYNC_H */
Base class for semi-sync master and slave classes.
Definition: semisync.h:83
static const unsigned char kPacketFlagSync
Definition: semisync.h:89
static const unsigned char kSyncHeader[2]
Definition: semisync.h:85
static const unsigned char kPacketMagicNum
Definition: semisync.h:88
This class is used to trace function calls and other process information.
Definition: semisync.h:43
int function_exit(const char *func_name, int exit_code)
Definition: semisync.h:57
static const unsigned long kTraceGeneral
Definition: semisync.h:46
void function_exit(const char *func_name)
Definition: semisync.h:71
static const unsigned long kTraceNetWait
Definition: semisync.h:48
static const unsigned long kTraceFunction
Definition: semisync.h:45
Trace(unsigned long trace_level)
Definition: semisync.h:77
unsigned long trace_level_
Definition: semisync.h:50
Trace()
Definition: semisync.h:76
static const unsigned long kTraceDetail
Definition: semisync.h:47
void function_enter(const char *func_name)
Definition: semisync.h:52
bool function_exit(const char *func_name, bool exit_code)
Definition: semisync.h:64
const mysql_service_log_builtins_t * log_bi
Definition: keyring_file.cc:136
#define L
Definition: ctype-tis620.cc:75
#define LogErr(severity, ecode,...)
Definition: log_builtins.h:843
Common #defines and includes for file and socket I/O.
@ INFORMATION_LEVEL
Definition: my_loglevel.h:45
Defines to make different thread packages compatible.
bool is_sysvar_defined(const char *name)
Return true if the named sysvar has been defined in the server.
Definition: semisync.cc:39
case opt name
Definition: sslopt-case.h:29
SHOW STATUS Server status variable.
Definition: status_var.h:79
Definition: plugin.h:69