Commit 3f52ef0e authored by tsmith@maint1.mysql.com's avatar tsmith@maint1.mysql.com

Merge maint1.mysql.com:/data/localhome/tsmith/bk/51

into  maint1.mysql.com:/data/localhome/tsmith/bk/maint/51
parents 674675a7 5b22bc3b
# include/wait_for_slave_param.inc
#
# SUMMARY
#
# Waits until SHOW SLAVE STATUS has returned a spicified value.
#
# USAGE
#
# let $slave_param= Slave_SQL_Running;
# let $slave_param_value= No;
# --source include/slave_wait_param.inc
let $slave_wait_param_counter= 300;
let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
while (`select "$slave_value" != "$slave_param_value"`)
{
dec $slave_wait_param_counter;
if (!$slave_wait_param_counter)
{
--echo ERROR: failed while waiting for slave parameter $slave_param: $slave_param_value
query_vertical show slave status;
exit;
}
sleep 0.1;
let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
}
...@@ -55,3 +55,19 @@ flush tables with read lock; ...@@ -55,3 +55,19 @@ flush tables with read lock;
insert into t2 values(1); insert into t2 values(1);
unlock tables; unlock tables;
drop table t1, t2; drop table t1, t2;
End of 5.0 tests
set @old_general_log= @@general_log;
set @old_read_only= @@read_only;
set global general_log= on;
flush tables with read lock;
flush logs;
unlock tables;
set global read_only=1;
flush logs;
unlock tables;
flush tables with read lock;
flush logs;
unlock tables;
set global general_log= @old_general_log;
set global read_only= @old_read_only;
End of 5.1 tests
...@@ -7,27 +7,80 @@ start slave; ...@@ -7,27 +7,80 @@ start slave;
show master status; show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 106 <Binlog_Ignore_DB> master-bin.000001 106 <Binlog_Ignore_DB>
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 106 # # master-bin.000001 Yes Yes 0 0 106 # None 0 No # No
stop slave;
change master to master_log_pos=75;
start slave;
stop slave; stop slave;
change master to master_log_pos=75; change master to master_log_pos=75;
show slave status; show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Slave_IO_State #
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 75 # # master-bin.000001 No No 0 0 75 # None 0 No # No Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos 75
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running No
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos 75
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
start slave; start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 75 # # master-bin.000001 No Yes 0 0 75 # None 0 No # No
stop slave; stop slave;
change master to master_log_pos=178;
start slave;
show slave status; show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Slave_IO_State #
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 178 # # master-bin.000001 # Yes 0 0 178 # None 0 No # No Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos 75
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running No
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos 75
Relay_Log_Space #
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
show master status; show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 106 <Binlog_Ignore_DB> master-bin.000001 106 <Binlog_Ignore_DB>
...@@ -35,7 +88,6 @@ create table if not exists t1 (n int); ...@@ -35,7 +88,6 @@ create table if not exists t1 (n int);
drop table if exists t1; drop table if exists t1;
create table t1 (n int); create table t1 (n int);
insert into t1 values (1),(2),(3); insert into t1 values (1),(2),(3);
stop slave;
change master to master_log_pos=106; change master to master_log_pos=106;
start slave; start slave;
select * from t1 ORDER BY n; select * from t1 ORDER BY n;
...@@ -44,3 +96,4 @@ n ...@@ -44,3 +96,4 @@ n
2 2
3 3
drop table t1; drop table t1;
End of 5.0 tests
...@@ -96,3 +96,4 @@ Seconds_Behind_Master # ...@@ -96,3 +96,4 @@ Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No Master_SSL_Verify_Server_Cert No
drop user replssl@localhost; drop user replssl@localhost;
drop table t1; drop table t1;
End of 5.0 tests
...@@ -133,4 +133,28 @@ disconnect con3; ...@@ -133,4 +133,28 @@ disconnect con3;
connection default; connection default;
drop table t1, t2; drop table t1, t2;
# End of 5.0 tests --echo End of 5.0 tests
#
# Bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock
#
set @old_general_log= @@general_log;
set @old_read_only= @@read_only;
set global general_log= on;
flush tables with read lock;
flush logs;
unlock tables;
set global read_only=1;
flush logs;
unlock tables;
flush tables with read lock;
flush logs;
unlock tables;
set global general_log= @old_general_log;
set global read_only= @old_read_only;
--echo End of 5.1 tests
...@@ -14,31 +14,29 @@ source include/master-slave.inc; ...@@ -14,31 +14,29 @@ source include/master-slave.inc;
--replace_column 3 <Binlog_Ignore_DB> --replace_column 3 <Binlog_Ignore_DB>
show master status; show master status;
sync_slave_with_master; sync_slave_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
stop slave;
change master to master_log_pos=75;
start slave;
sleep 5;
stop slave; stop slave;
--source include/wait_for_slave_to_stop.inc
change master to master_log_pos=75; change master to master_log_pos=75;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 # --replace_column 1 # 8 # 9 # 23 # 33 #
show slave status; query_vertical show slave status;
start slave; start slave;
sleep 5; let $slave_param= Slave_SQL_Running;
--replace_result $MASTER_MYPORT MASTER_PORT let $slave_param_value= Yes;
--replace_column 1 # 8 # 9 # 23 # 33 # --source include/wait_for_slave_param.inc
show slave status; let $slave_param= Slave_IO_Running;
let $slave_param_value= No;
--source include/wait_for_slave_param.inc
stop slave; stop slave;
change master to master_log_pos=178; --source include/wait_for_slave_to_stop.inc
start slave;
sleep 2;
--replace_result $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 11 # 23 # 33 # --replace_column 1 # 8 # 9 # 23 # 33 #
show slave status; query_vertical show slave status;
connection master; connection master;
--replace_column 3 <Binlog_Ignore_DB> --replace_column 3 <Binlog_Ignore_DB>
show master status; show master status;
...@@ -48,7 +46,6 @@ create table t1 (n int); ...@@ -48,7 +46,6 @@ create table t1 (n int);
insert into t1 values (1),(2),(3); insert into t1 values (1),(2),(3);
save_master_pos; save_master_pos;
connection slave; connection slave;
stop slave;
change master to master_log_pos=106; change master to master_log_pos=106;
start slave; start slave;
sync_with_master; sync_with_master;
...@@ -57,4 +54,4 @@ connection master; ...@@ -57,4 +54,4 @@ connection master;
drop table t1; drop table t1;
sync_slave_with_master; sync_slave_with_master;
# End of 4.1 tests --echo End of 5.0 tests
...@@ -58,6 +58,7 @@ connection master; ...@@ -58,6 +58,7 @@ connection master;
# the sync has something to do # the sync has something to do
insert into t1 values (NULL); insert into t1 values (NULL);
sync_slave_with_master; sync_slave_with_master;
--source include/wait_for_slave_to_start.inc
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # --replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
query_vertical show slave status; query_vertical show slave status;
...@@ -67,3 +68,4 @@ drop user replssl@localhost; ...@@ -67,3 +68,4 @@ drop user replssl@localhost;
drop table t1; drop table t1;
sync_slave_with_master; sync_slave_with_master;
--echo End of 5.0 tests
...@@ -92,6 +92,7 @@ static void print_lock_error(int error, const char *); ...@@ -92,6 +92,7 @@ static void print_lock_error(int error, const char *);
count The number of tables to lock. count The number of tables to lock.
flags Options: flags Options:
MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK Ignore a global read lock MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK Ignore a global read lock
MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY Ignore SET GLOBAL READ_ONLY
MYSQL_LOCK_IGNORE_FLUSH Ignore a flush tables. MYSQL_LOCK_IGNORE_FLUSH Ignore a flush tables.
MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN Instead of reopening altered MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN Instead of reopening altered
or dropped tables by itself, or dropped tables by itself,
...@@ -150,11 +151,11 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, ...@@ -150,11 +151,11 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
} }
} }
if ( write_lock_used if (!(flags & MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY) &&
&& opt_readonly write_lock_used &&
&& ! (thd->security_ctx->master_access & SUPER_ACL) opt_readonly &&
&& ! thd->slave_thread !(thd->security_ctx->master_access & SUPER_ACL) &&
) !thd->slave_thread)
{ {
/* /*
Someone has issued SET GLOBAL READ_ONLY=1 and we want a write lock. Someone has issued SET GLOBAL READ_ONLY=1 and we want a write lock.
...@@ -714,9 +715,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, ...@@ -714,9 +715,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
if (!table_ptr[i]-> file-> if (!table_ptr[i]-> file->
check_if_locking_is_allowed(thd->lex->sql_command, thd->lex->type, check_if_locking_is_allowed(thd->lex->sql_command, thd->lex->type,
table_ptr[i], count, i, &system_count, table_ptr[i], count, i, &system_count,
(thd == logger.get_general_log_thd()) || logger.is_privileged_thread(thd)))
(thd == logger.get_slow_log_thd()) ||
(thd == logger.get_privileged_thread())))
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -600,6 +600,12 @@ public: ...@@ -600,6 +600,12 @@ public:
else else
return NULL; return NULL;
} }
bool is_privileged_thread(THD *thd)
{
return thd == get_general_log_thd() ||
thd == get_slow_log_thd() ||
thd == get_privileged_thread();
}
}; };
enum enum_binlog_format { enum enum_binlog_format {
......
...@@ -1765,6 +1765,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, ...@@ -1765,6 +1765,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count,
#define MYSQL_LOCK_IGNORE_FLUSH 0x0002 #define MYSQL_LOCK_IGNORE_FLUSH 0x0002
#define MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004 #define MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004
#define MYSQL_OPEN_TEMPORARY_ONLY 0x0008 #define MYSQL_OPEN_TEMPORARY_ONLY 0x0008
#define MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY 0x0010
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
......
...@@ -4018,6 +4018,12 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen) ...@@ -4018,6 +4018,12 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen)
{ {
DBUG_ASSERT(thd->lock == 0); // You must lock everything at once DBUG_ASSERT(thd->lock == 0); // You must lock everything at once
TABLE **start,**ptr; TABLE **start,**ptr;
uint lock_flag= MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN;
/* Ignore GLOBAL READ LOCK and GLOBAL READ_ONLY if called from a logger */
if (logger.is_privileged_thread(thd))
lock_flag|= (MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK |
MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY);
if (!(ptr=start=(TABLE**) thd->alloc(sizeof(TABLE*)*count))) if (!(ptr=start=(TABLE**) thd->alloc(sizeof(TABLE*)*count)))
DBUG_RETURN(-1); DBUG_RETURN(-1);
...@@ -4046,8 +4052,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen) ...@@ -4046,8 +4052,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen)
} }
if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start), if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start),
MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN, lock_flag, need_reopen)))
need_reopen)))
{ {
if (thd->lex->requires_prelocking()) if (thd->lex->requires_prelocking())
{ {
......
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