MCPcopy Create free account
hub / github.com/MariaDB/server / send_engine_events

Function send_engine_events

sql/sql_repl.cc:3343–3483  ·  view source on GitHub ↗

* Send events from binlog implemented in storage engine. Will wait for more * data to become available as needed. * * return 0 - OK * else NOK */

Source from the content-addressed store, hash-verified

3341 * else NOK
3342 */
3343static int send_engine_events(binlog_send_info *info, LOG_INFO* linfo)
3344{
3345 int error;
3346 ulong ev_offset;
3347
3348 String *packet= info->packet;
3349 handler_binlog_reader *reader= info->engine_binlog_reader;
3350 DBUG_ASSERT(reader);
3351 while (!should_stop(info))
3352 {
3353 /* reset the transmit packet for the event read from binary log
3354 file */
3355 if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg))
3356 return 1;
3357
3358 error= reader->read_log_event(packet, packet->length(),
3359 info->thd->variables.max_allowed_packet);
3360 if (unlikely(error) && error != LOG_READ_EOF)
3361 {
3362 set_read_error(info, error);
3363 return 1;
3364 }
3365
3366 uint64_t prev_file_no= linfo->file_no.load(std::memory_order_relaxed);
3367 if (unlikely(prev_file_no == ~(uint64_t)0) ||
3368 unlikely(reader->cur_file_no > prev_file_no))
3369 {
3370 linfo->file_no.store(reader->cur_file_no, std::memory_order_relaxed);
3371 (*opt_binlog_engine_hton->get_filename)(info->log_file_name,
3372 reader->cur_file_no);
3373 }
3374 linfo->pos= (my_off_t) reader->cur_file_pos;
3375
3376 if (error == LOG_READ_EOF)
3377 {
3378 /**
3379 * check if we should wait for more data
3380 */
3381 if ((info->flags & BINLOG_DUMP_NON_BLOCK) ||
3382 (info->thd->variables.server_id == 0))
3383 {
3384 info->should_stop= true;
3385 return 0;
3386 }
3387
3388 /**
3389 * flush data before waiting
3390 */
3391 if (net_flush(info->net))
3392 {
3393 info->errmsg= "failed on net_flush()";
3394 info->error= ER_UNKNOWN_ERROR;
3395 return 1;
3396 }
3397
3398 while (!should_stop(info, true) && !reader->data_available())
3399 {
3400 struct timespec ts;

Callers 1

send_one_binlog_fileFunction · 0.85

Calls 15

should_stopFunction · 0.85
reset_transmit_packetFunction · 0.85
set_read_errorFunction · 0.85
net_flushFunction · 0.85
send_heartbeat_eventFunction · 0.85
get_heartbeat_periodFunction · 0.85
fake_rotate_eventFunction · 0.85
send_event_to_slaveFunction · 0.85
debug_sync_set_actionFunction · 0.70
read_log_eventMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected