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