Commit fff47f40 authored by unknown's avatar unknown

MDEV-26: Global Transaction ID

 - Fix that binlog_gtid_pos() (and hence slave connect) does not work
   correctly in the very first binlog file (due to not logging empty
   Gtid_list_log_event).

 - Remove one instance of the stupid domain_id-0-is-implicit.

 - Rename the confusing Gtid_Pos_Auto in SHOW SLAVE STATUS to Using_Gtid.

 - Fix memory leak.
parent cb46c333
......@@ -60,7 +60,7 @@ if ($tmp)
--echo Last_SQL_Error
--echo Replicate_Ignore_Server_Ids
--echo Master_Server_Id #
--echo Gtid_Pos_Auto 0
--echo Using_Gtid 0
}
if (!$tmp) {
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
......
......@@ -89,7 +89,7 @@ while ($_rpl_server)
--let $rpl_connection_name= server_$_rpl_server
--source include/rpl_connection.inc
# Clear Gtid_Pos_Auto in SHOW SLAVE STATUS to keep check_testcase happy.
# Clear Using_Gtid in SHOW SLAVE STATUS to keep check_testcase happy.
CHANGE MASTER TO master_log_file='';
--dec $_rpl_server
......
......@@ -3270,12 +3270,9 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
there had been an entry (domain_id, server_id, 0).
*/
if (rpl_global_gtid_binlog_state.count())
{
Gtid_list_log_event gl_ev(&rpl_global_gtid_binlog_state);
if (gl_ev.write(&log_file))
goto err;
}
Gtid_list_log_event gl_ev(&rpl_global_gtid_binlog_state);
if (gl_ev.write(&log_file))
goto err;
/* Output a binlog checkpoint event at the start of the binlog file. */
......
......@@ -7220,9 +7220,9 @@ Gtid_list_log_event::Gtid_list_log_event(const char *buf, uint event_len,
buf+= header_size;
count= uint4korr(buf) & ((1<<28)-1);
buf+= 4;
if (count == 0 ||
event_len - (header_size + post_header_len) < count*element_size ||
(!(list= (rpl_gtid *)my_malloc(count*sizeof(*list), MYF(MY_WME)))))
if (event_len - (header_size + post_header_len) < count*element_size ||
(!(list= (rpl_gtid *)my_malloc(count*sizeof(*list) + (count == 0),
MYF(MY_WME)))))
return;
for (i= 0; i < count; ++i)
......@@ -7314,11 +7314,10 @@ rpl_binlog_state::get_most_recent_gtid_list(rpl_gtid **list, uint32 *size)
Gtid_list_log_event::Gtid_list_log_event(rpl_binlog_state *gtid_set)
: count(gtid_set->count()), list(0)
{
DBUG_ASSERT(count != 0);
/* Failure to allocate memory will be caught by is_valid() returning false. */
if (count != 0 && count < (1<<28) &&
(list = (rpl_gtid *)my_malloc(count * sizeof(*list), MYF(MY_WME))))
if (count < (1<<28) &&
(list = (rpl_gtid *)my_malloc(count * sizeof(*list) + (count == 0),
MYF(MY_WME))))
gtid_set->get_gtid_list(list, count);
}
......@@ -7356,17 +7355,13 @@ Gtid_list_log_event::pack_info(THD *thd, Protocol *protocol)
uint32 i;
buf.length(0);
buf.append(STRING_WITH_LEN("["));
for (i= 0; i < count; ++i)
{
if (i)
buf.append(STRING_WITH_LEN(", "));
else
buf.append(STRING_WITH_LEN("["));
if (list[i].domain_id)
{
buf.append_ulonglong((ulonglong)list[i].domain_id);
buf.append(STRING_WITH_LEN("-"));
}
buf.append_ulonglong((ulonglong)list[i].domain_id);
buf.append(STRING_WITH_LEN("-"));
buf.append_ulonglong((ulonglong)list[i].server_id);
buf.append(STRING_WITH_LEN("-"));
buf.append_ulonglong(list[i].seq_no);
......@@ -7392,8 +7387,7 @@ Gtid_list_log_event::print(FILE *file, PRINT_EVENT_INFO *print_event_info)
print_header(&cache, print_event_info, FALSE);
for (i= 0; i < count; ++i)
{
if (list[i].domain_id)
my_b_printf(&cache, "%u-", list[i].domain_id);
my_b_printf(&cache, "%u-", list[i].domain_id);
longlong10_to_str(list[i].seq_no, buf, 10);
my_b_printf(&cache, "%u-%s", list[i].server_id, buf);
if (i < count-1)
......@@ -7428,7 +7422,8 @@ Gtid_list_log_event::peek(const char *event_start, uint32 event_len,
if (event_len < LOG_EVENT_HEADER_LEN + GTID_LIST_HEADER_LEN +
16 * count)
return true;
if (!(gtid_list= (rpl_gtid *)my_malloc(sizeof(rpl_gtid)*count, MYF(MY_WME))))
if (!(gtid_list= (rpl_gtid *)my_malloc(sizeof(rpl_gtid)*count + (count == 0),
MYF(MY_WME))))
return true;
*out_gtid_list= gtid_list;
*out_list_len= count;
......
......@@ -2256,7 +2256,7 @@ static bool send_show_master_info_header(THD *thd, bool full,
FN_REFLEN));
field_list.push_back(new Item_return_int("Master_Server_Id", sizeof(ulong),
MYSQL_TYPE_LONG));
field_list.push_back(new Item_return_int("Gtid_Pos_Auto", sizeof(ulong),
field_list.push_back(new Item_return_int("Using_Gtid", sizeof(ulong),
MYSQL_TYPE_LONG));
if (full)
{
......
......@@ -735,7 +735,7 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name)
{
MEM_ROOT memroot;
binlog_file_entry *list;
Gtid_list_log_event *glev;
Gtid_list_log_event *glev= NULL;
const char *errormsg= NULL;
IO_CACHE cache;
File file = (File)-1;
......@@ -780,6 +780,8 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name)
strmake(out_name, buf, FN_REFLEN);
goto end;
}
delete glev;
glev= NULL;
list= list->next;
}
......@@ -789,6 +791,8 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name)
"have been purged.";
end:
if (glev)
delete glev;
if (file != (File)-1)
{
end_io_cache(&cache);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment