#At file:///home/andrei/MySQL/BZR/2a-23May/WL/mysql-next-mr-wl5569/ based on revid:andrei.elkin@stripped
3321 Andrei Elkin 2011-06-24
wl#5569 MTS
This patch makes a bit of cleanup, addresses one memory-allocation todo and completes fixing valgrind report (rpl_parallel_start_stop) due to strings allocation in Slave_job_group items.
modified:
sql/log_event.cc
sql/rpl_rli.h
sql/rpl_rli_pdb.cc
sql/rpl_rli_pdb.h
sql/rpl_slave.cc
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2011-06-22 17:54:23 +0000
+++ b/sql/log_event.cc 2011-06-24 12:38:19 +0000
@@ -2475,7 +2475,7 @@ Slave_worker *Log_event::get_slave_worke
{
int i= 0;
num_dbs= mts_number_dbs();
- List_iterator<char> it(*mts_get_dbs(thd->mem_root));
+ List_iterator<char> it(*mts_get_dbs(&rli->mts_coor_mem_root));
it++;
ret_worker= rli->last_assigned_worker;
@@ -2526,14 +2526,6 @@ Slave_worker *Log_event::get_slave_worke
}
DBUG_ASSERT(i == num_dbs || num_dbs == OVER_MAX_DBS_IN_EVENT_MTS);
-
- // TODO: convert to C's private mem_root to reset not per event but rather realrely.
-
- // Releasing the Coord's mem-root from the updated dbs. It's safe to do at this
- // point because the root is no longer needed along remained part of Coordinator's
- // execution flow.
-
- free_root(thd->mem_root, MYF(MY_KEEP_PREALLOC));
}
else
{
@@ -2609,8 +2601,14 @@ Slave_worker *Log_event::get_slave_worke
DBUG_ASSERT(ret_worker != NULL);
- // TODO: UNTIL option, throw an error when relay-log reading
- // starts from inside of a group!!
+ /*
+ The following two blocks are executed if the worker has not been
+ notified about new relay-log or a new checkpoints.
+ Relay-log string is freed by Coordinator, Worker deallocates
+ strings in the checkpoint block.
+ However if the worker exits earlier reclaiming for both happens anyway at
+ GAQ delete.
+ */
if (!ret_worker->relay_log_change_notified) // ALFRANIO
{
@@ -2633,13 +2631,6 @@ Slave_worker *Log_event::get_slave_worke
ret_worker->relay_log_change_notified= TRUE;
}
- /*
- This executed if the worker has not been notified by a recent
- set of checkpoints.
- Notice that it is the worker responsibility to deallocate the
- memory allocated at this point. This is done upon committing
- this job.
- */
if (!ret_worker->checkpoint_notified)
{
ptr_g->checkpoint_log_name= (char *)
@@ -2661,6 +2652,9 @@ Slave_worker *Log_event::get_slave_worke
ptr_g->checkpoint_seqno= rli->checkpoint_seqno;
ptr_g->ts= when + (time_t) exec_time;
rli->checkpoint_seqno++;
+
+ // reclaiming resources allocated during the group scheduling
+ free_root(&rli->mts_coor_mem_root, MYF(MY_KEEP_PREALLOC));
}
return ret_worker;
=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h 2011-06-22 17:54:23 +0000
+++ b/sql/rpl_rli.h 2011-06-24 12:38:19 +0000
@@ -460,6 +460,7 @@ public:
ulong opt_slave_parallel_workers; // auxiliary cache for ::opt_slave_parallel_workers
ulong slave_parallel_workers; // the one slave session time number of workers
ulong recovery_parallel_workers; // number of workers while recovering.
+
/*
A sorted array of Worker current assignements number to provide
approximate view on Workers loading.
@@ -473,6 +474,7 @@ public:
ulong mts_recovery_group_cnt; // number of groups to execute at recovery
ulong mts_recovery_index; // running index of recoverable groups
bool mts_recovery_group_seen_begin;
+
/*
temporary tables are held by Coordinator though are created and dropped
explicilty by Workers. The following lock has to be taken by either party
@@ -480,16 +482,27 @@ public:
find, drop, create, open.
*/
mysql_mutex_t mts_temp_tables_lock;
+
/*
- While Worker utilize its thd->mem_root, Coordinator adopts a specific mem-root:
+ Coordinator's specific mem-root to hold various temporary data while
+ the current group is being schedulled. The root is shunk to default size
+ at the end of the group distribution.
*/
MEM_ROOT mts_coor_mem_root;
+
/*
- While distibuting events basing on their properties MTS Coordinator
- changes its mts group status.
- Transition from NOT_IN to IN happens once an event is scheduled to a Worker.
- Reverse transition occures when Coordinator requests synchronization with
- Workers demanding them to complete their assignments.
+ While distibuting events basing on their properties MTS
+ Coordinator changes its mts group status.
+ Transition normally flowws to follow `=>' arrows on the diagram:
+
+ +----------------------------+
+ V |
+ MTS_NOT_IN_GROUP => |
+ {MTS_IN_GROUP => MTS_END_GROUP --+} while (!killed) => MTS_KILLED_GROUP
+
+ though MTS_END_GROUP has `->' link to MTS_NOT_IN_GROUP
+ when Coordinator synchronizes with Workers by demanding them to complete their
+ assignments.
*/
enum
{
=== modified file 'sql/rpl_rli_pdb.cc'
--- a/sql/rpl_rli_pdb.cc 2011-06-21 16:10:54 +0000
+++ b/sql/rpl_rli_pdb.cc 2011-06-24 12:38:19 +0000
@@ -1135,6 +1135,14 @@ void Slave_committed_queue::free_dynamic
{
my_free(ptr_g->group_relay_log_name);
}
+ if (ptr_g->checkpoint_log_name)
+ {
+ my_free(ptr_g->checkpoint_log_name);
+ }
+ if (ptr_g->checkpoint_relay_log_name)
+ {
+ my_free(ptr_g->checkpoint_relay_log_name);
+ }
}
}
=== modified file 'sql/rpl_rli_pdb.h'
--- a/sql/rpl_rli_pdb.h 2011-06-21 14:05:32 +0000
+++ b/sql/rpl_rli_pdb.h 2011-06-24 12:38:19 +0000
@@ -210,6 +210,7 @@ public:
{
delete_dynamic(&last_done);
my_free(lwm.group_relay_log_name);
+ free_dynamic_items(); // free possibly left allocated strings in GAQ list
}
}
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc 2011-06-22 18:17:43 +0000
+++ b/sql/rpl_slave.cc 2011-06-24 12:38:19 +0000
@@ -4490,8 +4490,6 @@ void slave_stop_workers(Relay_log_info *
rli->mts_group_status= Relay_log_info::MTS_NOT_IN_GROUP;
destroy_hash_workers(rli);
- // free possibly allocated strings in GAQ's list
- rli->gaq->free_dynamic_items();
delete rli->gaq;
delete_dynamic(&rli->least_occupied_workers); // least occupied
delete_dynamic(&rli->curr_group_da); // GCDA
Attachment: [text/bzr-bundle] bzr/andrei.elkin@oracle.com-20110624123819-buljr7f1ib9a7y49.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-wl5569 branch (andrei.elkin:3321) WL#5569 | Andrei Elkin | 25 Jun |