Commit a142ea8a authored by Dmitry Lenev's avatar Dmitry Lenev

Merge recent changes from mysql-next-mr-bugfixing

into mysql-next-4284 tree.
parents a7530fb2 82f63dfe
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
set @save_general_log = @@global.general_log;
set @save_log_output = @@global.log_output;
set @save_slave_net_timeout = @@global.slave_net_timeout;
set @@global.general_log = ON;
set @@global.log_output = 'table,file';
include/stop_slave.inc
set @@global.slave_net_timeout = @@global.net_read_timeout * 2;
change master to master_host = '127.0.0.1',master_port = MASTER_PORT,
master_user = 'root', master_heartbeat_period = 0;
include/start_slave.inc
include/stop_slave.inc
select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time desc limit 1 into @ts_last;
select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time asc limit 1 into @ts_prev;
select @result as 'Must be 1';
Must be 1
1
set @@global.general_log = @save_general_log;
set @@global.log_output = @save_log_output;
set @@global.slave_net_timeout = @save_slave_net_timeout;
#
# Testing reconnecting by slave as specified by `slave_net_timeout'
#
# Bug #50296 Slave reconnects earlier than the prescribed slave_net_timeout value
#
--source include/have_csv.inc
--source include/master-slave.inc
# save global env
connection master;
set @save_general_log = @@global.general_log;
set @save_log_output = @@global.log_output;
connection slave;
set @save_slave_net_timeout = @@global.slave_net_timeout;
connection master;
set @@global.general_log = ON;
set @@global.log_output = 'table,file';
connection slave;
--source include/stop_slave.inc
--disable_warnings
set @@global.slave_net_timeout = @@global.net_read_timeout * 2;
--enable_warnings
let $idle_time=`select @@global.slave_net_timeout * 2`;
#
# if heartbeat is disabled then reconnecting to the idle master
# should happen with `slave_net_timeout' period.
# Since it's the real time that is measured, `slave_net_timeout'
# merely guarantees that reconnecting can *not* happen earlier of a value specified.
# That is there can't an exact estimate for how many time it will happen.
#
# The following lines verify that having idle master
# for more than 2 * slave_net_timeout seconds and
# slave.net_read_timeout < slave_net_timeout
# won't cause reconnecting by the slave within at least
# slave_net_timeout interval.
--replace_result $MASTER_MYPORT MASTER_PORT
eval change master to master_host = '127.0.0.1',master_port = $MASTER_MYPORT,
master_user = 'root', master_heartbeat_period = 0;
let $slave_net_timeout = `select @@global.slave_net_timeout`;
--source include/start_slave.inc
--disable_query_log
--disable_result_log
eval select 'master is idle for ', sleep($idle_time);
--enable_result_log
--enable_query_log
--source include/stop_slave.inc
# querying general-log
connection master;
# In particular the last reconnection timestamp must be greater or equal to
# the previous one + slave_net_timeout
select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time desc limit 1 into @ts_last;
select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time asc limit 1 into @ts_prev;
--disable_query_log
eval select time_to_sec(@ts_last) - $slave_net_timeout >= time_to_sec(@ts_prev) into @result;
--enable_query_log
select @result as 'Must be 1';
# cleanup
# restore global env
connection master;
set @@global.general_log = @save_general_log;
set @@global.log_output = @save_log_output;
connection slave;
set @@global.slave_net_timeout = @save_slave_net_timeout;
...@@ -11,3 +11,17 @@ create table test.t1 like performance_schema.EVENTS_WAITS_CURRENT; ...@@ -11,3 +11,17 @@ create table test.t1 like performance_schema.EVENTS_WAITS_CURRENT;
ERROR HY000: Invalid performance_schema usage. ERROR HY000: Invalid performance_schema usage.
create table performance_schema.t1(a int); create table performance_schema.t1(a int);
ERROR 42000: CREATE command denied to user 'root'@'localhost' for table 't1' ERROR 42000: CREATE command denied to user 'root'@'localhost' for table 't1'
drop table if exists test.ghost;
create table test.ghost (a int, b int);
alter table test.ghost add index index_a(a);
alter table test.ghost add index index_b(b);
insert into test.ghost values (1, 3);
insert into test.ghost values (2, 4);
select * from test.ghost;
a b
1 3
2 4
drop table test.ghost;
select * from performance_schema.FILE_INSTANCES
where file_name like "%ghost%";
FILE_NAME EVENT_NAME OPEN_COUNT
...@@ -55,3 +55,24 @@ create table test.t1 like performance_schema.EVENTS_WAITS_CURRENT; ...@@ -55,3 +55,24 @@ create table test.t1 like performance_schema.EVENTS_WAITS_CURRENT;
--error ER_TABLEACCESS_DENIED_ERROR --error ER_TABLEACCESS_DENIED_ERROR
create table performance_schema.t1(a int); create table performance_schema.t1(a int);
#
# Bug#51447 performance schema evil twin files
#
--disable_warnings
drop table if exists test.ghost;
--enable_warnings
create table test.ghost (a int, b int);
alter table test.ghost add index index_a(a);
alter table test.ghost add index index_b(b);
insert into test.ghost values (1, 3);
insert into test.ghost values (2, 4);
select * from test.ghost;
drop table test.ghost;
# Shoud return nothing
select * from performance_schema.FILE_INSTANCES
where file_name like "%ghost%";
...@@ -1965,7 +1965,8 @@ extern ulong slow_launch_threads, slow_launch_time; ...@@ -1965,7 +1965,8 @@ extern ulong slow_launch_threads, slow_launch_time;
extern ulong table_cache_size, table_def_size; extern ulong table_cache_size, table_def_size;
extern MYSQL_PLUGIN_IMPORT ulong max_connections; extern MYSQL_PLUGIN_IMPORT ulong max_connections;
extern ulong max_connect_errors, connect_timeout; extern ulong max_connect_errors, connect_timeout;
extern ulong slave_net_timeout, slave_trans_retries; extern ulong slave_trans_retries;
extern uint slave_net_timeout;
extern ulong what_to_log,flush_time; extern ulong what_to_log,flush_time;
extern ulong query_buff_size; extern ulong query_buff_size;
extern ulong max_prepared_stmt_count, prepared_stmt_count; extern ulong max_prepared_stmt_count, prepared_stmt_count;
......
...@@ -464,7 +464,8 @@ ulong table_cache_size, table_def_size; ...@@ -464,7 +464,8 @@ ulong table_cache_size, table_def_size;
ulong what_to_log; ulong what_to_log;
ulong query_buff_size, slow_launch_time, slave_open_temp_tables; ulong query_buff_size, slow_launch_time, slave_open_temp_tables;
ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong open_files_limit, max_binlog_size, max_relay_log_size;
ulong slave_net_timeout, slave_trans_retries; ulong slave_trans_retries;
uint slave_net_timeout;
uint slave_exec_mode_options; uint slave_exec_mode_options;
ulonglong slave_type_conversions_options; ulonglong slave_type_conversions_options;
ulong thread_cache_size=0, thread_pool_size= 0; ulong thread_cache_size=0, thread_pool_size= 0;
......
...@@ -2795,11 +2795,11 @@ static bool fix_slave_net_timeout(sys_var *self, THD *thd, enum_var_type type) ...@@ -2795,11 +2795,11 @@ static bool fix_slave_net_timeout(sys_var *self, THD *thd, enum_var_type type)
mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
return false; return false;
} }
static Sys_var_ulong Sys_slave_net_timeout( static Sys_var_uint Sys_slave_net_timeout(
"slave_net_timeout", "Number of seconds to wait for more data " "slave_net_timeout", "Number of seconds to wait for more data "
"from a master/slave connection before aborting the read", "from a master/slave connection before aborting the read",
GLOBAL_VAR(slave_net_timeout), CMD_LINE(REQUIRED_ARG), GLOBAL_VAR(slave_net_timeout), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(SLAVE_NET_TIMEOUT), BLOCK_SIZE(1), VALID_RANGE(1, UINT_MAX), DEFAULT(SLAVE_NET_TIMEOUT), BLOCK_SIZE(1),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(fix_slave_net_timeout)); ON_UPDATE(fix_slave_net_timeout));
......
...@@ -746,8 +746,23 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass, ...@@ -746,8 +746,23 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass,
} }
} }
if (len >= sizeof(pfs->m_filename)) /*
len= sizeof(pfs->m_filename) - 1; Normalize the file name to avoid duplicates when using aliases:
- absolute or relative paths
- symbolic links
*/
char buffer[FN_REFLEN];
const char *normalized_filename;
int normalized_length;
/*
Ignore errors, the file may not exist.
my_realpath always provide a best effort result in buffer.
*/
(void) my_realpath(buffer, filename, MYF(0));
normalized_filename= buffer;
normalized_length= strlen(normalized_filename);
PFS_file **entry; PFS_file **entry;
uint retry_count= 0; uint retry_count= 0;
...@@ -755,7 +770,7 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass, ...@@ -755,7 +770,7 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass,
search: search:
entry= reinterpret_cast<PFS_file**> entry= reinterpret_cast<PFS_file**>
(lf_hash_search(&filename_hash, thread->m_filename_hash_pins, (lf_hash_search(&filename_hash, thread->m_filename_hash_pins,
filename, len)); normalized_filename, normalized_length));
if (entry && (entry != MY_ERRPTR)) if (entry && (entry != MY_ERRPTR))
{ {
pfs= *entry; pfs= *entry;
...@@ -783,9 +798,9 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass, ...@@ -783,9 +798,9 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass,
if (pfs->m_lock.free_to_dirty()) if (pfs->m_lock.free_to_dirty())
{ {
pfs->m_class= klass; pfs->m_class= klass;
strncpy(pfs->m_filename, filename, len); strncpy(pfs->m_filename, normalized_filename, normalized_length);
pfs->m_filename[len]= '\0'; pfs->m_filename[normalized_length]= '\0';
pfs->m_filename_length= len; pfs->m_filename_length= normalized_length;
pfs->m_file_stat.m_open_count= 1; pfs->m_file_stat.m_open_count= 1;
pfs->m_wait_stat.m_control_flag= pfs->m_wait_stat.m_control_flag=
&flag_events_waits_summary_by_instance; &flag_events_waits_summary_by_instance;
......
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