This class provides the feature to read events from relay log files.
More...
#include <rpl_applier_reader.h>
|
class | Stage_controller |
| It manages a stage and the related mutex and makes the process of locking and entering stage/unlock and exiting stage as monolithic operations. More...
|
|
This class provides the feature to read events from relay log files.
- Open() function just opens the first relay log file (rli->get_group_relay_log_name()) which need to be applied by slave.
- read_next_event() just returns the events one by one. It will close() current relay log and open next relay log file automatically when reaching the end of current relay log. Internally each relay log file is opened and read by using a Relaylog_file_reader.
- It will purge the applied relay logs accordingly when moving to next relay log.
- When reaching the end of active relay log file, it will wait for new events coming and make MTS checkpoints accordingly while waiting for events.
◆ Rpl_applier_reader() [1/2]
- Parameters
-
[in] | rli | relay log info is used in the function. So rli should be initialized before initializing Rpl_applier_reader object. |
◆ Rpl_applier_reader() [2/2]
◆ ~Rpl_applier_reader()
Rpl_applier_reader::~Rpl_applier_reader |
( |
| ) |
|
◆ close()
void Rpl_applier_reader::close |
( |
void |
| ) |
|
◆ debug_print_next_event_positions()
void Rpl_applier_reader::debug_print_next_event_positions |
( |
| ) |
|
|
private |
◆ generate_rotate_event()
In the case receiver thread says master skipped some events, it will generate a Rotate_log_event for applier to advance executed master log position.
◆ move_to_next_log()
bool Rpl_applier_reader::move_to_next_log |
( |
bool |
force_purge | ) |
|
|
private |
When reaching the end of current relay log file, close it and open next relay log.
purge old relay logs if necessary.
- Parameters
-
force_purge | This function rarely purges the current log before moving to the next. Sometimes, we need to enforce this purge, e.g. when receiver is waiting for available relay log space. The 'force_purge' will enable an aggressive relay log purge. Beware that 'move_to_next_log' with force_purge enabled, will ignore that current group position is lower than required and will reset it. Therefore, make sure that workers finished executing ALL scheduled jobs. |
- Return values
-
◆ open()
bool Rpl_applier_reader::open |
( |
const char ** |
errmsg | ) |
|
Open the first relay log file which will be read by applier and seek to correct position.
The file name and position are read from rli->get_group_master_log_name() and rli->get_group_relay_log_pos().
- Parameters
-
[out] | errmsg | Set the error message to it if any error happens. |
- Return values
-
group_relay_log_name may be different from the one in index file. For example group_relay_log_name includes a full path. But the one in index file has relative path. So set group_relay_log_name to the one in index file. It guarantees MYSQL_BIN_LOG::purge works well.
◆ operator=()
◆ purge_applied_logs()
bool Rpl_applier_reader::purge_applied_logs |
( |
| ) |
|
|
private |
Purge relay log files prior to m_rli->group_relay_log_name.
It is used to be called MYSQL_BIN_LOG::purge_first_log
- Return values
-
◆ read_active_log_end_pos()
bool Rpl_applier_reader::read_active_log_end_pos |
( |
| ) |
|
|
private |
It reads the coordinates up to which the receiver thread has written and check whether there is any event to be read.
- Return values
-
false | The applier has read all events. |
true | The applier is behind the receiver. |
◆ read_next_event()
Log_event * Rpl_applier_reader::read_next_event |
( |
| ) |
|
Read next event from relay log.
- It will wait until the receiver writes some events to relay log in case where there are no more events left to read from the active relay log.
- The caller must hold m_rli->data_lock. The lock will be released temporarily while waiting and required after waking up.
- The wait is protected by relay_log.lock_binlog_end_pos().
- Return values
-
Log_event* | A valid Log_event object. |
nullptr | Error happened or sql thread was killed. |
◆ reopen_log_reader_if_needed()
bool Rpl_applier_reader::reopen_log_reader_if_needed |
( |
| ) |
|
|
private |
It checks if the relaylog file reader should be reopened and then reopens the reader if receiver thread truncated some data from active relay log.
The caller must hold m_rli->data_lock
- Return values
-
◆ reset_seconds_behind_master()
void Rpl_applier_reader::reset_seconds_behind_master |
( |
| ) |
|
|
private |
◆ wait_for_new_event()
bool Rpl_applier_reader::wait_for_new_event |
( |
| ) |
|
|
private |
Waits for new events coming.
Returning successfully just means it gets a signal. That doesn't guarantee that any new event came.
- Return values
-
false | Success |
true | Error. The thread is killed or flush failed while executing mta_checkpoint_routine. |
- Note
- the The caller must hold m_rli->data_lock and relaylog.lock_binlog_end_pos().
◆ m_errmsg
const char* Rpl_applier_reader::m_errmsg = nullptr |
|
private |
Stores the error message which is used internally.
◆ m_linfo
◆ m_log_end_pos
my_off_t Rpl_applier_reader::m_log_end_pos = 0 |
|
private |
Stores active log's end position.
Thus avoids to call relay_log.get_binlog_log_pos() for each event.
◆ m_reading_active_log
bool Rpl_applier_reader::m_reading_active_log = true |
|
private |
◆ m_relay_log_purge
◆ m_relaylog_file_reader
◆ m_rli
The documentation for this class was generated from the following files: