Skip to content

Commit

Permalink
Use last_master_timestamp from mysql_bin_log and not raft log
Browse files Browse the repository at this point in the history
Summary:
last_master_timestamp in rli->relay_log is not initialized
and not kept up to date. Although this sounds unintuitive from raft
point of view, its not from the non-raft standpoint. In non-raft mode
tailers are always served from binlog files and not from relay log
files and hence keeping mysql_bin_log up to date was understandable.

During the port of Dump log functionality to 8.0, I think by mistake
references to mysql_bin_log in rpl_binlog_sender were migrated to
Dump_log. This however caused a Uninitialized Memory Read issue because
of the uninitialized last_master_timestamp value.

Reviewed By: abhinav04sharma

Differential Revision: D34843214

fbshipit-source-id: a615975a302e13984a2f6d6b0b778213c30061f6
  • Loading branch information
anirbanr-fb authored and facebook-github-bot committed Mar 12, 2022
1 parent 0c8f7e9 commit 3d18955
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions sql/binlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4534,6 +4534,7 @@ MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_period, bool relay_log)
checksum_alg_reset(binary_log::BINLOG_CHECKSUM_ALG_UNDEF),
relay_log_checksum_alg(binary_log::BINLOG_CHECKSUM_ALG_UNDEF),
engine_binlog_pos(ULLONG_MAX),
last_master_timestamp(0),
previous_gtid_set_relaylog(nullptr),
raft_cur_log_ext(0),
setup_flush_done(false),
Expand Down
2 changes: 1 addition & 1 deletion sql/rpl_binlog_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ int Binlog_sender::send_heartbeat_event(my_off_t log_pos, bool send_timestamp) {
// value in the HB event otherwise we use now()
time_t ts = 0;
if (send_timestamp) {
ts = dump_log.get_log(false)->last_master_timestamp.load();
ts = mysql_bin_log.last_master_timestamp.load();
if (ts == 0) ts = time(nullptr);
}
int4store(header, ts);
Expand Down

0 comments on commit 3d18955

Please sign in to comment.