24#ifndef DEFINED_RPL_BINLOG_SENDER
25#define DEFINED_RPL_BINLOG_SENDER
35#include "mysqld_error.h"
423 inline void set_error(
int errorno,
const char *errmsg) {
435 set_error(ER_SOURCE_FATAL_ERROR_READING_BINLOG, errmsg);
439 return m_errno == ER_SOURCE_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:295
Binlog_event_data_istream fetches byte data from Basic_istream and divides them into event_data chunk...
Definition: binlog_reader.h:58
It reads event_data from an event_data stream and deserialize them to event object.
Definition: binlog_reader.h:180
Binlog input file.
Definition: binlog_istream.h:241
Error_type
Possible errors which happens when reading an event.
Definition: binlog_istream.h:42
Binlog_sender reads events one by one.
Definition: rpl_binlog_sender.cc:221
The major logic of dump thread is implemented in this class.
Definition: rpl_binlog_sender.h:48
void set_error(int errorno, const char *errmsg)
Definition: rpl_binlog_sender.h:423
int send_packet_and_flush()
Definition: rpl_binlog_sender.cc:1372
THD * m_thd
Definition: rpl_binlog_sender.h:82
bool m_observe_transmission
Definition: rpl_binlog_sender.h:188
void set_prev_event_type(mysql::binlog::event::Log_event_type type)
Sets the value of the previously processed event.
Definition: rpl_binlog_sender.h:71
int after_send_hook(const char *log_file, my_off_t log_pos)
Definition: rpl_binlog_sender.cc:1387
String & m_packet
Definition: rpl_binlog_sender.h:83
my_off_t m_last_pos
Definition: rpl_binlog_sender.h:125
Binlog_sender(THD *thd, const char *start_file, my_off_t start_pos, Gtid_set *exclude_gtids, uint32 flag)
Definition: rpl_binlog_sender.cc:241
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:566
int check_event_count()
Definition: rpl_binlog_sender.cc:1410
bool m_wait_new_events
Definition: rpl_binlog_sender.h:109
bool has_error()
Definition: rpl_binlog_sender.h:422
bool stop_waiting_for_update(my_off_t log_pos) const
Checks whether thread should continue awaiting new events.
Definition: rpl_binlog_sender.cc:804
static const float PACKET_SHRINK_FACTOR
The dual of PACKET_GROW_FACTOR.
Definition: rpl_binlog_sender.h:180
ushort m_half_buffer_size_req_counter
Definition: rpl_binlog_sender.h:130
uint32 m_flag
Definition: rpl_binlog_sender.h:182
void init()
Definition: rpl_binlog_sender.cc:264
char m_last_file_buf[FN_REFLEN]
Definition: rpl_binlog_sender.h:123
static const uint32 PACKET_MIN_SIZE
The minimum size of the buffer.
Definition: rpl_binlog_sender.h:168
bool m_gtid_clear_fd_created_flag
Definition: rpl_binlog_sender.h:96
const char * m_errmsg
Definition: rpl_binlog_sender.h:113
const char * m_start_file
Definition: rpl_binlog_sender.h:86
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:386
std::chrono::nanoseconds m_last_event_sent_ts
Definition: rpl_binlog_sender.h:104
bool grow_packet(size_t extra_size)
This function SHALL grow the buffer of the packet if needed.
Definition: rpl_binlog_sender.cc:1420
void set_last_pos(my_off_t log_pos)
Definition: rpl_binlog_sender.h:449
mysql::binlog::event::enum_binlog_checksum_alg m_event_checksum_alg
Definition: rpl_binlog_sender.h:101
int m_errno
Definition: rpl_binlog_sender.h:114
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:174
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:1294
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:572
int read_event(File_reader &reader, uchar **event_ptr, uint32 *event_len)
It reads an event from binlog file.
Definition: rpl_binlog_sender.cc:1224
std::chrono::nanoseconds m_heartbeat_period
Definition: rpl_binlog_sender.h:103
Diagnostics_area m_diag_area
Definition: rpl_binlog_sender.h:111
const char * log_read_error_msg(Binlog_read_error::Error_type error)
Transform read error numbers to error messages.
Definition: rpl_binlog_sender.cc:1204
int flush_net()
Definition: rpl_binlog_sender.cc:1341
int reset_transmit_packet(ushort flags, size_t event_len=0)
Definition: rpl_binlog_sender.cc:1071
bool shrink_packet()
This function SHALL shrink the size of the buffer used.
Definition: rpl_binlog_sender.cc:1453
bool m_transmit_started
Definition: rpl_binlog_sender.h:193
void cleanup()
Definition: rpl_binlog_sender.cc:366
bool m_check_previous_gtid_event
Definition: rpl_binlog_sender.h:95
static const ushort PACKET_SHRINK_COUNTER_THRESHOLD
Definition: rpl_binlog_sender.h:163
mysql::binlog::event::enum_binlog_checksum_alg m_slave_checksum_alg
Definition: rpl_binlog_sender.h:102
int before_send_hook(const char *log_file, my_off_t log_pos)
Definition: rpl_binlog_sender.cc:1376
bool m_using_gtid_protocol
Definition: rpl_binlog_sender.h:94
Gtid_set * m_exclude_gtid
Definition: rpl_binlog_sender.h:93
Basic_binlog_file_reader< Binlog_ifile, Binlog_event_data_istream, Binlog_event_object_istream, Event_allocator > File_reader
Definition: rpl_binlog_sender.h:49
int send_packet()
Definition: rpl_binlog_sender.cc:1350
void set_fatal_error(const char *errmsg)
Definition: rpl_binlog_sender.h:434
void init_heartbeat_period()
Definition: rpl_binlog_sender.cc:849
char m_errmsg_buf[MYSQL_ERRMSG_SIZE]
Definition: rpl_binlog_sender.h:112
bool event_checksum_on()
Definition: rpl_binlog_sender.h:442
Log_info m_linfo
Definition: rpl_binlog_sender.h:99
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:1523
int check_start_file()
Check if the requested binlog file and position are valid.
Definition: rpl_binlog_sender.cc:864
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:749
int send_binlog(File_reader &reader, my_off_t start_pos)
It dumps a binlog file.
Definition: rpl_binlog_sender.cc:497
bool is_fatal_error()
Definition: rpl_binlog_sender.h:438
void init_checksum_alg()
Definition: rpl_binlog_sender.cc:999
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:1098
void set_unknown_error(const char *errmsg)
Definition: rpl_binlog_sender.h:430
int wait_without_heartbeat(my_off_t log_pos)
Definition: rpl_binlog_sender.cc:841
void calc_event_checksum(uchar *event_ptr, size_t event_len)
Definition: rpl_binlog_sender.cc:1064
void set_last_file(const char *log_file)
Definition: rpl_binlog_sender.h:454
static const uint32 PACKET_MAX_SIZE
Definition: rpl_binlog_sender.h:157
size_t m_new_shrink_size
Definition: rpl_binlog_sender.h:136
int wait_with_heartbeat(my_off_t log_pos)
Definition: rpl_binlog_sender.cc:812
mysql::binlog::event::Log_event_type m_prev_event_type
Type of the previously processed event.
Definition: rpl_binlog_sender.h:197
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:1187
const char * m_last_file
Definition: rpl_binlog_sender.h:124
int send_heartbeat_event_v1(my_off_t log_pos)
It sends a heartbeat to the client.
Definition: rpl_binlog_sender.cc:1268
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:1029
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:537
int m_event_count
Definition: rpl_binlog_sender.h:414
my_off_t m_start_pos
Definition: rpl_binlog_sender.h:87
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:1500
int wait_new_events(my_off_t log_pos)
It waits until receiving an update_cond signal.
Definition: rpl_binlog_sender.cc:771
bool check_event_type(mysql::binlog::event::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:690
Stores status of the currently executed statement.
Definition: sql_error.h:269
Represents a set of GTIDs.
Definition: rpl_gtid.h:1557
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
static int flags[50]
Definition: hp_test1.cc:40
static int flag
Definition: hp_test1.cc:40
Some integer typedefs for easier portability.
ulonglong my_off_t
Definition: my_inttypes.h:72
unsigned char uchar
Definition: my_inttypes.h:52
uint32_t uint32
Definition: my_inttypes.h:67
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:83
Common definition between mysql server & client.
#define MYSQL_ERRMSG_SIZE
Max length of a error message.
Definition: mysql_com.h:881
Logfile log_file
Definition: mysqltest.cc:269
Log_event_type
Enumeration type for the different types of log events.
Definition: binlog_event.h:278
enum_binlog_checksum_alg
Enumeration spcifying checksum algorithm used to encode a binary log event.
Definition: binlog_event.h:454
@ BINLOG_CHECKSUM_ALG_OFF
Events are without checksum though its generator is checksum-capable New Master (NM).
Definition: binlog_event.h:459
@ BINLOG_CHECKSUM_ALG_ENUM_END
the cut line: valid alg range is [1, 0x7f]
Definition: binlog_event.h:463
required string type
Definition: replication_group_member_actions.proto:34
Definition: binlog_index.h:86
char log_file_name[FN_REFLEN]
Definition: binlog_index.h:89