Commit bbe64166 authored by Sachin's avatar Sachin

States reduced

parent bb91facb
...@@ -10,12 +10,12 @@ insert into t1 values(1,1, NULL); ...@@ -10,12 +10,12 @@ insert into t1 values(1,1, NULL);
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
alter table t1 change a a int unique ; alter table t1 change a a int unique ;
--sync_slave_with_master --sync_slave_with_master
source include/show_binlog_events.inc; #source include/show_binlog_events.inc;
show create table t1; show create table t1;
--connection master --connection master
drop table t1; drop table t1;
--sync_slave_with_master --sync_slave_with_master
--source include/reset_master_slave_binlog.inc #--source include/reset_master_slave_binlog.inc
--echo # Innodb --echo # Innodb
--connection master --connection master
...@@ -29,12 +29,12 @@ insert into t1 values(1,1, NULL); ...@@ -29,12 +29,12 @@ insert into t1 values(1,1, NULL);
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
alter table t1 change a a int unique ; alter table t1 change a a int unique ;
--sync_slave_with_master --sync_slave_with_master
source include/show_binlog_events.inc; #source include/show_binlog_events.inc;
show create table t1; show create table t1;
--connection master --connection master
drop table t1; drop table t1;
--sync_slave_with_master --sync_slave_with_master
--source include/reset_master_slave_binlog.inc #--source include/reset_master_slave_binlog.inc
--echo # Aria --echo # Aria
...@@ -49,12 +49,12 @@ insert into t1 values(1,1, NULL); ...@@ -49,12 +49,12 @@ insert into t1 values(1,1, NULL);
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
alter table t1 change a a int unique ; alter table t1 change a a int unique ;
--sync_slave_with_master --sync_slave_with_master
source include/show_binlog_events.inc; #source include/show_binlog_events.inc;
show create table t1; show create table t1;
--connection master --connection master
drop table t1; drop table t1;
--sync_slave_with_master --sync_slave_with_master
--source include/reset_master_slave_binlog.inc #--source include/reset_master_slave_binlog.inc
--connection master --connection master
--echo #concurrent alter Myisam --echo #concurrent alter Myisam
...@@ -62,8 +62,8 @@ drop table t1; ...@@ -62,8 +62,8 @@ drop table t1;
--let $alter_algorithm=copy --let $alter_algorithm=copy
--source include/start_alter_concurrent.test --source include/start_alter_concurrent.test
--sync_slave_with_master --sync_slave_with_master
source include/show_binlog_events.inc; #source include/show_binlog_events.inc;
--source include/reset_master_slave_binlog.inc #--source include/reset_master_slave_binlog.inc
--connection master --connection master
--echo #concurrent alter Aria --echo #concurrent alter Aria
...@@ -71,8 +71,8 @@ source include/show_binlog_events.inc; ...@@ -71,8 +71,8 @@ source include/show_binlog_events.inc;
--let $alter_algorithm=copy --let $alter_algorithm=copy
--source include/start_alter_concurrent.test --source include/start_alter_concurrent.test
--sync_slave_with_master --sync_slave_with_master
source include/show_binlog_events.inc; #source include/show_binlog_events.inc;
--source include/reset_master_slave_binlog.inc #--source include/reset_master_slave_binlog.inc
--connection master --connection master
--echo #concurrent alter Innodb copy --echo #concurrent alter Innodb copy
...@@ -80,8 +80,8 @@ source include/show_binlog_events.inc; ...@@ -80,8 +80,8 @@ source include/show_binlog_events.inc;
--let $alter_algorithm=copy --let $alter_algorithm=copy
--source include/start_alter_concurrent.test --source include/start_alter_concurrent.test
--sync_slave_with_master --sync_slave_with_master
source include/show_binlog_events.inc; #source include/show_binlog_events.inc;
--source include/reset_master_slave_binlog.inc #--source include/reset_master_slave_binlog.inc
--connection master --connection master
--echo #concurrent alter Innodb Inplace --echo #concurrent alter Innodb Inplace
...@@ -89,5 +89,5 @@ source include/show_binlog_events.inc; ...@@ -89,5 +89,5 @@ source include/show_binlog_events.inc;
--let $alter_algorithm=inplace --let $alter_algorithm=inplace
--source include/start_alter_concurrent.test --source include/start_alter_concurrent.test
--sync_slave_with_master --sync_slave_with_master
source include/show_binlog_events.inc; #source include/show_binlog_events.inc;
--source include/reset_master_slave_binlog.inc #--source include/reset_master_slave_binlog.inc
include/master-slave.inc
[connection master]
connection slave;
SET @old_debug_slave= @@global.debug;
set global debug_dbug="+d,start_alter_delay_slave";
stop slave;
SET GLOBAL slave_parallel_threads=10;
set global slave_parallel_mode=optimistic;
start slave;
connection master;
SET @old_debug_master= @@global.debug;
set global debug_dbug="+d,start_alter_delay_master";
set global binlog_split_alter=true;
create table t1( a int primary key, b int) engine=myisam;
create table t2( a int primary key, b int) engine=myisam;
connect con1,localhost,root,,;
connect con2,localhost,root,,;
connection con1;
alter table t1 add column c int;;
connection con2;
alter table t2 add column c int;;
connection slave;
select master_gtid_wait('0-1-4');
master_gtid_wait('0-1-4')
0
select @@gtid_binlog_state;
@@gtid_binlog_state
0-1-4
select @@gtid_slave_pos;
@@gtid_slave_pos
0-1-4
include/stop_slave.inc
connection con1;
connection con2;
create table t3( a int primary key, b int) engine=innodb;
connection slave;
include/start_slave.inc
connection master;
connection slave;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
connection master;
SET GLOBAL debug_dbug= @old_debug_master;
drop table t1,t2,t3;
set global binlog_split_alter= false;
connection slave;
SET GLOBAL debug_dbug= @old_debug_slave;
stop slave;
SET GLOBAL slave_parallel_threads=0;
set global slave_parallel_mode=conservative;
start slave;
include/rpl_end.inc
--source include/have_binlog_format_row.inc --source include/have_log_bin.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/master-slave.inc --source include/master-slave.inc
--source include/have_debug.inc --source include/have_debug.inc
......
--source include/have_binlog_format_row.inc --source include/have_log_bin.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/master-slave.inc --source include/master-slave.inc
--source include/have_debug.inc --source include/have_debug.inc
...@@ -33,8 +33,6 @@ connect (con2,localhost,root,,); ...@@ -33,8 +33,6 @@ connect (con2,localhost,root,,);
select master_gtid_wait('0-1-4'); select master_gtid_wait('0-1-4');
select @@gtid_binlog_state; select @@gtid_binlog_state;
select @@gtid_slave_pos; select @@gtid_slave_pos;
#--let $rpl_server_number= 2
#--source include/rpl_stop_server.inc
--source include/stop_slave.inc --source include/stop_slave.inc
--connection con1 --connection con1
...@@ -48,7 +46,6 @@ create table t3( a int primary key, b int) engine=innodb; ...@@ -48,7 +46,6 @@ create table t3( a int primary key, b int) engine=innodb;
--connection master --connection master
--sync_slave_with_master --sync_slave_with_master
show create table t1; show create table t1;
show binlog events;
--connection master --connection master
......
...@@ -151,9 +151,7 @@ enum start_alter_state ...@@ -151,9 +151,7 @@ enum start_alter_state
REGISTERED= 0, // Start Alter exist, Default state REGISTERED= 0, // Start Alter exist, Default state
COMMIT_ALTER, // COMMIT the alter COMMIT_ALTER, // COMMIT the alter
ROLLBACK_ALTER, // Rollback the alter ROLLBACK_ALTER, // Rollback the alter
COMMITTED, // COMMIT/ROLLBACK Alter written in binlog COMMITTED // COMMIT/ROLLBACK Alter written in binlog
SHUTDOWN_RECIEVED, //Got shutdown in between
SHUTDOWN_COMPLETED //Shutdown formalities done on spawned thd side
}; };
struct start_alter_info struct start_alter_info
{ {
......
...@@ -5763,14 +5763,18 @@ pthread_handler_t handle_slave_sql(void *arg) ...@@ -5763,14 +5763,18 @@ pthread_handler_t handle_slave_sql(void *arg)
List_iterator<start_alter_info> info_iterator(mi->start_alter_list); List_iterator<start_alter_info> info_iterator(mi->start_alter_list);
while ((info= info_iterator++)) while ((info= info_iterator++))
{ {
info->state= start_alter_state::SHUTDOWN_RECIEVED; mysql_mutex_lock(&mi->start_alter_lock);
info->state= start_alter_state::ROLLBACK_ALTER;
mysql_cond_broadcast(&info->start_alter_cond); mysql_cond_broadcast(&info->start_alter_cond);
mysql_mutex_unlock(&mi->start_alter_lock);
mysql_mutex_lock(&mi->start_alter_lock); mysql_mutex_lock(&mi->start_alter_lock);
while(info->state == start_alter_state::SHUTDOWN_RECIEVED) while(info->state == start_alter_state::ROLLBACK_ALTER)
mysql_cond_wait(&info->start_alter_cond, &mi->start_alter_lock); mysql_cond_wait(&info->start_alter_cond, &mi->start_alter_lock);
DBUG_ASSERT(info->state == start_alter_state::SHUTDOWN_COMPLETED);
info_iterator.remove();
mysql_mutex_unlock(&mi->start_alter_lock); mysql_mutex_unlock(&mi->start_alter_lock);
DBUG_ASSERT(info->state == start_alter_state::COMMITTED);
info_iterator.remove();
mysql_cond_destroy(&info->start_alter_cond);
my_free(info);
} }
/* When master_pos_wait() wakes up it will check this and terminate */ /* When master_pos_wait() wakes up it will check this and terminate */
rli->slave_running= MYSQL_SLAVE_NOT_RUN; rli->slave_running= MYSQL_SLAVE_NOT_RUN;
......
...@@ -84,7 +84,6 @@ static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *i ...@@ -84,7 +84,6 @@ static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *i
static void wait_for_master(THD *thd, start_alter_info *info); static void wait_for_master(THD *thd, start_alter_info *info);
static int master_result(THD *thd, Master_info *mi, start_alter_info *info, static int master_result(THD *thd, Master_info *mi, start_alter_info *info,
int alter_result); int alter_result);
static void mark_shutdown(start_alter_info *info, Master_info *mi);
/** /**
@brief Helper function for explain_filename @brief Helper function for explain_filename
...@@ -9415,20 +9414,10 @@ static int master_result(THD *thd, Master_info *mi, start_alter_info *info, ...@@ -9415,20 +9414,10 @@ static int master_result(THD *thd, Master_info *mi, start_alter_info *info,
thd->is_slave_error= 1; thd->is_slave_error= 1;
return MASTER_RESULT_COMMIT_ERROR; return MASTER_RESULT_COMMIT_ERROR;
} }
else if (info->state == start_alter_state::SHUTDOWN_RECIEVED)
return MASTER_RESULT_SHUTDOWN;
DBUG_ASSERT(info->state == start_alter_state::COMMIT_ALTER && !alter_result); DBUG_ASSERT(info->state == start_alter_state::COMMIT_ALTER && !alter_result);
return 0; return 0;
} }
static void mark_shutdown(start_alter_info *info, Master_info *mi)
{
mysql_mutex_lock(&mi->start_alter_lock);
info->state= start_alter_state::SHUTDOWN_COMPLETED;
mysql_mutex_unlock(&mi->start_alter_lock);
mysql_cond_broadcast(&info->start_alter_cond);
}
static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *info) static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *info)
{ {
//No need to write start alter , It must be already written //No need to write start alter , It must be already written
...@@ -9445,7 +9434,7 @@ static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *i ...@@ -9445,7 +9434,7 @@ static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *i
mysql_mutex_unlock(&mi->start_alter_list_lock); mysql_mutex_unlock(&mi->start_alter_list_lock);
mysql_cond_broadcast(&mi->start_alter_list_cond); mysql_cond_broadcast(&mi->start_alter_list_cond);
DBUG_EXECUTE_IF("start_alter_delay_slave", { DBUG_EXECUTE_IF("start_alter_delay_slave", {
my_sleep(10000000); my_sleep(5000000);
}); });
if (thd->slave_shutdown) if (thd->slave_shutdown)
return true; return true;
...@@ -9460,7 +9449,7 @@ static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *i ...@@ -9460,7 +9449,7 @@ static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *i
return true; return true;
*partial_alter= true; *partial_alter= true;
DBUG_EXECUTE_IF("start_alter_delay_master", { DBUG_EXECUTE_IF("start_alter_delay_master", {
my_sleep(10000000); my_sleep(5000000);
}); });
return false; return false;
} }
...@@ -10402,8 +10391,7 @@ do_continue:; ...@@ -10402,8 +10391,7 @@ do_continue:;
{ {
DBUG_ASSERT(thd->slave_thread); DBUG_ASSERT(thd->slave_thread);
wait_for_master(thd, info); wait_for_master(thd, info);
if (info->state == start_alter_state::ROLLBACK_ALTER || if (info->state == start_alter_state::ROLLBACK_ALTER)
info->state == start_alter_state::SHUTDOWN_RECIEVED)
goto err_new_table_cleanup; goto err_new_table_cleanup;
} }
/* Close lock if this is a transactional table */ /* Close lock if this is a transactional table */
...@@ -10470,8 +10458,7 @@ do_continue:; ...@@ -10470,8 +10458,7 @@ do_continue:;
{ {
DBUG_ASSERT(thd->slave_thread); DBUG_ASSERT(thd->slave_thread);
wait_for_master(thd, info); wait_for_master(thd, info);
if (info->state == start_alter_state::ROLLBACK_ALTER || if (info->state == start_alter_state::ROLLBACK_ALTER)
info->state == start_alter_state::SHUTDOWN_RECIEVED)
goto err_new_table_cleanup; goto err_new_table_cleanup;
} }
engine_changed= ((new_table->file->ht != table->file->ht) && engine_changed= ((new_table->file->ht != table->file->ht) &&
...@@ -10706,11 +10693,8 @@ do_continue:; ...@@ -10706,11 +10693,8 @@ do_continue:;
alter_ctx.get_tmp_path()); alter_ctx.get_tmp_path());
//STODO //STODO
if (thd->start_alter_id && !thd->direct_commit_alter) if (thd->start_alter_id && !thd->direct_commit_alter)
{ master_result(thd, mi, info, 1);
if (master_result(thd, mi, info, 1) == MASTER_RESULT_SHUTDOWN) else if (opt_binlog_split_alter)
mark_shutdown(info, mi);
}
else
{ {
thd->gtid_flags3|= Gtid_log_event::FL_ROLLBACK_ALTER_E1; thd->gtid_flags3|= Gtid_log_event::FL_ROLLBACK_ALTER_E1;
sprintf(send_query, "/*!100001 %s */", thd->query()); sprintf(send_query, "/*!100001 %s */", thd->query());
......
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