23#ifndef DEFINED_RPL_BINLOG_SENDER
24#define DEFINED_RPL_BINLOG_SENDER
34#include "mysqld_error.h"
421 inline void set_error(
int errorno,
const char *errmsg) {
433 set_error(ER_MASTER_FATAL_ERROR_READING_BINLOG, errmsg);
437 return m_errno == ER_MASTER_FATAL_ERROR_READING_BINLOG;
Contains the classes representing events occurring in the replication stream.
It owns an allocator, a byte stream, an event_data stream and an event object stream.
Definition: binlog_reader.h:246
Binlog_event_data_istream fetches byte data from Basic_istream and divides them into event_data chunk...
Definition: binlog_reader.h:57
It reads event_data from an event_data stream and deserialize them to event object.
Definition: binlog_reader.h:177
Binlog input file.
Definition: binlog_istream.h:236
Error_type
Possible errors which happens when reading an event.
Definition: binlog_istream.h:41
Binlog_sender reads events one by one.
Definition: rpl_binlog_sender.cc:213
The major logic of dump thread is implemented in this class.
Definition: rpl_binlog_sender.h:47
void set_error(int errorno, const char *errmsg)
Definition: rpl_binlog_sender.h:421
int send_packet_and_flush()
Definition: rpl_binlog_sender.cc:1359
THD * m_thd
Definition: rpl_binlog_sender.h:81
bool m_observe_transmission
Definition: rpl_binlog_sender.h:186
int after_send_hook(const char *log_file, my_off_t log_pos)
Definition: rpl_binlog_sender.cc:1374
String & m_packet
Definition: rpl_binlog_sender.h:82
my_off_t m_last_pos
Definition: rpl_binlog_sender.h:124
Binlog_sender(THD *thd, const char *start_file, my_off_t start_pos, Gtid_set *exclude_gtids, uint32 flag)
Definition: rpl_binlog_sender.cc:233
int send_heartbeat_event(my_off_t log_pos)
Checks if the heartbeat_version flag is set or not, and call the correct send_heartbeat_method accord...
Definition: rpl_binlog_sender.cc:560
int check_event_count()
Definition: rpl_binlog_sender.cc:1397
bool m_wait_new_events
Definition: rpl_binlog_sender.h:108
bool has_error()
Definition: rpl_binlog_sender.h:420
bool stop_waiting_for_update(my_off_t log_pos) const
Checks whether thread should continue awaiting new events.
Definition: rpl_binlog_sender.cc:794
static const float PACKET_SHRINK_FACTOR
The dual of PACKET_GROW_FACTOR.
Definition: rpl_binlog_sender.h:178
ushort m_half_buffer_size_req_counter
Definition: rpl_binlog_sender.h:129
uint32 m_flag
Definition: rpl_binlog_sender.h:180
void init()
Definition: rpl_binlog_sender.cc:256
char m_last_file_buf[FN_REFLEN]
Definition: rpl_binlog_sender.h:122
static const uint32 PACKET_MIN_SIZE
The minimum size of the buffer.
Definition: rpl_binlog_sender.h:166
bool m_gtid_clear_fd_created_flag
Definition: rpl_binlog_sender.h:95
const char * m_errmsg
Definition: rpl_binlog_sender.h:112
const char * m_start_file
Definition: rpl_binlog_sender.h:85
void run()
It checks the dump request and sends events to the client until it finish all events(for mysqlbinlog)...
Definition: rpl_binlog_sender.cc:381
std::chrono::nanoseconds m_last_event_sent_ts
Definition: rpl_binlog_sender.h:103
bool grow_packet(size_t extra_size)
This function SHALL grow the buffer of the packet if needed.
Definition: rpl_binlog_sender.cc:1407
void set_last_pos(my_off_t log_pos)
Definition: rpl_binlog_sender.h:445
binary_log::enum_binlog_checksum_alg m_event_checksum_alg
Definition: rpl_binlog_sender.h:100
int m_errno
Definition: rpl_binlog_sender.h:113
static const float PACKET_GROW_FACTOR
How much to grow the buffer each time we need to accommodate more bytes than it currently can hold.
Definition: rpl_binlog_sender.h:172
int send_heartbeat_event_v2(my_off_t log_pos)
It sends a heartbeat to the client, for the cases when the flag USE_HEARTBEAT_EVENT_V2 is set.
Definition: rpl_binlog_sender.cc:1283
int send_events(File_reader &reader, my_off_t end_pos)
It sends some events in a binlog file to the client.
Definition: rpl_binlog_sender.cc:566
int read_event(File_reader &reader, uchar **event_ptr, uint32 *event_len)
It reads an event from binlog file.
Definition: rpl_binlog_sender.cc:1213
std::chrono::nanoseconds m_heartbeat_period
Definition: rpl_binlog_sender.h:102
Diagnostics_area m_diag_area
Definition: rpl_binlog_sender.h:110
const char * log_read_error_msg(Binlog_read_error::Error_type error)
Transform read error numbers to error messages.
Definition: rpl_binlog_sender.cc:1193
int flush_net()
Definition: rpl_binlog_sender.cc:1328
int reset_transmit_packet(ushort flags, size_t event_len=0)
Definition: rpl_binlog_sender.cc:1064
bool shrink_packet()
This function SHALL shrink the size of the buffer used.
Definition: rpl_binlog_sender.cc:1440
bool m_transmit_started
Definition: rpl_binlog_sender.h:191
void cleanup()
Definition: rpl_binlog_sender.cc:359
LOG_INFO m_linfo
Definition: rpl_binlog_sender.h:98
bool m_check_previous_gtid_event
Definition: rpl_binlog_sender.h:94
static const ushort PACKET_SHRINK_COUNTER_THRESHOLD
Definition: rpl_binlog_sender.h:161
binary_log::enum_binlog_checksum_alg m_slave_checksum_alg
Definition: rpl_binlog_sender.h:101
int before_send_hook(const char *log_file, my_off_t log_pos)
Definition: rpl_binlog_sender.cc:1363
bool m_using_gtid_protocol
Definition: rpl_binlog_sender.h:93
Gtid_set * m_exclude_gtid
Definition: rpl_binlog_sender.h:92
Basic_binlog_file_reader< Binlog_ifile, Binlog_event_data_istream, Binlog_event_object_istream, Event_allocator > File_reader
Definition: rpl_binlog_sender.h:48
int send_packet()
Definition: rpl_binlog_sender.cc:1337
void set_fatal_error(const char *errmsg)
Definition: rpl_binlog_sender.h:432
void init_heartbeat_period()
Definition: rpl_binlog_sender.cc:839
void set_prev_event_type(binary_log::Log_event_type type)
Sets the value of the previously processed event.
Definition: rpl_binlog_sender.h:70
char m_errmsg_buf[MYSQL_ERRMSG_SIZE]
Definition: rpl_binlog_sender.h:111
bool event_checksum_on()
Definition: rpl_binlog_sender.h:440
void calc_shrink_buffer_size(size_t current_size)
Helper function to recalculate the new size for the m_new_shrink_size.
Definition: rpl_binlog_sender.cc:1510
int check_start_file()
Check if the requested binlog file and position are valid.
Definition: rpl_binlog_sender.cc:854
bool skip_event(const uchar *event_ptr, bool in_exclude_group)
It checks if the event is in m_exclude_gtid.
Definition: rpl_binlog_sender.cc:740
int send_binlog(File_reader &reader, my_off_t start_pos)
It dumps a binlog file.
Definition: rpl_binlog_sender.cc:491
bool is_fatal_error()
Definition: rpl_binlog_sender.h:436
void init_checksum_alg()
Definition: rpl_binlog_sender.cc:993
int send_format_description_event(File_reader &reader, my_off_t start_pos)
When starting to dump a binlog file, Format_description_log_event is read and sent first.
Definition: rpl_binlog_sender.cc:1091
void set_unknown_error(const char *errmsg)
Definition: rpl_binlog_sender.h:428
int wait_without_heartbeat(my_off_t log_pos)
Definition: rpl_binlog_sender.cc:831
void calc_event_checksum(uchar *event_ptr, size_t event_len)
Definition: rpl_binlog_sender.cc:1057
void set_last_file(const char *log_file)
Definition: rpl_binlog_sender.h:450
static const uint32 PACKET_MAX_SIZE
Definition: rpl_binlog_sender.h:155
size_t m_new_shrink_size
Definition: rpl_binlog_sender.h:135
int wait_with_heartbeat(my_off_t log_pos)
Definition: rpl_binlog_sender.cc:802
int has_previous_gtid_log_event(File_reader &reader, bool *found)
It checks if a binlog file has Previous_gtid_log_event.
Definition: rpl_binlog_sender.cc:1177
const char * m_last_file
Definition: rpl_binlog_sender.h:123
binary_log::Log_event_type m_prev_event_type
Type of the previously processed event.
Definition: rpl_binlog_sender.h:195
int send_heartbeat_event_v1(my_off_t log_pos)
It sends a heartbeat to the client.
Definition: rpl_binlog_sender.cc:1257
int fake_rotate_event(const char *next_log_file, my_off_t log_pos)
It sends a faked rotate event which does not exist physically in any binlog to the slave.
Definition: rpl_binlog_sender.cc:1022
std::pair< my_off_t, int > get_binlog_end_pos(File_reader &reader)
It gets the end position of the binlog file.
Definition: rpl_binlog_sender.cc:531
int m_event_count
Definition: rpl_binlog_sender.h:412
my_off_t m_start_pos
Definition: rpl_binlog_sender.h:86
size_t calc_grow_buffer_size(size_t current_size, size_t min_size)
Helper function to recalculate a new size for the growing buffer.
Definition: rpl_binlog_sender.cc:1487
int wait_new_events(my_off_t log_pos)
It waits until receiving an update_cond signal.
Definition: rpl_binlog_sender.cc:761
bool check_event_type(binary_log::Log_event_type type, const char *log_file, my_off_t log_pos)
Check if it is allowed to send this event type.
Definition: rpl_binlog_sender.cc:682
Stores status of the currently executed statement.
Definition: sql_error.h:268
Represents a set of GTIDs.
Definition: rpl_gtid.h:1454
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
static int flags[50]
Definition: hp_test1.cc:39
static int flag
Definition: hp_test1.cc:39
Some integer typedefs for easier portability.
ulonglong my_off_t
Definition: my_inttypes.h:71
unsigned char uchar
Definition: my_inttypes.h:51
uint32_t uint32
Definition: my_inttypes.h:66
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:82
Common definition between mysql server & client.
#define MYSQL_ERRMSG_SIZE
Max length of a error message.
Definition: mysql_com.h:879
Logfile log_file
Definition: mysqltest.cc:262
enum_binlog_checksum_alg
Enumeration spcifying checksum algorithm used to encode a binary log event.
Definition: binlog_event.h:420
@ BINLOG_CHECKSUM_ALG_ENUM_END
the cut line: valid alg range is [1, 0x7f]
Definition: binlog_event.h:429
@ BINLOG_CHECKSUM_ALG_OFF
Events are without checksum though its generator is checksum-capable New Master (NM).
Definition: binlog_event.h:425
Log_event_type
Enumeration type for the different types of log events.
Definition: binlog_event.h:274
required string type
Definition: replication_group_member_actions.proto:33
char log_file_name[FN_REFLEN]
Definition: binlog.h:118