summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqlbinlog.cc6
-rw-r--r--sql/log.cc4
-rw-r--r--sql/log_event.cc8
-rw-r--r--sql/log_event.h1
-rw-r--r--sql/rpl_parallel.cc2
-rw-r--r--sql/rpl_rli.cc2
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sql_repl.cc71
8 files changed, 78 insertions, 18 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index cca3fba5325..d7ffadb1dc6 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -2736,7 +2736,7 @@ static Exit_status check_header(IO_CACHE* file,
Format_description_log_event *new_description_event;
my_b_seek(file, tmp_pos); /* seek back to event's start */
if (!(new_description_event= (Format_description_log_event*)
- Log_event::read_log_event(file, 0, glob_description_event,
+ Log_event::read_log_event(file, glob_description_event,
opt_verify_binlog_checksum)))
/* EOF can't be hit here normally, so it's a real error */
{
@@ -2770,7 +2770,7 @@ static Exit_status check_header(IO_CACHE* file,
{
Log_event *ev;
my_b_seek(file, tmp_pos); /* seek back to event's start */
- if (!(ev= Log_event::read_log_event(file, 0, glob_description_event,
+ if (!(ev= Log_event::read_log_event(file, glob_description_event,
opt_verify_binlog_checksum)))
{
/* EOF can't be hit here normally, so it's a real error */
@@ -2884,7 +2884,7 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
char llbuff[21];
my_off_t old_off = my_b_tell(file);
- Log_event* ev = Log_event::read_log_event(file, 0, glob_description_event,
+ Log_event* ev = Log_event::read_log_event(file, glob_description_event,
opt_verify_binlog_checksum);
if (!ev)
{
diff --git a/sql/log.cc b/sql/log.cc
index e5ff85e4544..2d29f7d626a 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -9918,7 +9918,7 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name,
for (;;)
{
while ((ev= Log_event::read_log_event(first_round ? first_log : &log,
- 0, fdle, opt_master_verify_checksum))
+ fdle, opt_master_verify_checksum))
&& ev->is_valid())
{
enum Log_event_type typ= ev->get_type_code();
@@ -10159,7 +10159,7 @@ MYSQL_BIN_LOG::do_binlog_recovery(const char *opt_name, bool do_xa_recovery)
return 1;
}
- if ((ev= Log_event::read_log_event(&log, 0, &fdle,
+ if ((ev= Log_event::read_log_event(&log, &fdle,
opt_master_verify_checksum)) &&
ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
{
diff --git a/sql/log_event.cc b/sql/log_event.cc
index f1ceaec6456..7fe00b2bf43 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1854,7 +1854,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
DBUG_RETURN(0);
}
-Log_event* Log_event::read_log_event(IO_CACHE* file, mysql_mutex_t* log_lock,
+Log_event* Log_event::read_log_event(IO_CACHE* file,
const Format_description_log_event *fdle,
my_bool crc_check)
{
@@ -1864,9 +1864,6 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, mysql_mutex_t* log_lock,
const char *error= 0;
Log_event *res= 0;
- if (log_lock)
- mysql_mutex_lock(log_lock);
-
switch (read_log_event(file, &event, fdle, BINLOG_CHECKSUM_ALG_OFF))
{
case 0:
@@ -1903,8 +1900,6 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, mysql_mutex_t* log_lock,
res->register_temp_buf(event.release(), true);
err:
- if (log_lock)
- mysql_mutex_unlock(log_lock);
if (error)
{
DBUG_ASSERT(!res);
@@ -9735,7 +9730,6 @@ int Execute_load_log_event::do_apply_event(rpl_group_info *rgi)
}
if (!(lev= (Load_log_event*)
Log_event::read_log_event(&file,
- (mysql_mutex_t*)0,
rli->relay_log.description_event_for_exec,
opt_slave_sql_verify_checksum)) ||
lev->get_type_code() != NEW_LOAD_EVENT)
diff --git a/sql/log_event.h b/sql/log_event.h
index c8f3241cb3d..9fb14f0eae1 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -1300,7 +1300,6 @@ public:
constructor and pass description_event as an argument.
*/
static Log_event* read_log_event(IO_CACHE* file,
- mysql_mutex_t* log_lock,
const Format_description_log_event
*description_event,
my_bool crc_check);
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index 4a6e813d73b..2c5ef76681c 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -823,7 +823,7 @@ do_retry:
for (;;)
{
old_offset= cur_offset;
- ev= Log_event::read_log_event(&rlog, 0, description_event,
+ ev= Log_event::read_log_event(&rlog, description_event,
opt_slave_sql_verify_checksum);
cur_offset= my_b_tell(&rlog);
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index efb256fbe11..28835118fdd 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -538,7 +538,7 @@ read_relay_log_description_event(IO_CACHE *cur_log, ulonglong start_pos,
if (my_b_tell(cur_log) >= start_pos)
break;
- if (!(ev= Log_event::read_log_event(cur_log, 0, fdev,
+ if (!(ev= Log_event::read_log_event(cur_log, fdev,
opt_slave_sql_verify_checksum)))
{
DBUG_PRINT("info",("could not read event, cur_log->error=%d",
diff --git a/sql/slave.cc b/sql/slave.cc
index a57312998f1..e54e613ae16 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -7308,7 +7308,7 @@ static Log_event* next_event(rpl_group_info *rgi, ulonglong *event_size)
MYSQL_BIN_LOG::open() will write the buffered description event.
*/
old_pos= rli->event_relay_log_pos;
- if ((ev= Log_event::read_log_event(cur_log,0,
+ if ((ev= Log_event::read_log_event(cur_log,
rli->relay_log.description_event_for_exec,
opt_slave_sql_verify_checksum)))
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 08e9dcf3fe6..d85d984606d 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -875,6 +875,73 @@ get_binlog_list(MEM_ROOT *memroot)
DBUG_RETURN(current_list);
}
+/*
+ Find the Gtid_list_log_event at the start of a binlog.
+
+ NULL for ok, non-NULL error message for error.
+
+ If ok, then the event is returned in *out_gtid_list. This can be NULL if we
+ get back to binlogs written by old server version without GTID support. If
+ so, it means we have reached the point to start from, as no GTID events can
+ exist in earlier binlogs.
+*/
+
+static const char *
+get_gtid_list_event(IO_CACHE *cache, Gtid_list_log_event **out_gtid_list)
+{
+ Format_description_log_event init_fdle(BINLOG_VERSION);
+ Format_description_log_event *fdle;
+ Log_event *ev;
+ const char *errormsg = NULL;
+
+ *out_gtid_list= NULL;
+
+ if (!(ev= Log_event::read_log_event(cache, &init_fdle,
+ opt_master_verify_checksum)) ||
+ ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
+ {
+ if (ev)
+ delete ev;
+ return "Could not read format description log event while looking for "
+ "GTID position in binlog";
+ }
+
+ fdle= static_cast<Format_description_log_event *>(ev);
+
+ for (;;)
+ {
+ Log_event_type typ;
+
+ ev= Log_event::read_log_event(cache, fdle, opt_master_verify_checksum);
+ if (!ev)
+ {
+ errormsg= "Could not read GTID list event while looking for GTID "
+ "position in binlog";
+ break;
+ }
+ typ= ev->get_type_code();
+ if (typ == GTID_LIST_EVENT)
+ break; /* Done, found it */
+ if (typ == START_ENCRYPTION_EVENT)
+ {
+ if (fdle->start_decryption((Start_encryption_log_event*) ev))
+ errormsg= "Could not set up decryption for binlog.";
+ }
+ delete ev;
+ if (typ == ROTATE_EVENT || typ == STOP_EVENT ||
+ typ == FORMAT_DESCRIPTION_EVENT || typ == START_ENCRYPTION_EVENT)
+ continue; /* Continue looking */
+
+ /* We did not find any Gtid_list_log_event, must be old binlog. */
+ ev= NULL;
+ break;
+ }
+
+ delete fdle;
+ *out_gtid_list= static_cast<Gtid_list_log_event *>(ev);
+ return errormsg;
+}
+
/*
Check if every GTID requested by the slave is contained in this (or a later)
@@ -3930,7 +3997,7 @@ bool mysql_show_binlog_events(THD* thd)
my_off_t scan_pos = BIN_LOG_HEADER_SIZE;
while (scan_pos < pos)
{
- ev= Log_event::read_log_event(&log, (mysql_mutex_t*)0, description_event,
+ ev= Log_event::read_log_event(&log, description_event,
opt_master_verify_checksum);
scan_pos = my_b_tell(&log);
if (ev == NULL || !ev->is_valid())
@@ -3964,7 +4031,7 @@ bool mysql_show_binlog_events(THD* thd)
my_b_seek(&log, pos);
for (event_count = 0;
- (ev = Log_event::read_log_event(&log, (mysql_mutex_t*) 0,
+ (ev = Log_event::read_log_event(&log,
description_event,
opt_master_verify_checksum)); )
{