Skip to content

Commit 052dbd7

Browse files
author
Joao Gramacho
committed
BUG#26878022 MYSQLBINLOG: ASSERTION `(OLD_MH->M_KEY == KEY) ||
(OLD_MH->M_KEY == 0)' FAILED Post push fix to ASAN issues.
1 parent f60bc04 commit 052dbd7

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

client/mysqlbinlog.cc

+11-18
Original file line numberDiff line numberDiff line change
@@ -1460,17 +1460,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
14601460

14611461
if (head->error == -1)
14621462
goto err;
1463-
if (opt_remote_proto == BINLOG_LOCAL)
1464-
{
1465-
ev->free_temp_buf(); // free memory allocated in dump_local_log_entries
1466-
}
1467-
else
1468-
{
1469-
/*
1470-
disassociate but not free dump_remote_log_entries time memory
1471-
*/
1472-
ev->temp_buf= 0;
1473-
}
1463+
ev->free_temp_buf();
14741464
/*
14751465
We don't want this event to be deleted now, so let's hide it (I
14761466
(Guilhem) should later see if this triggers a non-serious Valgrind
@@ -1718,14 +1708,9 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
17181708
retval= ERROR_STOP;
17191709
end:
17201710
rec_count++;
1721-
/*
1722-
Destroy the log_event object. If reading from a remote host,
1723-
set the temp_buf to NULL so that memory isn't freed twice.
1724-
*/
1711+
/* Destroy the log_event object. */
17251712
if (ev)
17261713
{
1727-
if (opt_remote_proto != BINLOG_LOCAL)
1728-
ev->temp_buf= 0;
17291714
if (destroy_evt) /* destroy it later if not set (ignored table map) */
17301715
delete ev;
17311716
}
@@ -2705,6 +2690,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
27052690
if (rewrite_db_filter(&event_buf, &event_len, glob_description_event))
27062691
{
27072692
error("Got a fatal error while applying rewrite db filter.");
2693+
my_free(event_buf);
27082694
DBUG_RETURN(ERROR_STOP);
27092695
}
27102696

@@ -2781,6 +2767,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
27812767
*/
27822768
old_off= start_position_mot;
27832769
len= 1; // fake Rotate, so don't increment old_off
2770+
event_len= 0;
27842771
}
27852772
}
27862773
else if (type == binary_log::FORMAT_DESCRIPTION_EVENT)
@@ -2794,7 +2781,10 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
27942781
*/
27952782
// fake event when not in raw mode, don't increment old_off
27962783
if ((old_off != BIN_LOG_HEADER_SIZE) && (!raw_mode))
2784+
{
27972785
len= 1;
2786+
event_len= 0;
2787+
}
27982788
if (raw_mode)
27992789
{
28002790
if (result_file && (result_file != stdout))
@@ -2839,13 +2829,16 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
28392829
{
28402830
DBUG_EXECUTE_IF("simulate_result_file_write_error",
28412831
DBUG_SET("+d,simulate_fwrite_error"););
2842-
if (my_fwrite(result_file, net->read_pos + 1 , len - 1, MYF(MY_NABP)))
2832+
if (my_fwrite(result_file, (const uchar*)event_buf, event_len,
2833+
MYF(MY_NABP)))
28432834
{
28442835
error("Could not write into log file '%s'", log_file_name);
28452836
retval= ERROR_STOP;
28462837
}
28472838
if (ev)
28482839
reset_temp_buf_and_delete(ev);
2840+
else
2841+
my_free(event_buf);
28492842

28502843
/* Flush result_file after every event */
28512844
fflush(result_file);

mysql-test/suite/binlog/r/binlog_mysqlbinlog_rewrite_db.result

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ DELETE FROM t1 WHERE i=2;
1111
[Syntax error in the use of the new option: The to database name is missing]
1212
[VALID SYNTAX,The from->to database names is correctly mentioned]
1313
[VALID SYNTAX read from remote server ,The from->to database names are correctly mentioned]
14+
[VALID SYNTAX read from remote server in raw mode, the from->to database names are correctly mentioned]
1415
[VALID SYNTAX, but during the application of rewrite_db filter an invalid event is found. Hence mysqlbinlog tool should exit with an appropriate error]
1516
[ERROR: Got fatal error while applying rewrite db filter.]
1617
#Dropping the database db1 and creating the table in the new database new_db1.
@@ -29,6 +30,12 @@ CREATE DATABASE new_db1;
2930
RESET MASTER;
3031
[The event of table db1.t1 has been successfully applied to new_db1.t1]
3132
include/assert.inc [Assert that table new_db1.t1 has one row after applying the sql file.]
33+
DROP DATABASE db1;
34+
DROP DATABASE new_db1;
35+
CREATE DATABASE new_db1;
36+
RESET MASTER;
37+
[The event of table db1.t1 has been successfully applied to new_db1.t1 from raw mode]
38+
include/assert.inc [Assert that table new_db1.t1 has one row after applying the sql file from raw binlog dump.]
3239
CLEANUP
3340
DROP DATABASE db1;
3441
DROP DATABASE new_db1;

mysql-test/suite/binlog/t/binlog_mysqlbinlog_rewrite_db.test

+19
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ DELETE FROM t1 WHERE i=2;
6767
--echo [VALID SYNTAX read from remote server ,The from->to database names are correctly mentioned]
6868
--exec $MYSQL_BINLOG --force-if-open --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --rewrite-db="db1->new_db1" $binlog_file > $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite.sql
6969

70+
# BUG26878022: MYSQLBINLOG: ASSERTION `(OLD_MH->M_KEY == KEY) || (OLD_MH->M_KEY == 0)' FAILED
71+
--echo [VALID SYNTAX read from remote server in raw mode, the from->to database names are correctly mentioned]
72+
--exec $MYSQL_BINLOG --raw --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --rewrite-db="db1->new_db1" $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/
73+
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/tmp/$binlog_file > $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite_raw.sql
74+
7075
--echo [VALID SYNTAX, but during the application of rewrite_db filter an invalid event is found. Hence mysqlbinlog tool should exit with an appropriate error]
7176
--echo [ERROR: Got fatal error while applying rewrite db filter.]
7277
--error 1
@@ -111,11 +116,25 @@ RESET MASTER;
111116
--let $assert_cond= `SELECT COUNT(*)=1 from new_db1.t1`
112117
--source include/assert.inc
113118

119+
DROP DATABASE db1;
120+
DROP DATABASE new_db1;
121+
CREATE DATABASE new_db1;
122+
# With gtid-mode=on we need purge gtid_executed, if not transactions
123+
# replayed through mysqlbinlog will be skipped.
124+
RESET MASTER;
125+
--echo [The event of table db1.t1 has been successfully applied to new_db1.t1 from raw mode]
126+
--exec $MYSQL --database=new_db1 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite_raw.sql
127+
--let $assert_text= Assert that table new_db1.t1 has one row after applying the sql file from raw binlog dump.
128+
--let $assert_cond= `SELECT COUNT(*)=1 from new_db1.t1`
129+
--source include/assert.inc
130+
114131
--echo CLEANUP
115132

116133
--remove_file $MYSQLTEST_VARDIR/tmp/row_event.sql
117134
--remove_file $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql
118135
--remove_file $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite.sql
136+
--remove_file $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite_raw.sql
119137
--remove_file $MYSQLTEST_VARDIR/tmp/tmp.sql
138+
--remove_file $MYSQLTEST_VARDIR/tmp/$binlog_file
120139
DROP DATABASE db1;
121140
DROP DATABASE new_db1;

0 commit comments

Comments
 (0)