Skip to content

Commit 5042515

Browse files
committed
WL#7491: GTID-based replication applier recovery and positioning
Step 1: Add fields to the master and relay log info classes. ReviewBoard: 26586
1 parent 8b6d5da commit 5042515

File tree

4 files changed

+97
-3
lines changed

4 files changed

+97
-3
lines changed

sql/rpl_mi.cc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ Master_info::Master_info(
193193
auto_position(false),
194194
transaction_parser(
195195
Transaction_boundary_parser::TRX_BOUNDARY_PARSER_RECEIVER),
196-
reset(false) {
196+
reset(false),
197+
m_gtid_only_mode(false),
198+
m_is_receiver_position_info_invalid(false) {
197199
host[0] = 0;
198200
user[0] = 0;
199201
bind_addr[0] = 0;
@@ -785,3 +787,17 @@ void Master_info::get_flushed_relay_log_info(LOG_INFO *linfo) {
785787
sizeof(linfo->log_file_name) - 1);
786788
linfo->pos = flushed_relay_log_info.pos;
787789
}
790+
791+
void Master_info::set_receiver_position_info_invalid(bool invalid) {
792+
m_is_receiver_position_info_invalid = invalid;
793+
}
794+
795+
bool Master_info::is_receiver_position_info_invalid() const {
796+
return m_is_receiver_position_info_invalid;
797+
}
798+
799+
void Master_info::set_gtid_only_mode(bool gtid_only_mode) {
800+
m_gtid_only_mode = gtid_only_mode;
801+
}
802+
803+
bool Master_info::is_gtid_only_mode() const { return m_gtid_only_mode; }

sql/rpl_mi.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,55 @@ class Master_info : public Rpl_info {
750750

751751
void get_flushed_relay_log_info(LOG_INFO *linfo);
752752

753+
/**
754+
Marks the receiver position information (master_log_name, master_log_pos)
755+
as being invalid or not.
756+
757+
@param invalid The value to set the status to invalid or valid
758+
*/
759+
void set_receiver_position_info_invalid(bool invalid);
760+
761+
/**
762+
Returns if receiver position information is valid or invalid
763+
764+
@return true if receiver position information is not reliable,
765+
false otherwise.
766+
*/
767+
bool is_receiver_position_info_invalid() const;
768+
769+
/**
770+
Enable or disable the gtid_only mode
771+
772+
@param gtid_only_mode value to set gtid_only (enable/disable it)
773+
*/
774+
void set_gtid_only_mode(bool gtid_only_mode);
775+
776+
/**
777+
Returns if gtid_only is enabled or not
778+
779+
@return true if gtid_only mode is active for a channel,
780+
false otherwise.
781+
*/
782+
bool is_gtid_only_mode() const;
783+
753784
private:
754785
/*
755786
Holds the relay log coordinates (file name and position) of the last master
756787
coordinates flushed into Master_info repository.
757788
*/
758789
LOG_INFO flushed_relay_log_info;
790+
791+
/**
792+
Is the replica working in GTID only mode, meaning it does not
793+
persist position related information when executing or queing transactions.
794+
*/
795+
bool m_gtid_only_mode;
796+
797+
/**
798+
Are positions invalid. When true this means the values for
799+
receiver position related information might be outdated.
800+
*/
801+
bool m_is_receiver_position_info_invalid;
759802
};
760803

761804
#endif /* RPL_MI_H */

sql/rpl_rli.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ Relay_log_info::Relay_log_info(bool is_slave_recovery,
146146
m_privilege_checks_user_corrupted{false},
147147
m_require_row_format(false),
148148
m_require_table_primary_key_check(PK_CHECK_STREAM),
149+
m_is_applier_source_position_info_invalid(false),
149150
is_group_master_log_pos_invalid(false),
150151
log_space_total(0),
151152
ignore_log_space_limit(false),
@@ -3243,6 +3244,14 @@ void Relay_log_info::set_require_table_primary_key_check(
32433244
this->m_require_table_primary_key_check = require_pk;
32443245
}
32453246

3247+
void Relay_log_info::set_applier_source_position_info_invalid(bool invalid) {
3248+
m_is_applier_source_position_info_invalid = invalid;
3249+
}
3250+
3251+
bool Relay_log_info::is_applier_source_position_info_invalid() const {
3252+
return m_is_applier_source_position_info_invalid;
3253+
}
3254+
32463255
std::string Assign_gtids_to_anonymous_transactions_info::get_value() const {
32473256
return m_value;
32483257
}

sql/rpl_rli.h

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,21 @@ class Relay_log_info : public Rpl_info {
643643
*/
644644
Replication_transaction_boundary_parser transaction_parser;
645645

646+
/**
647+
Marks the applier position information as being invalid or not.
648+
649+
@param invalid value to set the position/file info as invalid or not
650+
*/
651+
void set_applier_source_position_info_invalid(bool invalid);
652+
653+
/**
654+
Returns if the applier positions are marked as being invalid or not.
655+
656+
@return true if applier position information is not reliable,
657+
false otherwise.
658+
*/
659+
bool is_applier_source_position_info_invalid() const;
660+
646661
/*
647662
Let's call a group (of events) :
648663
- a transaction
@@ -771,6 +786,15 @@ class Relay_log_info : public Rpl_info {
771786
*/
772787
enum_require_table_primary_key m_require_table_primary_key_check;
773788

789+
/**
790+
Are positions invalid. If true it means the applier related position
791+
information (group_master_log_name and group_master_log_pos) might
792+
be outdated.
793+
794+
Check also is_group_master_log_pos_invalid
795+
*/
796+
bool m_is_applier_source_position_info_invalid;
797+
774798
public:
775799
bool is_relay_log_truncated() { return m_relay_log_truncated; }
776800

@@ -826,12 +850,14 @@ class Relay_log_info : public Rpl_info {
826850
void fill_coord_err_buf(loglevel level, int err_code,
827851
const char *buff_coord) const;
828852

829-
/*
853+
/**
830854
Flag that the group_master_log_pos is invalid. This may occur
831855
(for example) after CHANGE MASTER TO RELAY_LOG_POS. This will
832856
be unset after the first event has been executed and the
833857
group_master_log_pos is valid again.
834-
*/
858+
859+
Check also m_is_applier_position_info_invalid
860+
*/
835861
bool is_group_master_log_pos_invalid;
836862

837863
/*

0 commit comments

Comments
 (0)