Skip to content

Commit 0c906be

Browse files
author
Luis Soares
committed
BUG#50474: rpl_slave_load_remove_tmpfile failed on windows debug
enabled binary The test case injects an error in the server by deleting the temporary file that it uses during the load data statement execution. The error consisted of closing, deleting and setting the file descriptor to -1 right before calling mysql_file_write. Although, this error injection seems to work OK in Unix like environments, in Windows, this would cause the server to hit an assertion in 'my_get_open_flags': DBUG_ASSERT(fd >= MY_FILE_MIN && fd < (int)my_file_limit) We fix this by changing the error injection to just call the macro my_delete_allow_opened, instead of the close + delete + set fd=-1. The macro deletes the file and is platform independent. Additionally, this required some changes to how the assertion is handled in the test case to make it cope with this change.
1 parent 27828ba commit 0c906be

File tree

3 files changed

+16
-50
lines changed

3 files changed

+16
-50
lines changed

mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,7 @@ insert into t1(b) values (1);
1010
insert into t1(b) values (2);
1111
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
1212
commit;
13-
show slave status;
14-
Slave_IO_State #
15-
Master_Host 127.0.0.1
16-
Master_User root
17-
Master_Port MASTER_MYPORT
18-
Connect_Retry 1
19-
Master_Log_File master-bin.000001
20-
Read_Master_Log_Pos #
21-
Relay_Log_File #
22-
Relay_Log_Pos #
23-
Relay_Master_Log_File master-bin.000001
24-
Slave_IO_Running Yes
25-
Slave_SQL_Running No
26-
Replicate_Do_DB
27-
Replicate_Ignore_DB
28-
Replicate_Do_Table
29-
Replicate_Ignore_Table
30-
Replicate_Wild_Do_Table
31-
Replicate_Wild_Ignore_Table
32-
Last_Errno 9
33-
Last_Error Error in Begin_load_query event: write to '../../tmp/SQL_LOAD.data' failed
34-
Skip_Counter 0
35-
Exec_Master_Log_Pos #
36-
Relay_Log_Space #
37-
Until_Condition None
38-
Until_Log_File
39-
Until_Log_Pos 0
40-
Master_SSL_Allowed No
41-
Master_SSL_CA_File
42-
Master_SSL_CA_Path
43-
Master_SSL_Cert
44-
Master_SSL_Cipher
45-
Master_SSL_Key
46-
Seconds_Behind_Master #
47-
Master_SSL_Verify_Server_Cert No
48-
Last_IO_Errno #
49-
Last_IO_Error #
50-
Last_SQL_Errno 9
51-
Last_SQL_Error Error in Begin_load_query event: write to '../../tmp/SQL_LOAD.data' failed
52-
Replicate_Ignore_Server_Ids
53-
Master_Server_Id 1
5413
drop table t1;
5514
drop table t1;
56-
call mtr.add_suppression("Slave: Error writing file 'UNKNOWN' .Errcode: 9. Error_code: 3");
15+
call mtr.add_suppression("Slave: Can't get stat of .*");
16+
call mtr.add_suppression("Slave: File.* not found.*");

mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,17 @@ commit;
3333
connection slave;
3434
source include/wait_for_slave_sql_to_stop.inc;
3535

36-
--replace_result $MASTER_MYPORT MASTER_MYPORT
37-
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
38-
--replace_regex /SQL_LOAD-[0-9]-[0-9]-[0-9]*/SQL_LOAD/
39-
query_vertical show slave status;
36+
--let $error= query_get_value(SHOW SLAVE STATUS, Last_Errno, 1)
37+
# windows and linux different error numbers here:
38+
# Windows:
39+
# - Last_Errno 29 (File not found)
40+
# Unix like OS:
41+
# - Last_Errno 13 (Can't stat file)
42+
--let $assertion= `SELECT $error=29 OR $error=13`
43+
if (!$assertion)
44+
{
45+
--echo UNEXPECTED ERROR NUMBER: $error
46+
}
4047

4148
##########################################################################
4249
# Clean up
@@ -49,4 +56,5 @@ connection slave;
4956

5057
drop table t1;
5158

52-
call mtr.add_suppression("Slave: Error writing file 'UNKNOWN' .Errcode: 9. Error_code: 3");
59+
call mtr.add_suppression("Slave: Can't get stat of .*");
60+
call mtr.add_suppression("Slave: File.* not found.*");

sql/log_event.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6355,9 +6355,7 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
63556355

63566356
DBUG_EXECUTE_IF("remove_slave_load_file_before_write",
63576357
{
6358-
mysql_file_close(fd, MYF(0));
6359-
fd= -1;
6360-
mysql_file_delete(0, fname, MYF(0));
6358+
my_delete_allow_opened(fname, MYF(0));
63616359
});
63626360

63636361
if (mysql_file_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP)))

0 commit comments

Comments
 (0)