3661 Andrei Elkin 2011-12-19 [merge]
merge from the repo.
added:
mysql-test/suite/perfschema/r/start_server_disable_idle.result
mysql-test/suite/perfschema/r/start_server_disable_stages.result
mysql-test/suite/perfschema/r/start_server_disable_statements.result
mysql-test/suite/perfschema/r/start_server_disable_waits.result
mysql-test/suite/perfschema/t/start_server_disable_idle-master.opt
mysql-test/suite/perfschema/t/start_server_disable_idle.test
mysql-test/suite/perfschema/t/start_server_disable_stages-master.opt
mysql-test/suite/perfschema/t/start_server_disable_stages.test
mysql-test/suite/perfschema/t/start_server_disable_statements-master.opt
mysql-test/suite/perfschema/t/start_server_disable_statements.test
mysql-test/suite/perfschema/t/start_server_disable_waits-master.opt
mysql-test/suite/perfschema/t/start_server_disable_waits.test
sql/sql_executor.cc
sql/sql_executor.h
sql/sql_join_buffer.h
sql/sql_optimizer.cc
sql/sql_optimizer.h
sql/sql_planner.cc
sql/sql_planner.h
sql/sql_resolver.cc
sql/sql_resolver.h
sql/sql_tmp_table.cc
sql/sql_tmp_table.h
renamed:
sql/sql_join_cache.cc => sql/sql_join_buffer.cc
modified:
cmake/install_macros.cmake
mysql-test/include/order_by.inc
mysql-test/include/range.inc
mysql-test/include/select.inc
mysql-test/include/subquery_sj.inc
mysql-test/r/func_in_all.result
mysql-test/r/innodb_explain_non_select_all.result
mysql-test/r/innodb_explain_non_select_none.result
mysql-test/r/innodb_mrr_all.result
mysql-test/r/innodb_mrr_cost_all.result
mysql-test/r/myisam_mrr_all.result
mysql-test/r/myisam_mrr_cost_all.result
mysql-test/r/order_by_all.result
mysql-test/r/order_by_icp_mrr.result
mysql-test/r/order_by_none.result
mysql-test/r/partition_hash.result
mysql-test/r/partition_list.result
mysql-test/r/partition_mgm.result
mysql-test/r/ps_ddl.result
mysql-test/r/range_all.result
mysql-test/r/range_icp.result
mysql-test/r/range_icp_mrr.result
mysql-test/r/range_mrr.result
mysql-test/r/range_mrr_cost.result
mysql-test/r/range_none.result
mysql-test/r/select_all.result
mysql-test/r/select_icp_mrr.result
mysql-test/r/select_icp_mrr_bka.result
mysql-test/r/select_icp_mrr_bka_nixbnl.result
mysql-test/r/select_none.result
mysql-test/r/select_none_bka.result
mysql-test/r/select_none_bka_nixbnl.result
mysql-test/r/sp.result
mysql-test/r/subquery_all.result
mysql-test/r/subquery_all_bka.result
mysql-test/r/subquery_all_bka_nixbnl.result
mysql-test/r/subquery_sj_all.result
mysql-test/r/subquery_sj_all_bka.result
mysql-test/r/subquery_sj_all_bka_nixbnl.result
mysql-test/r/subquery_sj_all_bkaunique.result
mysql-test/r/subquery_sj_dupsweed.result
mysql-test/r/subquery_sj_dupsweed_bka.result
mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
mysql-test/r/subquery_sj_dupsweed_bkaunique.result
mysql-test/r/subquery_sj_firstmatch.result
mysql-test/r/subquery_sj_firstmatch_bka.result
mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
mysql-test/r/subquery_sj_firstmatch_bkaunique.result
mysql-test/r/subquery_sj_loosescan.result
mysql-test/r/subquery_sj_loosescan_bka.result
mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
mysql-test/r/subquery_sj_loosescan_bkaunique.result
mysql-test/r/subquery_sj_mat.result
mysql-test/r/subquery_sj_mat_bka.result
mysql-test/r/subquery_sj_mat_bka_nixbnl.result
mysql-test/r/subquery_sj_mat_bkaunique.result
mysql-test/r/subquery_sj_mat_nosj.result
mysql-test/r/subquery_sj_none.result
mysql-test/r/subquery_sj_none_bka.result
mysql-test/r/subquery_sj_none_bka_nixbnl.result
mysql-test/r/subquery_sj_none_bkaunique.result
mysql-test/r/type_temporal_fractional.result
mysql-test/r/update.result
mysql-test/suite/binlog/t/binlog_index.test
mysql-test/suite/rpl/r/rpl_row_img_sanity.result
mysql-test/suite/rpl/t/rpl_binlog_errors.test
mysql-test/suite/rpl/t/rpl_empty_master_host.test
mysql-test/suite/rpl/t/rpl_row_img_sanity.test
mysql-test/suite/rpl/t/rpl_server_id_ignore.test
mysql-test/t/partition_hash.test
mysql-test/t/partition_list.test
mysql-test/t/partition_mgm.test
mysql-test/t/ps_ddl.test
mysql-test/t/sp.test
mysql-test/t/type_temporal_fractional.test
mysql-test/t/update.test
scripts/mysql_system_tables.sql
sql/CMakeLists.txt
sql/field.cc
sql/ha_partition.cc
sql/ha_partition.h
sql/item.cc
sql/item_cmpfunc.cc
sql/item_strfunc.cc
sql/item_subselect.cc
sql/item_sum.cc
sql/item_timefunc.cc
sql/opt_explain.cc
sql/opt_explain.h
sql/opt_range.cc
sql/opt_range.h
sql/partition_element.h
sql/partition_info.cc
sql/partition_info.h
sql/records.cc
sql/records.h
sql/rpl_utility.cc
sql/sp_rcontext.cc
sql/sql_admin.cc
sql/sql_base.cc
sql/sql_class.cc
sql/sql_class.h
sql/sql_cursor.cc
sql/sql_delete.cc
sql/sql_derived.cc
sql/sql_insert.cc
sql/sql_lex.cc
sql/sql_lex.h
sql/sql_partition.cc
sql/sql_partition.h
sql/sql_select.cc
sql/sql_select.h
sql/sql_show.cc
sql/sql_table.cc
sql/sql_test.cc
sql/sql_union.cc
sql/sql_update.cc
sql/sql_view.cc
sql/sql_yacc.yy
sql/table.h
sql/unireg.h
storage/innobase/dict/dict0dict.cc
storage/innobase/dict/dict0mem.cc
storage/innobase/dict/dict0stats.cc
storage/innobase/fts/fts0fts.cc
storage/innobase/include/fts0fts.h
storage/innobase/include/sync0sync.h
storage/innobase/row/row0mysql.cc
storage/perfschema/pfs.cc
sql/sql_join_buffer.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result'
--- a/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result 2011-11-19 08:08:03 +0000
+++ b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result 2011-12-19 14:26:51 +0000
@@ -20,6 +20,7 @@ include/rpl_sync.inc
call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
call mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
call mtr.add_suppression("Slave SQL: Coordinator thread of multi-threaded slave is exiting seeing a failed Worker to apply an event");
+call mtr.add_suppression("Slave worker thread has failed to apply an event");
*** Testing schema A->B->C->D->A ***
=== renamed file 'mysql-test/suite/rpl/r/rpl_mts_check_concurrency.result' => 'mysql-test/suite/rpl/r/rpl_mts_debug.result'
--- a/mysql-test/suite/rpl/r/rpl_mts_check_concurrency.result 2011-11-19 08:08:03 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mts_debug.result 2011-12-16 15:53:16 +0000
@@ -21,4 +21,19 @@ include/stop_slave.inc
SET @@global.slave_parallel_workers= save_slave_parallel_workers;
SET @@global.debug= "";
include/start_slave.inc
+call mtr.add_suppression('Error reading slave worker configuration');
+call mtr.add_suppression('Failed during slave workers initialization');
+call mtr.add_suppression('Failed during slave worker thread create');
+include/stop_slave.inc
+set @save.slave_checkpoint_group= @@global.slave_checkpoint_group;
+set @save.slave_parallel_workers= @@global.slave_parallel_workers;
+set @save.debug= @@global.debug;
+SET @@global.debug= "d,mts_worker_thread_fails";
+set @@global.slave_parallel_workers= 2;
+start slave sql_thread;
+include/wait_for_slave_sql_error.inc [errno=1593]
+set @@global.slave_checkpoint_group= @save.slave_checkpoint_group;
+set @@global.slave_parallel_workers= @save.slave_parallel_workers;
+set @@global.debug= @save.debug;
+include/start_slave.inc
include/rpl_end.inc
=== modified file 'mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test'
--- a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test 2011-11-24 18:26:55 +0000
@@ -33,6 +33,7 @@ CREATE TABLE t2 (a INT NOT NULL AUTO_INC
call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
call mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
call mtr.add_suppression("Slave SQL: Coordinator thread of multi-threaded slave is exiting seeing a failed Worker to apply an event");
+call mtr.add_suppression("Slave worker thread has failed to apply an event");
--echo
#
=== renamed file 'mysql-test/suite/rpl/t/rpl_mts_check_concurrency-slave.opt' => 'mysql-test/suite/rpl/t/rpl_mts_debug-slave.opt'
=== renamed file 'mysql-test/suite/rpl/t/rpl_mts_check_concurrency.test' => 'mysql-test/suite/rpl/t/rpl_mts_debug.test'
--- a/mysql-test/suite/rpl/t/rpl_mts_check_concurrency.test 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/rpl/t/rpl_mts_debug.test 2011-12-16 15:53:16 +0000
@@ -10,6 +10,8 @@
--source include/master-slave.inc
--source include/have_debug.inc
--source include/have_innodb.inc
+# no format specific tests so we run it only in MIXED mode
+--source include/have_binlog_format_mixed.inc
--connection master
CREATE DATABASE db_1;
@@ -46,4 +48,46 @@ DROP DATABASE db_2;
--eval SET @@global.slave_parallel_workers= $save_slave_parallel_workers
--eval SET @@global.debug= "$save_debug"
--source include/start_slave.inc
+
+#
+# Bug#12964649 MTS memory not released
+#
+# Originally reported when opt_slave_checkpoint_group is set to be greater
+# than sizeof(BLOB) * 8 - 1 Workers initialization code fails.
+# VALID_RANGE() for opt_slave_checkpoint_group is fixed in bug12979420.
+#
+# The current bug test simulates a failure to start by a Worker
+# thread, checks the error, and verifies that all memory is released
+# (valgrind proves, the user can watch top report).
+#
+
+connection slave;
+
+call mtr.add_suppression('Error reading slave worker configuration');
+call mtr.add_suppression('Failed during slave workers initialization');
+call mtr.add_suppression('Failed during slave worker thread create');
+
+source include/stop_slave.inc;
+set @save.slave_checkpoint_group= @@global.slave_checkpoint_group;
+set @save.slave_parallel_workers= @@global.slave_parallel_workers;
+
+# The following assignment can work only with debug builds.
+# It sets opt_slave_checkpoint_group to one more to its VALID_RANGE() maximum.
+# set @@global.slave_checkpoint_group= 524287 + 1;
+
+set @save.debug= @@global.debug;
+SET @@global.debug= "d,mts_worker_thread_fails";
+set @@global.slave_parallel_workers= 2;
+
+start slave sql_thread;
+--let $slave_sql_errno= 1593
+source include/wait_for_slave_sql_error.inc;
+
+set @@global.slave_checkpoint_group= @save.slave_checkpoint_group;
+set @@global.slave_parallel_workers= @save.slave_parallel_workers;
+set @@global.debug= @save.debug;
+
+source include/start_slave.inc;
+
+
--source include/rpl_end.inc
=== modified file 'mysql-test/suite/sys_vars/r/slave_checkpoint_group_basic.result'
--- a/mysql-test/suite/sys_vars/r/slave_checkpoint_group_basic.result 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/sys_vars/r/slave_checkpoint_group_basic.result 2011-11-24 18:26:55 +0000
@@ -37,6 +37,9 @@ Warning 1292 Truncated incorrect slave_c
set global slave_checkpoint_group=cast(-1 as unsigned int);
Warnings:
Warning 1292 Truncated incorrect slave_checkpoint_group value: '18446744073709551615'
+select @@global.slave_checkpoint_group as "truncated to the maximum" ;
+truncated to the maximum
+524287
SET @@global.slave_checkpoint_group = @start_global_value;
SELECT @@global.slave_checkpoint_group;
@@global.slave_checkpoint_group
=== modified file 'mysql-test/suite/sys_vars/r/slave_checkpoint_period_basic.result'
--- a/mysql-test/suite/sys_vars/r/slave_checkpoint_period_basic.result 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/sys_vars/r/slave_checkpoint_period_basic.result 2011-11-24 18:26:55 +0000
@@ -38,8 +38,8 @@ select @@global.slave_checkpoint_period;
set global slave_checkpoint_period=cast(-1 as unsigned int);
Warnings:
Warning 1292 Truncated incorrect slave_checkpoint_period value: '18446744073709551615'
-select @@global.slave_checkpoint_period;
-@@global.slave_checkpoint_period
+select @@global.slave_checkpoint_period as "truncated to the maximum";
+truncated to the maximum
4294967295
SET @@global.slave_checkpoint_period = @start_global_value;
SELECT @@global.slave_checkpoint_period;
=== modified file 'mysql-test/suite/sys_vars/r/slave_parallel_workers_basic.result'
--- a/mysql-test/suite/sys_vars/r/slave_parallel_workers_basic.result 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/sys_vars/r/slave_parallel_workers_basic.result 2011-11-24 18:26:55 +0000
@@ -17,7 +17,7 @@ set @@global.slave_parallel_workers= 0;
set @@global.slave_parallel_workers= cast(-1 as unsigned int);
Warnings:
Warning 1292 Truncated incorrect slave_parallel_workers value: '18446744073709551615'
-select @@global.slave_parallel_workers;
-@@global.slave_parallel_workers
+select @@global.slave_parallel_workers as "truncated to the maximum";
+truncated to the maximum
1024
set @@global.slave_parallel_workers= @save.slave_parallel_workers;
=== modified file 'mysql-test/suite/sys_vars/r/slave_pending_jobs_size_max_basic.result'
--- a/mysql-test/suite/sys_vars/r/slave_pending_jobs_size_max_basic.result 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/sys_vars/r/slave_pending_jobs_size_max_basic.result 2011-11-24 18:26:55 +0000
@@ -27,7 +27,7 @@ Warning 1292 Truncated incorrect slave_p
set @@global.slave_pending_jobs_size_max= cast(-1 as unsigned int);
Warnings:
Warning 1292 Truncated incorrect slave_pending_jobs_size_max value: '18446744073709551615'
-select @@global.slave_pending_jobs_size_max;
-@@global.slave_pending_jobs_size_max
+select @@global.slave_pending_jobs_size_max as "truncated to the maximum";
+truncated to the maximum
18446744073709550592
set @@global.slave_pending_jobs_size_max= @save.slave_pending_jobs_size_max;
=== modified file 'mysql-test/suite/sys_vars/t/slave_checkpoint_group_basic.test'
--- a/mysql-test/suite/sys_vars/t/slave_checkpoint_group_basic.test 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/sys_vars/t/slave_checkpoint_group_basic.test 2011-11-24 18:26:55 +0000
@@ -38,5 +38,7 @@ set global slave_checkpoint_group="foo";
set global slave_checkpoint_group=0;
set global slave_checkpoint_group=cast(-1 as unsigned int);
+select @@global.slave_checkpoint_group as "truncated to the maximum" ;
+
SET @@global.slave_checkpoint_group = @start_global_value;
SELECT @@global.slave_checkpoint_group;
=== modified file 'mysql-test/suite/sys_vars/t/slave_checkpoint_period_basic.test'
--- a/mysql-test/suite/sys_vars/t/slave_checkpoint_period_basic.test 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/sys_vars/t/slave_checkpoint_period_basic.test 2011-11-24 18:26:55 +0000
@@ -42,7 +42,7 @@ set global slave_checkpoint_period="foo"
set global slave_checkpoint_period=1;
select @@global.slave_checkpoint_period;
set global slave_checkpoint_period=cast(-1 as unsigned int);
-select @@global.slave_checkpoint_period;
+select @@global.slave_checkpoint_period as "truncated to the maximum";
SET @@global.slave_checkpoint_period = @start_global_value;
SELECT @@global.slave_checkpoint_period;
=== modified file 'mysql-test/suite/sys_vars/t/slave_parallel_workers_basic.test'
--- a/mysql-test/suite/sys_vars/t/slave_parallel_workers_basic.test 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/sys_vars/t/slave_parallel_workers_basic.test 2011-11-24 18:26:55 +0000
@@ -32,7 +32,7 @@ eval set @@global.$var= "foo";
#
eval set @@global.$var= 0;
eval set @@global.$var= cast(-1 as unsigned int);
-eval select @@global.$var;
+eval select @@global.$var as "truncated to the maximum";
# cleanup
=== modified file 'mysql-test/suite/sys_vars/t/slave_pending_jobs_size_max_basic.test'
--- a/mysql-test/suite/sys_vars/t/slave_pending_jobs_size_max_basic.test 2011-08-19 13:04:28 +0000
+++ b/mysql-test/suite/sys_vars/t/slave_pending_jobs_size_max_basic.test 2011-11-24 18:26:55 +0000
@@ -34,7 +34,7 @@ eval set @@global.$var= "foo";
#
eval set @@global.$var= 0;
eval set @@global.$var= cast(-1 as unsigned int);
-eval select @@global.$var;
+eval select @@global.$var as "truncated to the maximum";
# cleanup
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2011-12-13 17:06:27 +0000
+++ b/sql/mysqld.cc 2011-12-16 15:53:16 +0000
@@ -524,7 +524,7 @@ ulong thread_id=1L,current_pid;
ulong slow_launch_threads = 0;
uint sync_binlog_period= 0, sync_relaylog_period= 0,
sync_relayloginfo_period= 0, sync_masterinfo_period= 0,
- mts_checkpoint_period= 0, mts_checkpoint_group= 0;
+ opt_mts_checkpoint_period, opt_mts_checkpoint_group;
ulong expire_logs_days = 0;
const double log_10[] = {
=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h 2011-12-06 17:25:19 +0000
+++ b/sql/mysqld.h 2011-12-16 15:53:16 +0000
@@ -140,7 +140,7 @@ extern ulong expire_logs_days;
extern my_bool relay_log_recovery;
extern uint sync_binlog_period, sync_relaylog_period,
sync_relayloginfo_period, sync_masterinfo_period,
- mts_checkpoint_period, mts_checkpoint_group;
+ opt_mts_checkpoint_period, opt_mts_checkpoint_group;
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
extern ulong tc_log_page_waits;
extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc 2011-11-16 01:19:40 +0000
+++ b/sql/rpl_rli.cc 2011-12-16 15:53:16 +0000
@@ -82,7 +82,7 @@ Relay_log_info::Relay_log_info(bool is_s
rows_query_ev(NULL), last_event_start_time(0),
slave_parallel_workers(0),
recovery_parallel_workers(0), checkpoint_seqno(0),
- checkpoint_group(mts_checkpoint_group), mts_recovery_group_cnt(0),
+ checkpoint_group(opt_mts_checkpoint_group), mts_recovery_group_cnt(0),
mts_recovery_index(0), mts_recovery_group_seen_begin(0),
mts_group_status(MTS_NOT_IN_GROUP), reported_unsafe_warning(false),
sql_delay(0), sql_delay_end(0), m_flags(0), row_stmt_start_timestamp(0),
=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h 2011-11-21 17:46:02 +0000
+++ b/sql/rpl_rli.h 2011-12-16 15:53:16 +0000
@@ -467,7 +467,7 @@ public:
ulong slave_parallel_workers; // the one slave session time number of workers
ulong recovery_parallel_workers; // number of workers while recovering
uint checkpoint_seqno; // counter of groups executed after the most recent CP
- uint checkpoint_group; // number of groups in one checkpoint interval (period).
+ uint checkpoint_group; // cache for ::opt_mts_checkpoint_group
MY_BITMAP recovery_groups; // bitmap used during recovery
ulong mts_recovery_group_cnt; // number of groups to execute at recovery
ulong mts_recovery_index; // running index of recoverable groups
=== modified file 'sql/rpl_rli_pdb.cc'
--- a/sql/rpl_rli_pdb.cc 2011-11-22 10:19:19 +0000
+++ b/sql/rpl_rli_pdb.cc 2011-12-16 15:53:16 +0000
@@ -430,20 +430,23 @@ bool init_hash_workers(ulong slave_paral
{
DBUG_ENTER("init_hash_workers");
-#ifdef HAVE_PSI_INTERFACE
- mysql_mutex_init(key_mutex_slave_worker_hash, &slave_worker_hash_lock,
- MY_MUTEX_INIT_FAST);
- mysql_cond_init(key_cond_slave_worker_hash, &slave_worker_hash_cond, NULL);
-#else
- mysql_mutex_init(NULL, &slave_worker_hash_lock,
- MY_MUTEX_INIT_FAST);
- mysql_cond_init(NULL, &slave_worker_hash_cond, NULL);
-#endif
-
inited_hash_workers=
(my_hash_init(&mapping_db_to_worker, &my_charset_bin,
0, 0, 0, get_key,
(my_hash_free_key) free_entry, 0) == 0);
+ if (inited_hash_workers)
+ {
+#ifdef HAVE_PSI_INTERFACE
+ mysql_mutex_init(key_mutex_slave_worker_hash, &slave_worker_hash_lock,
+ MY_MUTEX_INIT_FAST);
+ mysql_cond_init(key_cond_slave_worker_hash, &slave_worker_hash_cond, NULL);
+#else
+ mysql_mutex_init(NULL, &slave_worker_hash_lock,
+ MY_MUTEX_INIT_FAST);
+ mysql_cond_init(NULL, &slave_worker_hash_cond, NULL);
+#endif
+ }
+
DBUG_RETURN (!inited_hash_workers);
}
@@ -453,9 +456,10 @@ void destroy_hash_workers(Relay_log_info
if (inited_hash_workers)
{
my_hash_free(&mapping_db_to_worker);
+ mysql_mutex_destroy(&slave_worker_hash_lock);
+ mysql_cond_destroy(&slave_worker_hash_cond);
+ inited_hash_workers= false;
}
- mysql_mutex_destroy(&slave_worker_hash_lock);
- mysql_cond_destroy(&slave_worker_hash_cond);
DBUG_VOID_RETURN;
}
@@ -1173,9 +1177,9 @@ bool Slave_committed_queue::count_done(R
DBUG_PRINT("mts", ("Checking if it can simulate a crash:"
" mts_checkpoint_group %u counter %lu parallel slaves %lu\n",
- mts_checkpoint_group, cnt, rli->slave_parallel_workers));
+ opt_mts_checkpoint_group, cnt, rli->slave_parallel_workers));
- return (cnt == (rli->slave_parallel_workers * mts_checkpoint_group));
+ return (cnt == (rli->slave_parallel_workers * opt_mts_checkpoint_group));
}
#endif
@@ -1214,7 +1218,7 @@ ulong Slave_committed_queue::move_queue_
#ifndef DBUG_OFF
if (DBUG_EVALUATE_IF("check_slave_debug_group", 1, 0) &&
- cnt == mts_checkpoint_period)
+ cnt == opt_mts_checkpoint_period)
return cnt;
#endif
@@ -1743,11 +1747,11 @@ int slave_worker_exec_job(Slave_worker *
#ifndef DBUG_OFF
DBUG_PRINT("mts", ("Check_slave_debug_group worker %lu mts_checkpoint_group"
- " %u processed %lu debug %d\n", worker->id, mts_checkpoint_group,
+ " %u processed %lu debug %d\n", worker->id, opt_mts_checkpoint_group,
worker->groups_done,
DBUG_EVALUATE_IF("check_slave_debug_group", 1, 0)));
if (DBUG_EVALUATE_IF("check_slave_debug_group", 1, 0) &&
- mts_checkpoint_group == worker->groups_done)
+ opt_mts_checkpoint_group == worker->groups_done)
{
DBUG_PRINT("mts", ("Putting worker %lu in busy wait.", worker->id));
while (true) my_sleep(6000000);
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc 2011-12-02 20:46:47 +0000
+++ b/sql/rpl_slave.cc 2011-12-16 15:53:16 +0000
@@ -87,7 +87,7 @@ const char *relay_log_basename= 0;
of Relay_log_info::gaq (see @c slave_start_workers()).
It can be set to any value in [1, ULONG_MAX - 1] range.
*/
-const ulong mts_slave_worker_queue_len_max= 32768;
+const ulong mts_slave_worker_queue_len_max= 16384;
/*
MTS load-ballancing parameter.
@@ -340,8 +340,9 @@ int init_slave()
/* If server id is not set, start_slave_thread() will say it */
if (active_mi->host[0] && !opt_skip_slave_start)
{
- /* same as in start_slave() cache the global var value into rli's member */
+ /* same as in start_slave() cache the global var values into rli's members */
active_mi->rli->opt_slave_parallel_workers= opt_mts_slave_parallel_workers;
+ active_mi->rli->checkpoint_group= opt_mts_checkpoint_group;
if (start_slave_threads(1 /* need mutex */,
0 /* no wait for start*/,
active_mi,
@@ -4268,7 +4269,7 @@ bool mts_checkpoint_routine(Relay_log_in
cnt= rli->gaq->move_queue_head(&rli->workers);
#ifndef DBUG_OFF
if (DBUG_EVALUATE_IF("check_slave_debug_group", 1, 0) &&
- cnt != mts_checkpoint_period)
+ cnt != opt_mts_checkpoint_period)
sql_print_error("This an error cnt != mts_checkpoint_period");
#endif
} while (!sql_slave_killed(rli->info_thd, rli) &&
@@ -4381,7 +4382,8 @@ int slave_start_single_worker(Relay_log_
}
set_dynamic(&rli->workers, (uchar*) &w, i);
- if (pthread_create(&th, &connection_attrib, handle_slave_worker,
+ if (DBUG_EVALUATE_IF("mts_worker_thread_fails", i == 1, 0) ||
+ pthread_create(&th, &connection_attrib, handle_slave_worker,
(void*) w))
{
sql_print_error("Failed during slave worker thread create");
@@ -4397,6 +4399,17 @@ int slave_start_single_worker(Relay_log_
insert_dynamic(&rli->least_occupied_workers, (uchar*) &w->jobs.len);
err:
+ if (error && w)
+ {
+ w->end_info();
+ delete w;
+ /*
+ Any failure after dynarray inserted must follow with deletion
+ of just created item.
+ */
+ if (rli->workers.elements == i + 1)
+ delete_dynamic_element(&rli->workers, i);
+ }
return error;
}
@@ -4408,7 +4421,7 @@ err:
@return 0 success
non-zero as failure
*/
-int slave_start_workers(Relay_log_info *rli, ulong n)
+int slave_start_workers(Relay_log_info *rli, ulong n, bool *mts_inited)
{
uint i;
int error= 0;
@@ -4416,6 +4429,8 @@ int slave_start_workers(Relay_log_info *
if (n == 0)
return error;
+ *mts_inited= true;
+
// RLI constructor time alloc/init
rli->init_workers(n);
@@ -4431,7 +4446,7 @@ int slave_start_workers(Relay_log_info *
/*
GAQ queue holds seqno:s of scheduled groups. C polls workers in
- @c lwm_checkpoint_period to update GAQ (see @c next_event())
+ @c opt_mts_checkpoint_period to update GAQ (see @c next_event())
The length of GAQ is set to be equal to checkpoint_group.
Notice, the size matters for mts_checkpoint_routine's progress loop.
*/
@@ -4462,12 +4477,6 @@ int slave_start_workers(Relay_log_info *
init_alloc_root(&rli->mts_coor_mem_root, NAME_LEN,
(MAX_DBS_IN_EVENT_MTS / 2) * NAME_LEN);
- for (i= 0; i < n; i++)
- {
- if ((error= slave_start_single_worker(rli, i)))
- goto err;
- }
-
if (init_hash_workers(n)) // MTS: mapping_db_to_worker
{
sql_print_error("Failed to init partitions hash");
@@ -4475,6 +4484,12 @@ int slave_start_workers(Relay_log_info *
goto err;
}
+ for (i= 0; i < n; i++)
+ {
+ if ((error= slave_start_single_worker(rli, i)))
+ goto err;
+ }
+
err:
rli->slave_parallel_workers= rli->workers.elements;
// end recovery right now if mts_recovery_groups() did not find any gaps
@@ -4494,14 +4509,16 @@ err:
worker's running_status.
Coordinator finalizes with its MTS running status to reset few objects.
*/
-void slave_stop_workers(Relay_log_info *rli)
+void slave_stop_workers(Relay_log_info *rli, bool *mts_inited)
{
int i;
THD *thd= rli->info_thd;
- if (rli->slave_parallel_workers == 0)
+ if (!*mts_inited)
return;
-
+ else if (rli->slave_parallel_workers == 0)
+ goto end;
+
/*
In case of the "soft" graceful stop Coordinator
guaranteed Workers were assigned with full groups so waiting
@@ -4597,6 +4614,7 @@ void slave_stop_workers(Relay_log_info *
DBUG_ASSERT(rli->pending_jobs == 0);
DBUG_ASSERT(rli->mts_pending_jobs_size == 0);
+end:
rli->mts_group_status= Relay_log_info::MTS_NOT_IN_GROUP;
destroy_hash_workers(rli);
delete rli->gaq;
@@ -4606,6 +4624,7 @@ void slave_stop_workers(Relay_log_info *
rli->deinit_workers();
rli->slave_parallel_workers= 0;
free_root(&rli->mts_coor_mem_root, MYF(0));
+ *mts_inited= false;
}
/**
@@ -4628,7 +4647,8 @@ pthread_handler_t handle_slave_sql(void
Relay_log_info* rli = ((Master_info*)arg)->rli;
const char *errmsg;
-
+ bool mts_inited= false;
+
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init();
DBUG_ENTER("handle_slave_sql");
@@ -4671,7 +4691,7 @@ pthread_handler_t handle_slave_sql(void
mysql_mutex_unlock(&LOCK_thread_count);
/* MTS: starting the worker pool */
- if (slave_start_workers(rli, rli->opt_slave_parallel_workers) != 0)
+ if (slave_start_workers(rli, rli->opt_slave_parallel_workers, &mts_inited) != 0)
{
mysql_cond_broadcast(&rli->start_cond);
mysql_mutex_unlock(&rli->run_lock);
@@ -4921,7 +4941,7 @@ llstr(rli->get_group_master_log_pos(), l
err:
- slave_stop_workers(rli); // stopping worker pool before clearing own error
+ slave_stop_workers(rli, &mts_inited); // stopping worker pool
/*
Some events set some playgrounds, which won't be cleared because thread
@@ -6229,9 +6249,9 @@ static Log_event* next_event(Relay_log_i
MTS checkpoint in the successful read branch
*/
bool force= (rli->checkpoint_seqno > (rli->checkpoint_group - 1));
- if (rli->is_parallel_exec() && (mts_checkpoint_period != 0 || force))
+ if (rli->is_parallel_exec() && (opt_mts_checkpoint_period != 0 || force))
{
- ulonglong period= static_cast<ulonglong>(mts_checkpoint_period * 1000000ULL);
+ ulonglong period= static_cast<ulonglong>(opt_mts_checkpoint_period * 1000000ULL);
mysql_mutex_unlock(&rli->data_lock);
/*
At this point the coordinator has is delegating jobs to workers and
@@ -6367,12 +6387,12 @@ static Log_event* next_event(Relay_log_i
mysql_cond_broadcast(&rli->log_space_cond);
// Note that wait_for_update_relay_log unlocks lock_log !
- if (rli->is_parallel_exec() && (mts_checkpoint_period != 0 ||
+ if (rli->is_parallel_exec() && (opt_mts_checkpoint_period != 0 ||
DBUG_EVALUATE_IF("check_slave_debug_group", 1, 0)))
{
int ret= 0;
struct timespec waittime;
- ulonglong period= static_cast<ulonglong>(mts_checkpoint_period * 1000000ULL);
+ ulonglong period= static_cast<ulonglong>(opt_mts_checkpoint_period * 1000000ULL);
ulong signal_cnt= rli->relay_log.signal_cnt;
mysql_mutex_unlock(log_lock);
@@ -6863,10 +6883,15 @@ int start_slave(THD* thd , Master_info*
if (thread_mask & SLAVE_SQL)
{
/*
- To cache the system var value and used it in the following.
- The system var can change but not the cached.
+ To cache the MTS system var values and used them in the following
+ runtime. The system var:s can change meanwhile but having no other
+ effects.
*/
mi->rli->opt_slave_parallel_workers= opt_mts_slave_parallel_workers;
+#ifndef DBUG_OFF
+ if (!DBUG_EVALUATE_IF("check_slave_debug_group", 1, 0))
+#endif
+ mi->rli->checkpoint_group= opt_mts_checkpoint_group;
mysql_mutex_lock(&mi->rli->data_lock);
=== modified file 'sql/rpl_slave.h'
--- a/sql/rpl_slave.h 2011-08-19 13:04:28 +0000
+++ b/sql/rpl_slave.h 2011-11-24 18:26:55 +0000
@@ -57,6 +57,7 @@ typedef enum { SLAVE_THD_IO, SLAVE_THD_S
#define MTS_WORKER_UNDEF ((ulong) -1)
#define MTS_MAX_WORKERS 1024
+#define MTS_MAX_BITS_IN_GROUP ((1L << 19) - 1) /* 524287 */
// Forward declarations
class Relay_log_info;
=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc 2011-12-02 16:18:37 +0000
+++ b/sql/sys_vars.cc 2011-12-16 15:54:23 +0000
@@ -3637,7 +3637,7 @@ static Sys_var_uint Sys_checkpoint_mts_p
"slave_checkpoint_period", "Gather workers' activities to "
"Update progress status of Multi-threaded slave and flush "
"the relay log info to disk after every #th milli-seconds.",
- GLOBAL_VAR(mts_checkpoint_period), CMD_LINE(REQUIRED_ARG),
+ GLOBAL_VAR(opt_mts_checkpoint_period), CMD_LINE(REQUIRED_ARG),
#ifndef DBUG_OFF
VALID_RANGE(0, UINT_MAX), DEFAULT(300), BLOCK_SIZE(1));
#else
@@ -3648,11 +3648,11 @@ static Sys_var_uint Sys_checkpoint_mts_g
"slave_checkpoint_group",
"Maximum number of processed transactions by Multi-threaded slave "
"before a checkpoint operation is called to update progress status.",
- GLOBAL_VAR(mts_checkpoint_group), CMD_LINE(REQUIRED_ARG),
+ GLOBAL_VAR(opt_mts_checkpoint_group), CMD_LINE(REQUIRED_ARG),
#ifndef DBUG_OFF
- VALID_RANGE(1, UINT_MAX), DEFAULT(512), BLOCK_SIZE(1));
+ VALID_RANGE(1, MTS_MAX_BITS_IN_GROUP), DEFAULT(512), BLOCK_SIZE(1));
#else
- VALID_RANGE(512, UINT_MAX), DEFAULT(512), BLOCK_SIZE(8));
+ VALID_RANGE(512, MTS_MAX_BITS_IN_GROUP), DEFAULT(512), BLOCK_SIZE(8));
#endif /* DBUG_OFF */
#endif /* HAVE_REPLICATION */
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (andrei.elkin:3661) | Andrei Elkin | 20 Dec |